Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-enable functional tests in CI #522

Closed
wants to merge 10 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,46 @@ jobs:
bundler-cache: true
- name: Run rubocop
run: bundle exec rake lint

functional:
runs-on: macos-latest-xl
env:
VAGRANT_DISABLE_VBOXSYMLINKCREATE: "1"
strategy:
max-parallel: 1
matrix:
ruby: ["2.0", "3.3"]
steps:
- uses: actions/checkout@v4

- name: Cache Vagrant boxes
uses: actions/cache@v3
with:
path: ~/.vagrant.d/boxes
key: ${{ runner.os }}-vagrant-v2-${{ hashFiles('Vagrantfile') }}
restore-keys: |
${{ runner.os }}-vagrant-v2-

- name: Run vagrant up
run: vagrant up

- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true

- name: Run functional tests
run: bundle exec rake test:functional

functional-all:
runs-on: ubuntu-latest
needs: [functional]
if: always()
steps:
- name: All tests ok
if: ${{ !(contains(needs.*.result, 'failure')) }}
run: exit 0
- name: Some tests failed
if: ${{ contains(needs.*.result, 'failure') }}
run: exit 1
9 changes: 8 additions & 1 deletion Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,15 @@ VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = 'bento/ubuntu-22.10'

config.vm.boot_timeout = 600 # seconds
config.vm.provider 'virtualbox' do |vb|
vb.memory = 1024
vb.cpus = 1

# https://github.com/hashicorp/vagrant/issues/11777#issuecomment-661076612
vb.customize ["modifyvm", :id, "--uart1", "0x3F8", "4"]
vb.customize ["modifyvm", :id, "--uartmode1", "file", File::NULL]
end
config.ssh.insert_key = false
config.vm.provision "shell", inline: <<-SHELL
echo 'ClientAliveInterval 3' >> /etc/ssh/sshd_config
Expand Down
2 changes: 1 addition & 1 deletion lib/sshkit/backends/netssh/sftp_transfer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def download!(remote, local, options)
end

def on_get(download, entry, offset, data)
entry.size ||= download.sftp.file.open(entry.remote, &:size)
entry.size ||= download.sftp.file.open(entry.remote) { |file| file.stat.size }
summarizer.call(nil, entry.remote, offset + data.bytesize, entry.size)
end

Expand Down
8 changes: 0 additions & 8 deletions test/boxes.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,5 @@
"user": "vagrant",
"password": "vagrant",
"hostname": "localhost"
},
{
"name": "two",
"port": 3002
},
{
"name": "three",
"port": 3003
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def test_that_it_works
def test_creating_a_user_gives_us_back_his_private_key_as_a_string
skip 'It is not safe to create an user for non vagrant envs' unless VagrantWrapper.running?
keys = create_user_with_key(:peter)
assert_equal [:one, :two, :three], keys.keys
assert_equal [:one], keys.keys
assert keys.values.all?
end

Expand Down
Loading