-
Notifications
You must be signed in to change notification settings - Fork 3
134 lines (116 loc) · 3.42 KB
/
build-and-test-snap.yml
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
name: Build, test and publish snap
on:
schedule:
- cron: "20 2 * * 1" # Monday morning 02:20 UTC
push:
branches: [ main ]
pull_request:
branches: [ main ]
# Allow manual trigger
workflow_dispatch:
env:
ARTIFACT_AMD64: chip-tool_${{ github.run_number}}_amd64
ARTIFACT_ARM64: chip-tool_${{ github.run_number}}_arm64
jobs:
build-amd64:
outputs:
snap: ${{ steps.snapcraft.outputs.snap }}
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Build snap
uses: snapcore/action-build@v1
id: snapcraft
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ env.ARTIFACT_AMD64 }}
path: ${{ steps.snapcraft.outputs.snap }}
if-no-files-found: error
test-amd64:
needs: build-amd64
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
lfs: true
- name: Download locally built snap
uses: actions/download-artifact@v4
with:
name: ${{ env.ARTIFACT_AMD64 }}
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: '1.*'
cache: false
- name: Run tests
shell: bash
working-directory: tests
env:
SKIP_TEARDOWN_REMOVAL: true
LOCAL_SERVICE_SNAP: ../${{ needs.build-amd64.outputs.snap }}
run: |
go test -failfast -p 1 -timeout 30m -v
- name: Upload snap logs
if: always()
uses: actions/upload-artifact@v4
with:
name: logs
path: tests/logs/*.log
publish-amd64:
# Only publish if we are on the main branch
if: github.ref == 'refs/heads/main'
needs: [build-amd64, test-amd64]
runs-on: ubuntu-latest
steps:
- name: Download locally built snap
uses: actions/download-artifact@v4
with:
name: ${{ env.ARTIFACT_AMD64 }}
- uses: snapcore/action-publish@v1
env:
SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.STORE_LOGIN }}
with:
snap: ${{ needs.build-amd64.outputs.snap }}
release: latest/edge
build-arm64:
# We do not start the long running arm64 build unless the amd64 tests have passed.
needs: test-amd64
outputs:
snap: ${{ steps.snapcraft.outputs.snap }}
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: arm64
- name: Build snap
uses: diddlesnaps/snapcraft-multiarch-action@v1
id: snapcraft
with:
architecture: arm64
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ env.ARTIFACT_ARM64 }}
path: ${{ steps.snapcraft.outputs.snap }}
publish-arm64:
# Only publish if we are on the main branch
if: github.ref == 'refs/heads/main'
needs: [build-arm64]
runs-on: ubuntu-latest
steps:
- name: Download locally built snap
uses: actions/download-artifact@v4
with:
name: ${{ env.ARTIFACT_ARM64 }}
- uses: snapcore/action-publish@v1
env:
SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.STORE_LOGIN }}
with:
snap: ${{ needs.build-arm64.outputs.snap }}
release: latest/edge