forked from canonical/snapd
-
Notifications
You must be signed in to change notification settings - Fork 0
285 lines (260 loc) · 11.7 KB
/
weekly-feature-tagging.yaml
File metadata and controls
285 lines (260 loc) · 11.7 KB
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
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
name: Feature Tagging
on:
workflow_dispatch:
inputs:
features:
type: string
description: 'Comma-separated list of features to tag'
default: 'cmd,task,change,ensure,endpoint,interface'
maximum-reruns:
type: number
description: 'Maximum number of times to rerun failed spread tasks'
default: 2
run-one-system:
type: string
description: 'When set, will only run this system in spread'
skip-tests:
type: string
description: 'Filters out all matches for each space-separated regex expression when running spread tests'
default: 'ubuntu-14.04-64 tests/lib/ tests/unit/ manual/snapd-refresh-from-old core/persistent-journal'
schedule:
- cron: '30 4 * * 6'
jobs:
set-inputs:
runs-on: ubuntu-latest
outputs:
features: ${{ steps.set-inputs.outputs.features }}
maximum-reruns: ${{ steps.set-inputs.outputs.maximum-reruns }}
run-one-system: ${{ steps.set-inputs.outputs.run-one-system }}
skip-tests: ${{ steps.set-inputs.outputs.skip-tests }}
steps:
- name: Set inputs
id: set-inputs
run: |
echo "features=${{ inputs.features || 'cmd,task,change,ensure,endpoint,interface' }}" >> $GITHUB_OUTPUT
echo "maximum-reruns=${{ inputs.maximum-reruns || 2 }}" >> $GITHUB_OUTPUT
echo "run-one-system=${{ inputs.run-one-system || '' }}" >> $GITHUB_OUTPUT
echo "skip-tests=${{ inputs.skip-tests || 'ubuntu-14.04-64 tests/lib/ tests/unit/ manual/snapd-refresh-from-old core/persistent-journal' }}" >> $GITHUB_OUTPUT
read-systems:
runs-on: ubuntu-latest
needs: set-inputs
outputs:
fundamental-systems: ${{ steps.read-systems.outputs.fundamental-systems }}
non-fundamental-systems: ${{ steps.read-systems.outputs.non-fundamental-systems }}
nested-systems: ${{ steps.read-systems.outputs.nested-systems }}
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Filter systems
if: needs.set-inputs.outputs.run-one-system != ''
run: |
echo 'fundamental_systems=""' >> $GITHUB_ENV
echo 'non_fundamental_systems=""' >> $GITHUB_ENV
echo 'nested_systems=""' >> $GITHUB_ENV
if grep -q "${{ needs.set-inputs.outputs.run-one-system }}" .github/workflows/data-fundamental-systems.json; then
echo "fundamental_systems=$(jq -c ".include |= map(select(.systems == \"${{ needs.set-inputs.outputs.run-one-system }}\"))" .github/workflows/data-fundamental-systems.json)" >> $GITHUB_ENV
elif grep -q "${{ needs.set-inputs.outputs.run-one-system }}" .github/workflows/data-non-fundamental-systems.json; then
echo "non_fundamental_systems=$(jq -c ".include |= map(select(.systems == \"${{ needs.set-inputs.outputs.run-one-system }}\"))" .github/workflows/data-non-fundamental-systems.json)" >> $GITHUB_ENV
elif grep -q "${{ needs.set-inputs.outputs.run-one-system }}" .github/workflows/data-nested-systems.json; then
echo "nested_systems=$(jq -c ".include |= map(select(.systems == \"${{ needs.set-inputs.outputs.run-one-system }}\"))" .github/workflows/data-nested-systems.json)" >> $GITHUB_ENV
fi
- name: Read all systems
if: needs.set-inputs.outputs.run-one-system == ''
run: |
echo "fundamental_systems=$(jq -c . ./.github/workflows/data-fundamental-systems.json)" >> $GITHUB_ENV
echo "non_fundamental_systems=$(jq -c . ./.github/workflows/data-non-fundamental-systems.json)" >> $GITHUB_ENV
echo "nested_systems=$(jq -c . ./.github/workflows/data-nested-systems.json)" >> $GITHUB_ENV
- name: Read matrix file
id: read-systems
shell: bash
run: |
echo "fundamental-systems=$fundamental_systems" >> $GITHUB_OUTPUT
echo "non-fundamental-systems=$non_fundamental_systems" >> $GITHUB_OUTPUT
echo "nested-systems=$nested_systems" >> $GITHUB_OUTPUT
tag-features-fundamental:
uses: ./.github/workflows/spread-tests.yaml
needs: [set-inputs, read-systems]
name: "spread ${{ matrix.group }}"
if: needs.read-systems.outputs.fundamental-systems != ''
secrets: inherit
with:
runs-on: '${{ matrix.runs-on }}'
group: ${{ matrix.group }}
backend: ${{ matrix.backend }}
systems: ${{ matrix.systems }}
tasks: ${{ matrix.tasks }}
rules: ${{ matrix.rules }}
is-fundamental: true
use-snapd-snap-from-master: true
spread-env: "SPREAD_TAG_FEATURES=1"
upload-artifacts: true
skip-tests: ${{ needs.set-inputs.outputs.skip-tests }}
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.read-systems.outputs.fundamental-systems) }}
tag-features-non-fundamental:
uses: ./.github/workflows/spread-tests.yaml
needs: [set-inputs, read-systems]
if: needs.read-systems.outputs.non-fundamental-systems != ''
name: "spread ${{ matrix.group }}"
secrets: inherit
with:
runs-on: '${{ matrix.runs-on }}'
group: ${{ matrix.group }}
backend: ${{ matrix.backend }}
systems: ${{ matrix.systems }}
tasks: ${{ matrix.tasks }}
rules: ${{ matrix.rules }}
use-snapd-snap-from-master: true
spread-env: "SPREAD_TAG_FEATURES=1"
upload-artifacts: true
skip-tests: ${{ needs.set-inputs.outputs.skip-tests }}
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.read-systems.outputs.non-fundamental-systems) }}
tag-features-nested:
uses: ./.github/workflows/spread-tests.yaml
needs: [set-inputs, read-systems]
if: needs.read-systems.outputs.nested-systems != ''
name: "spread ${{ matrix.group }}"
secrets: inherit
with:
runs-on: '${{ matrix.runs-on }}'
group: ${{ matrix.group }}
backend: ${{ matrix.backend }}
systems: ${{ matrix.systems }}
tasks: ${{ matrix.tasks }}
rules: ${{ matrix.rules }}
use-snapd-snap-from-master: true
spread-env: "SPREAD_TAG_FEATURES=1"
upload-artifacts: true
skip-tests: ${{ needs.set-inputs.outputs.skip-tests }}
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.read-systems.outputs.nested-systems) }}
re-run:
permissions:
actions: write
needs: [set-inputs, tag-features-fundamental, tag-features-non-fundamental, tag-features-nested]
# If the spread tests ended in failure, rerun the workflow up to maximum-reruns times
if: failure() && fromJSON(github.run_attempt) <= fromJSON(needs.set-inputs.outputs.maximum-reruns)
runs-on: ubuntu-latest
steps:
- env:
GH_REPO: ${{ github.repository }}
GH_TOKEN: ${{ github.token }}
run: gh workflow run rerun.yaml -F run_id=${{ github.run_id }}
get-all-features:
runs-on: ubuntu-latest
if: always()
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Download snapd snap
uses: ./.github/actions/download-snapd-snap
with:
use-master-push: true
is-amd64: true
is-arm64: false
is-fips: false
- name: Get all snapd features
run: |
sudo snap install built-snap/snapd_*.snap.keep --dangerous
snap debug features > all-features.json
- name: Upload snapd feature data
uses: actions/upload-artifact@v5
with:
name: "all-features"
path: "all-features.json"
create-reports:
needs: [set-inputs, tag-features-fundamental, tag-features-non-fundamental, tag-features-nested, get-all-features]
runs-on: ["self-hosted", "spread-enabled"]
if: |
(always() && (needs.tag-features-fundamental.result == 'success' || needs.tag-features-fundamental.result == 'skipped')
&& (needs.tag-features-non-fundamental.result == 'success' || needs.tag-features-non-fundamental.result == 'skipped')
&& (needs.tag-features-nested.result == 'success' || needs.tag-features-nested.result == 'skipped'))
|| fromJSON(github.run_attempt) > fromJSON(needs.set-inputs.outputs.maximum-reruns)
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Get generated data
uses: actions/download-artifact@v6
with:
path: feature-tags-artifacts
pattern: spread-artifacts-*
merge-multiple: true
- name: Get all features
uses: actions/download-artifact@v6
with:
name: all-features
- name: Create feature tags
run: |
shopt -s nullglob
featdir="extracted-tags"
mkdir -p "$featdir"
composedir="composed-tags"
mkdir -p "$composedir"
IFS=',' read -ra features <<< "${{ needs.set-inputs.outputs.features }}"
for file in "feature-tags-artifacts"/*; do
mkdir working
tar -xzf "$file" -C working
if ! [ -d "working/spread-artifacts/feature-tags" ]; then
echo "Artifact $file has no artifact data"
rm -r working
continue
fi
for dir in "working/spread-artifacts/feature-tags"/*/; do
if [ -f "${dir}/journal.txt" ] && [ -f "${dir}/state.json" ]; then
./tests/utils/features/featextractor.py \
-f "${features[@]}" \
--journal "${dir}/journal.txt" \
--state "${dir}/state.json" \
--output "$featdir/$(basename ${dir})"
elif [ -f "${dir}/journal.txt" ] && [ ! -f "${dir}/state.json" ]; then
./tests/utils/features/featextractor.py \
-f "${features[@]}" \
--journal "${dir}/journal.txt" \
--output "$featdir/$(basename ${dir})"
elif [ ! -f "${dir}/journal.txt" ]; then
echo "No journal.txt present in $dir"
exit 1
fi
done
./tests/utils/features/featcomposer.py \
--dir "$featdir" \
--output "$composedir" \
--failed-tests "working/spread-artifacts/failed-tests.txt" \
--run-attempt "$(cat "working/spread-artifacts/run-attempt.txt")" \
--env-variables "$(cat "working/spread-artifacts/env-variables.txt")"
rm -r working
done
./tests/utils/features/featcomposer.py \
--dir "$composedir" \
--output "final-feature-tags" \
--replace-old-runs
for json in final-feature-tags/*; do
if grep -qE "-nested.*04-64" <<<"$json"; then
version=${json#*ubuntu-}
version=${version%%.*}
core_file=$(find final-feature-tags -name "*ubuntu-core-$version-64*" || true)
if [ -n "$core_file" ]; then
echo "merging $json into $core_file"
jq -s '.[0].tests += .[1].tests | .[0]' "$core_file" "$json" > temp.json && mv temp.json "$core_file"
rm "$json"
fi
fi
done
./tests/utils/features/feattranslator.py -f all-features.json -o final-feature-tags/all-features.json
tar -czf "final-feature-tags.tar.gz" "final-feature-tags"
- name: Upload results to mongo
env:
MONGO_USER: ${{ secrets.MONGO_USER }}
MONGO_PASSWORD: ${{ secrets.MONGO_PASS }}
MONGO_HOST: ${{ secrets.MONGO_HOST }}
MONGO_PORT: ${{ secrets.MONGO_PORT }}
run: ./tests/utils/features/mongo_upload.py --dir "final-feature-tags" --verbose
- name: Upload feature data
uses: actions/upload-artifact@v5
with:
name: "feature-tags"
path: "final-feature-tags.tar.gz"