-
Notifications
You must be signed in to change notification settings - Fork 776
249 lines (233 loc) · 8.02 KB
/
build-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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
name: Build and test MicroK8s snap
on:
- pull_request
jobs:
build:
name: Create snap package
runs-on: ubuntu-20.04
steps:
- name: Checking out repo
uses: actions/checkout@v4
- name: Install lxd
run: |
sudo lxd init --auto
sudo usermod --append --groups lxd $USER
sg lxd -c 'lxc version'
- name: Install snapcraft
run: |
sudo snap install snapcraft --classic
- name: Install snapd from candidate
run: |
# TODO(neoaggelos): revert this after latest/beta is working again
sudo snap refresh snapd --channel=latest/stable
- name: Build snap
run: |
sg lxd -c 'snapcraft --use-lxd'
sudo mv microk8s*.snap microk8s.snap
- name: Uploading snap
uses: actions/upload-artifact@v3
with:
name: microk8s.snap
path: microk8s.snap
test-upgrade:
name: Upgrade path test
runs-on: ubuntu-20.04
needs: build
steps:
- name: Checking out repo
uses: actions/checkout@v4
- name: Install test dependencies
run: |
set -x
sudo apt-get install python3-setuptools
sudo pip3 install --upgrade pip
sudo pip3 install -U pytest sh
sudo apt-get -y install open-iscsi
sudo systemctl enable iscsid
- name: Fetch snap
uses: actions/[email protected]
with:
name: microk8s.snap
path: build
- name: Running upgrade path test
run: |
sudo -E STRICT="yes" UPGRADE_MICROK8S_FROM=1.30-strict/edge UPGRADE_MICROK8S_TO=$PWD/build/microk8s.snap pytest -s ./tests/test-upgrade-path.py
test-addons-core:
name: Test core addons
runs-on: ubuntu-20.04
needs: build
steps:
- name: Checking out repo
uses: actions/checkout@v4
- name: Install test dependencies
run: |
set -x
sudo apt-get install python3-setuptools
sudo pip3 install --upgrade pip
sudo pip3 install -U pytest sh
sudo apt-get -y install open-iscsi
sudo systemctl enable iscsid
- name: Fetch snap
uses: actions/[email protected]
with:
name: microk8s.snap
path: build
- name: Running addons tests in strict mode
run: |
set -x
sudo snap install build/microk8s.snap --dangerous
sudo /snap/microk8s/current/connect-all-interfaces.sh
sudo microk8s status --wait-ready --timeout 300
./tests/smoke-test.sh
export UNDER_TIME_PRESSURE="True"
export STRICT="yes"
sudo -E bash -c "cd /var/snap/microk8s/common/addons/core/tests; pytest -s -ra test-addons.py"
test-addons-community:
name: Test community addons
runs-on: ubuntu-20.04
needs: build
steps:
- name: Checking out repo
uses: actions/checkout@v4
- name: Install test dependencies
run: |
set -x
sudo apt-get install python3-setuptools
sudo pip3 install --upgrade pip
sudo pip3 install -U pytest sh
sudo apt-get -y install open-iscsi
sudo systemctl enable iscsid
- name: Fetch snap
uses: actions/[email protected]
with:
name: microk8s.snap
path: build
# - name: Setup tmate session
# uses: mxschmitt/action-tmate@v3
- name: Running addons tests
run: |
set -x
sudo snap install build/microk8s.snap --classic --dangerous
sudo /snap/microk8s/current/connect-all-interfaces.sh
sudo microk8s status --wait-ready --timeout 300
sudo microk8s enable community
export UNDER_TIME_PRESSURE="True"
export STRICT="yes"
sudo -E bash -c "cd /var/snap/microk8s/common/addons/community/; pytest -s -ra ./tests/"
test-addons-core-upgrade:
name: Test core addons upgrade
runs-on: ubuntu-20.04
needs: build
steps:
- name: Checking out repo
uses: actions/checkout@v4
# - name: Setup tmate session
# uses: mxschmitt/action-tmate@v3
- name: Install test dependencies
run: |
set -x
sudo apt-get install python3-setuptools
sudo pip3 install --upgrade pip
sudo pip3 install -U pytest sh
sudo apt-get -y install open-iscsi
sudo systemctl enable iscsid
- name: Fetch snap
uses: actions/[email protected]
with:
name: microk8s.snap
path: build
- name: Running upgrade tests
run: |
set -x
export UNDER_TIME_PRESSURE="True"
export STRICT="yes"
sudo -E bash -c "UPGRADE_MICROK8S_FROM=1.30-strict/edge UPGRADE_MICROK8S_TO=$PWD/build/microk8s.snap pytest -s ./tests/test-upgrade.py"
test-cluster-agent:
name: Cluster agent health check
runs-on: ubuntu-20.04
needs: build
steps:
- name: Checking out repo
uses: actions/checkout@v4
- name: Install test dependencies
run: |
set -x
sudo apt-get install python3-setuptools
sudo pip3 install --upgrade pip
sudo pip3 install -U pytest sh requests
- name: Fetch snap
uses: actions/[email protected]
with:
name: microk8s.snap
path: build
- name: Running cluster agent health check
run: |
set -x
sudo snap install build/microk8s.snap --classic --dangerous
sudo /snap/microk8s/current/connect-all-interfaces.sh
sudo -E bash -c "pytest -s ./tests/test-cluster-agent.py"
test-airgap:
name: Test airgap installation
runs-on: ubuntu-20.04
needs: build
steps:
- name: Checking out repo
uses: actions/checkout@v4
- name: Fetch snap
uses: actions/[email protected]
with:
name: microk8s.snap
path: build
- name: Initialize LXD
run: |
sudo lxd init --auto
sudo lxc network set lxdbr0 ipv6.address=none
sudo usermod --append --groups lxd $USER
sg lxd -c 'lxc version'
- name: Run airgap tests
run: |
sudo -E bash -x -c "./tests/libs/airgap.sh --distro ubuntu:20.04 --channel $PWD/build/microk8s.snap"
security-scan:
name: Security scan
runs-on: ubuntu-20.04
needs: build
steps:
- name: Checking out repo
uses: actions/checkout@v4
- name: Fetch snap
uses: actions/[email protected]
with:
name: microk8s.snap
path: build
- name: Setup Trivy vulnerability scanner
run: |
mkdir -p sarifs
VER=$(curl --silent -qI https://github.com/aquasecurity/trivy/releases/latest | awk -F '/' '/^location/ {print substr($NF, 1, length($NF)-1)}');
wget https://github.com/aquasecurity/trivy/releases/download/${VER}/trivy_${VER#v}_Linux-64bit.tar.gz
tar -zxvf ./trivy_${VER#v}_Linux-64bit.tar.gz
- name: Run Trivy vulnerability scanner in repo mode
uses: aquasecurity/trivy-action@master
with:
scan-type: "fs"
ignore-unfixed: true
format: "sarif"
output: "trivy-microk8s-repo-scan--results.sarif"
severity: "CRITICAL"
- name: Gather Trivy repo scan results
run: |
cp trivy-microk8s-repo-scan--results.sarif ./sarifs/
- name: Run Trivy vulnerability scanner on images
run: |
for i in $(cat ./build-scripts/images.txt) ; do
name=$(echo $i | awk -F ':|/' '{print $(NF-1)}')
./trivy image $i --format sarif > sarifs/$name.sarif
done
- name: Run Trivy vulnerability scanner on the snap
run: |
cp build/microk8s.snap .
unsquashfs microk8s.snap
./trivy rootfs ./squashfs-root/ --format sarif > sarifs/snap.sarif
- name: Upload Trivy scan results to GitHub Security tab
uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: "sarifs"