-
Notifications
You must be signed in to change notification settings - Fork 3
92 lines (87 loc) · 2.72 KB
/
snap-lxc.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
name: build-install-test-snap-lxc
on:
workflow_call:
inputs:
lxc-image:
required: true
type: string
ubuntu-image:
required: false
type: string
default: "ubuntu-latest"
snapcraft-channel:
required: false
type: string
default: "latest/stable"
snap-name:
required: true
type: string
branch-name:
required: true
type: string
snapcraft-args:
required: false
type: string
snap-install-args:
required: false
type: string
enable-experimental-extensions-env:
required: false
type: boolean
test-script:
description: "Custom script to run some custom snap testing"
required: false
type: string
jobs:
build:
uses: ubuntu-robotics/snap_workflows/.github/workflows/snap.yaml@main
with:
ubuntu-image: ${{ inputs.ubuntu-image }}
snapcraft-channel: ${{ inputs.snapcraft-channel }}
branch-name: ${{ inputs.branch-name }}
snap-name: ${{ inputs.snap-name }}
snap-install-args: ${{ inputs.snap-install-args }}
cleanup: false
test-on-lxc:
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/download-artifact@v4
name: ${{ inputs.snap-name }}-${{ inputs.branch-name }}
with:
path: .
- name: Setup LXD
uses: canonical/setup-lxd@v0.1.1
- name: Launch container
run: |
lxc launch '${{ inputs.lxc-image }}' lxc-container
lxc exec lxc-container -- cloud-init status --wait
until lxc exec lxc-container -- getent passwd ubuntu; do
echo "Waiting for the ubuntu user."
sleep 0.25
done
- name: Push snap to lxc container
run: |
lxc file push ${{ inputs.snap-name }}-${{ inputs.branch-name }}/${{ inputs.snap-name }}_*.snap lxc-container/home/ubuntu/
- name: Install snap
env:
SNAPCRAFT_INSTALL_ARGS : '${{ inputs.snap-install-args }}'
run: |
lxc exec lxc-container -- sh -c "snap install /home/ubuntu/${{ inputs.snap-name }}_*.snap $SNAPCRAFT_INSTALL_ARGS"
- name: Run custom test script
shell: bash
run: |
cat > test-script.sh << 'EOF'
${{ inputs.test-script }}
EOF
lxc file push test-script.sh lxc-container/home/ubuntu/
lxc exec --user 1000 lxc-container -- sh -c "bash /home/ubuntu/test-script.sh"
cleanup:
if: ${{ always() && !cancelled() && needs.build.result == 'success' && inputs.cleanup == true }}
runs-on: ubuntu-latest
needs: [build, test-on-lxc]
steps:
- name: Delete artifact
uses: geekyeggo/delete-artifact@v4
with:
name: ${{ inputs.snap-name }}-*