Skip to content

Commit

Permalink
Merge pull request #24 from sergiusens/patch-1
Browse files Browse the repository at this point in the history
tools: do not fail if LXD snap cannot be refreshed
  • Loading branch information
kenvandine authored Sep 17, 2021
2 parents 61deecb + f2f9b1a commit a400bf1
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 3 deletions.
19 changes: 18 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ jobs:
strategy:
matrix:
project:
- core
- core18
- core20
steps:
Expand All @@ -34,6 +33,24 @@ jobs:
name: 'snap'
path: ${{ steps.snapcraft.outputs.snap}}

integration-legacy: # make sure the action works on a clean machine without building
runs-on: ubuntu-latest
strategy:
matrix:
project:
- core
steps:
- uses: actions/checkout@v2
- uses: ./
id: snapcraft
with:
path: './test-projects/${{ matrix.project }}'
snapcraft-channel: 4.x/stable
- uses: actions/upload-artifact@v2
with:
name: 'snap'
path: ${{ steps.snapcraft.outputs.snap}}

check-runner: # make sure the action works on each VM image
strategy:
matrix:
Expand Down
12 changes: 11 additions & 1 deletion dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1620,7 +1620,17 @@ function ensureLXD() {
// Ensure that the "lxd" group exists
const haveSnapLXD = yield haveExecutable('/snap/bin/lxd');
Object(core.info)('Installing LXD...');
yield Object(exec.exec)('sudo', ['snap', haveSnapLXD ? 'refresh' : 'install', 'lxd']);
if (haveSnapLXD) {
try {
yield Object(exec.exec)('sudo', ['snap', 'refresh', 'lxd']);
}
catch (err) {
Object(core.info)("LXD could not be refreshed...");
}
}
else {
yield Object(exec.exec)('sudo', ['snap', 'install', 'lxd']);
}
Object(core.info)('Initialising LXD...');
yield Object(exec.exec)('sudo', ['lxd', 'init', '--auto']);
});
Expand Down
10 changes: 9 additions & 1 deletion src/tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,15 @@ export async function ensureLXD(): Promise<void> {
// Ensure that the "lxd" group exists
const haveSnapLXD = await haveExecutable('/snap/bin/lxd')
core.info('Installing LXD...')
await exec.exec('sudo', ['snap', haveSnapLXD ? 'refresh' : 'install', 'lxd'])
if (haveSnapLXD) {
try {
await exec.exec('sudo', ['snap', 'refresh', 'lxd'])
} catch (err) {
core.info('LXD could not be refreshed...')
}
} else {
await exec.exec('sudo', ['snap', 'install', 'lxd'])
}
core.info('Initialising LXD...')
await exec.exec('sudo', ['lxd', 'init', '--auto'])
}
Expand Down

0 comments on commit a400bf1

Please sign in to comment.