Skip to content

Commit

Permalink
ci: use snapcraft build container instead of destructive
Browse files Browse the repository at this point in the history
There are some dependencies leaking into the snap from the build host.
Use LXD and build containers to isolate the snap from that type of
thing.

Signed-off-by: Kyle Fazzari <kyrofa@ubuntu.com>
  • Loading branch information
kyrofa committed Apr 15, 2022
1 parent f4e10b5 commit c1b4a40
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 14 deletions.
7 changes: 4 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,11 @@ jobs:
uses: actions/checkout@v2

- name: Install dependencies
run: sudo apt-get update -qq && sudo snap install --classic snapcraft
run: sudo apt-get update -qq && sudo apt-get remove -qq lxd lxd-client && sudo snap install lxd && sudo lxd init --auto && sudo snap install --classic snapcraft

# Using sudo here because our CI user isn't a member of the lxd group
- name: Build snap
run: snapcraft --destructive-mode
run: sudo snapcraft --provider lxd

- name: Review snap
run: sudo snap install review-tools && /snap/bin/review-tools.snap-review *.snap
Expand All @@ -56,4 +57,4 @@ jobs:

- name: Run integration tests
working-directory: tests
run: bundle exec ./run-tests.sh integration
run: bundle exec ./run-tests.sh integration
26 changes: 15 additions & 11 deletions tests/integration/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -162,11 +162,10 @@
Capybara.current_session.driver.quit

# After each test, make sure maintenance mode is reset
`sudo nextcloud.occ -n maintenance:mode --off 2>&1`
expect($?.to_i).to eq 0
run 'sudo nextcloud.occ -n maintenance:mode --off 2>&1'

# Maintenance mode takes a second to apply (opcache)
sleep 2
# Maintenance mode takes two seconds to apply (opcache)
sleep 3

# Make sure any and all backups are removed
`sudo rm -rf /var/snap/nextcloud/common/backups`
Expand All @@ -176,8 +175,7 @@
end

def enable_https(port: nil)
`sudo nextcloud.enable-https self-signed`
expect($?.to_i).to eq 0
run 'sudo nextcloud.enable-https self-signed'
wait_for_nextcloud(https: true, port: port)
end

Expand Down Expand Up @@ -229,10 +227,8 @@ def set_config(options)
options_string += "#{key}=#{value} "
end

`sudo snap set nextcloud #{options_string}`
expect($?.to_i).to eq 0
`snap watch --last=configure-snap`
expect($?.to_i).to eq 0
run "sudo snap set nextcloud #{options_string}"
run 'snap watch --last=configure-snap'
end

def nextcloud_is_installed
Expand All @@ -242,8 +238,16 @@ def nextcloud_is_installed

def install_nextcloud
unless nextcloud_is_installed
`sudo nextcloud.manual-install admin admin`
run 'sudo nextcloud.manual-install admin admin'
end
end

def run(command, expect_success: true)
system(command)
if expect_success
expect($?.to_i).to eq 0
else
expect($?.to_i).not_to eq 0
end
end
end

0 comments on commit c1b4a40

Please sign in to comment.