Skip to content

Commit

Permalink
Add use_lxd option (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
casperdcl authored Feb 18, 2020
1 parent 9c9f8f8 commit b8cb8b4
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 1 deletion.
20 changes: 20 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,23 @@ jobs:
snapcraft_token: ${{ secrets.snapcraft_token }}
- name: User should be logged in
run: snapcraft whoami

# Install with lxd
lxd:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
steps:
- name: Check out Git repository
uses: actions/checkout@v1
- name: Run action
uses: ./
- name: lxd should not be available
run: "! /snap/bin/lxd waitready"
- name: Run action requesting lxd
uses: ./
with:
use_lxd: true
- name: lxd should be installed
run: "/snap/bin/lxd version"
15 changes: 14 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:

steps:
- name: Check out Git repository
uses: actions/checkout@v1
uses: actions/checkout@v2

- name: Install Snapcraft
uses: samuelmeuli/action-snapcraft@v1
Expand Down Expand Up @@ -66,6 +66,19 @@ Finally, add the following option to your workflow step:
skip_install: true # optional, if already installed in an earlier step
```
### Build using LXD
LXD (`runs-on: ubuntu-latest`) is for now likely the easiest way to get `snapcraft` to build snaps. This is an alternative to using `multipass` (GitHub VMs give the error `launch failed: CPU does not support KVM extensions.` when trying to use `multipass`). It takes between 1 to ~10 minutes to set up `lxd` (varies wildly between runs).

```yml
- name: Install Snapcraft with LXD
uses: samuelmeuli/action-snapcraft@v1
with:
use_lxd: true
- name: Build snap
run: snapcraft --use-lxd
```

## Development

Suggestions and contributions are always welcome! Please discuss larger changes via issue before submitting a pull request.
Expand Down
3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ inputs:
skip_install:
description: Skip installation (login only)
required: false
use_lxd:
description: Whether to install and configure lxd
required: false

runs:
using: node12
Expand Down
9 changes: 9 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,17 @@ const getPlatform = () => {
* Installs Snapcraft on Linux
*/
const runLinuxInstaller = () => {
const lxd = process.env.INPUT_USE_LXD === "true";
run("sudo snap install snapcraft --classic");
if (lxd) {
run("sudo snap install lxd");
}
run("sudo chown root:root /"); // Fix root ownership
if (lxd) {
run("sudo /snap/bin/lxd.migrate -yes");
run("sudo /snap/bin/lxd waitready");
run("sudo /snap/bin/lxd init --auto");
}
};

/**
Expand Down

0 comments on commit b8cb8b4

Please sign in to comment.