-
Notifications
You must be signed in to change notification settings - Fork 22
199 lines (188 loc) · 6.92 KB
/
subsystem.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
name: subsystem
on: [pull_request]
env:
USER: runner
JAVA_OPTS: "-Duser.home=/run/github-runner/sequencer"
# Cancel the current workflow when new commit pushed
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
cancel-in-progress: true
jobs:
build-emulators:
name: "Build Emulators"
runs-on: [self-hosted, linux, nixos, AMD Ryzen 9 7940HS w/ Radeon 780M Graphics]
strategy:
matrix:
config:
- squirtle
- blastoise
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: "Build verilator emulator"
run: |
nix build '.#t1.${{ matrix.config }}.subsystem.emu' -L --no-link --cores 64
gen-matrix:
name: "Prepare for running testcases"
needs: [build-emulators]
runs-on: [self-hosted, linux, nixos, "AMD Ryzen 9 7940HS w/ Radeon 780M Graphics"]
env:
RUNNERS: 70
outputs:
ci-tests: ${{ steps.gen-matrix.outputs.matrix }}
steps:
# actions/checkout will use the "event" commit to checkout repository,
# which will lead to an unexpected issue that the "event" commit doesn't belongs to the repository,
# and causing the derivation build output cannot be cache correctly.
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: "Build all testcases"
run: |
# Build testcases with vlen 1024 and vlen 4096
nix build ".#t1.bulbasaur.cases.all" --max-jobs auto -L --no-link --cores 64
nix build ".#t1.psyduck.cases.all" --max-jobs auto -L --no-link --cores 64
- id: gen-matrix
name: "Generate test matrix"
run: |
echo -n matrix= >> "$GITHUB_OUTPUT"
nix shell ".#ammonite" -c .github/scripts/ci.sc generateCiMatrix subsystem.json "$RUNNERS" >> "$GITHUB_OUTPUT"
build-trace-emulators:
name: "Build trace emulator"
needs: [gen-matrix]
runs-on: [self-hosted, linux, nixos, AMD Ryzen 9 7940HS w/ Radeon 780M Graphics]
strategy:
fail-fast: false
matrix:
config:
- squirtle
- blastoise
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: "Build verilator emulator with trace"
run: nix build '.#t1.${{ matrix.config }}.subsystem.emu-trace' -L --no-link --cores 64
test-emit:
name: "Test elaborate"
runs-on: [self-hosted, linux, nixos]
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: "Test elaborate"
run: |
set -e
nix build '.#t1.configgen' -L --out-link ./config-gen
for cfg in $(jq -r '.[]' ./config-gen/share/all-supported-configs.json); do
echo "Building .#t1.${cfg}.subsystem.rtl"
nix build ".#t1.${cfg}.subsystem.rtl" -L
done
run-testcases:
name: "Run testcases"
needs: [gen-matrix]
strategy:
fail-fast: false
matrix: ${{ fromJSON(needs.gen-matrix.outputs.ci-tests) }}
runs-on: [self-hosted, linux, nixos]
outputs:
result: ${{ steps.ci-run.outputs.result }}
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: "Run testcases"
id: ci-run
run: |
nix shell ".#ammonite" -c .github/scripts/ci.sc runTests \
--runTarget subsystem \
--jobs "${{ matrix.jobs }}" \
--resultDir test-results-$(head -c 10 /dev/urandom | base32)
- uses: actions/upload-artifact@v4
if: ${{ !cancelled() }}
with:
name: test-reports-${{ matrix.id }}
path: |
test-results-*/failed-tests.md
- uses: actions/upload-artifact@v4
if: failure()
with:
name: failed-logs-${{ matrix.id }}
path: test-results-*/failed-logs
gen-fail-wave-matrix:
name: "Generate matrix for re-testing failing tests"
if: ${{ !cancelled() }}
needs: [run-testcases]
runs-on: [self-hosted, linux, nixos]
outputs:
generate_wave: ${{ steps.generate-matrix.outputs.generate_wave }}
retry_tasks: ${{ steps.generate-matrix.outputs.retry_tasks }}
steps:
- uses: actions/download-artifact@v4
with:
pattern: test-reports-*
merge-multiple: true
- id: generate-matrix
name: "Generate matrix"
run: |
touch all-fail-tests.txt
shopt -s nullglob
cat test-results-*/failed-tests.md > all-failed-tests.txt
retry=$(sed 's/\* //' all-failed-tests.txt | shuf -n3) # only retry last three failed
echo "build wave for: $retry"
if [ -n "$retry" ]; then
echo "generate_wave=true" >> "$GITHUB_OUTPUT"
echo -n "retry_tasks=" >> "$GITHUB_OUTPUT"
echo "$retry" | \
jq -nR --indent 0 '{"include": [inputs | {"job": ., "id": (input_line_number)}]}' >> "$GITHUB_OUTPUT"
fi
build-fail-wave:
name: "Generate wave for failing tests"
needs: [build-emulators, gen-fail-wave-matrix]
if: ${{ !cancelled() && needs.gen-fail-wave-matrix.outputs.generate_wave == 'true' }}
strategy:
fail-fast: false
matrix: ${{ fromJSON(needs.gen-fail-wave-matrix.outputs.retry_tasks) }}
runs-on: [self-hosted, linux, nixos]
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: "Run failed testcases"
run: |
nix shell ".#ammonite" -c .github/scripts/ci.sc runFailedTests --runTarget subsystem --jobs "${{ matrix.job }}"
waveFile=$(find testrun -name 'wave.fst')
hierFile=$(find testrun -name 'wave.hier')
if [[ -z "$waveFile" || -n "$hierFile" ]]; then # when emulator failed, .hier is not merged into .fst
echo "Verilator doesn't generate wave correctly"
exit 1
fi
mv "$waveFile" ./wave-${{ matrix.job }}.fst
- uses: actions/upload-artifact@v4
with:
name: failed-tests-wave-${{ matrix.id }}
path: 'wave-*.fst'
- run: |
echo "Test ${{ matrix.job }} run fail"
# We are just running post action for failing test, so we need to avoid the workflow finishing successfully
exit 1
report:
name: "Report CI result"
if: ${{ !cancelled() }}
needs: [run-testcases]
runs-on: [self-hosted, linux, nixos]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.head_ref }}
- uses: actions/download-artifact@v4
with:
pattern: test-reports-*
merge-multiple: true
- name: "Print step summary"
run: |
echo -e "\n## Failed tests\n" >> $GITHUB_STEP_SUMMARY
shopt -s nullglob
cat test-results-*/failed-tests.md >> $GITHUB_STEP_SUMMARY