-
Notifications
You must be signed in to change notification settings - Fork 22
210 lines (198 loc) · 7.4 KB
/
daily-regression.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
name: Daily Regression
on:
schedule:
# Run this job everyday at 6:30 AM UTC+8
- cron: '30 22 * * *'
jobs:
gen-matrix:
name: "Generate test matrix"
runs-on: [self-hosted, linux, nixos, BIGRAM]
env:
RUNNERS: 70
outputs:
test-plan: ${{ 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 }}
- id: gen-matrix
name: "Generate test matrix"
run: |
echo -n matrix= >> "$GITHUB_OUTPUT"
nix develop -c t1-helper generateRegressionTestPlan --runnersAmount "$RUNNERS" >> "$GITHUB_OUTPUT"
run-testcases:
name: "Run testcases"
needs: [gen-matrix]
strategy:
fail-fast: false
matrix: ${{ fromJSON(needs.gen-matrix.outputs.test-plan) }}
runs-on: [self-hosted, linux, nixos]
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: "Run testcases"
run: |
nix develop -c t1-helper runTests --jobs "${{ matrix.jobs }}" \
--resultDir test-results-$(head -c 10 /dev/urandom | base32) \
--dontBail
- uses: actions/upload-artifact@v4
if: ${{ !cancelled() }}
with:
name: test-reports-${{ matrix.id }}
path: |
test-results-*/failed-tests.md
test-results-*/cycle-updates.md
gen-perf-matrix:
name: "Generate test matrix for perf cases"
runs-on: [self-hosted, linux, nixos, BIGRAM]
env:
RUNNERS: 70
outputs:
perf-plan: ${{ 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 }}
- id: gen-matrix
name: "Generate test matrix"
run: |
echo -n matrix= >> "$GITHUB_OUTPUT"
nix develop -c t1-helper generateCiMatrix --testPlanFile "perf.json" --runnersAmount "$RUNNERS" >> "$GITHUB_OUTPUT"
run-perfcases:
name: "Run perf cases"
needs: [gen-perf-matrix]
strategy:
fail-fast: false
matrix: ${{ fromJSON(needs.gen-perf-matrix.outputs.perf-plan) }}
runs-on: [self-hosted, linux, nixos]
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: "Run testcases"
run: |
nix develop -c t1-helper runTests --jobs "${{ matrix.jobs }}" \
--resultDir test-results-$(head -c 10 /dev/urandom | base32)
- uses: actions/upload-artifact@v4
if: ${{ !cancelled() }}
with:
name: perf-reports-${{ matrix.id }}
path: |
test-results-*/failed-tests.md
test-results-*/cycle-updates.md
test-results-*/*_cycle.json
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: master
- uses: actions/download-artifact@v4
with:
pattern: '*-reports-*'
merge-multiple: true
- run: |
echo -e "\n## Newly passed tests\n" >> "$GITHUB_STEP_SUMMARY"
shopt -s nullglob
cat test-results-*/cycle-updates.md >> "$GITHUB_STEP_SUMMARY"
- run: |
echo -e "\n## Still failing tests\n" >> "$GITHUB_STEP_SUMMARY"
shopt -s nullglob
cat test-results-*/failed-tests.md >> "$GITHUB_STEP_SUMMARY"
- name: "Commit cycle updates"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
nix develop -c t1-helper mergeCycleData --filePat perf.json
git config user.name github-actions
git config user.email [email protected]
changed_cases=$(git diff --name-only '.github/cases/**/perf.json')
if [ -n "$changed_cases" ]; then
echo "changed cases: $changed_cases"
currentDate=$(date +%F)
branch="cycle-update-$currentDate"
git checkout -b "$branch"
git add '.github/cases/**/perf.json'
git commit -m "[ci] update test case cycle data at $currentDate"
git push origin "$branch" --force-with-lease
nix run '.#gh' -- \
pr create --title "Update perf cycle" --body "Update test cycles."
else
echo "No cycle change detect"
fi
- uses: geekyeggo/delete-artifact@v4
with:
# test-reports has been used, it can be deleted
name: test-reports-*
bump-deps:
name: "Bump Chisel"
if: ${{ !cancelled() }}
runs-on: [self-hosted, linux, nixos]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
ref: master
- name: Bump Chisel
run: |
cd nix/t1
nix run '.#nvfetcher' -- -f '^chisel$'
- name: Bump circt
run: |
oldFirtool="$(nix build '.#circt' --no-link --print-out-paths)/bin/firtool"
nix flake update nixpkgs-for-circt
newFirtool="$(nix build '.#circt' --no-link --print-out-paths)/bin/firtool"
diff_bin="$(nix build '.#diffutils' --no-link --print-out-paths)/bin/diff"
if "$diff_bin" -u <($oldFirtool --version) <($newFirtool --version); then
# if unchanged
git restore flake.lock
fi
- name: Bump all mill deps
run: |
oldHash=$(nix derivation show .#t1.elaborator.millDeps | jq -r 'to_entries[0].value.env.outputHash')
nix build '.#t1.elaborator.millDeps' --rebuild > t1-milldeps-log.txt 2>&1 || true
newHash=$(cat t1-milldeps-log.txt \
| grep -P '^\s+got:\s+sha256-.*$' \
| cut -d':' -f2 \
| xargs)
if [ -z "$newHash" ] || [ "$newHash" = "$oldHash" ]; then
echo "Original build logs for debug: "
cat t1-milldeps-log.txt
echo "Hash unchanged, exit"
exit 0
fi
echo "Updating hash $oldHash to $newHash"
sed -i "s|$oldHash|$newHash|" nix/t1/t1.nix
- name: Commit changes
env:
GITHUB_TOKEN: ${{ secrets.T1_PR_PAT }}
run: |
git config user.name Avimitin
git config user.email [email protected]
currentDate=$(date +%F)
branch="dependencies-bumping-$currentDate"
git checkout -b "$branch"
git add 'nix/t1'
git add 'flake.lock'
fileUnchanged() {
git diff --quiet --exit-code "$@"
}
if ! git diff --quiet --cached --exit-code; then
updatedFiles=$(git diff --cached --name-only)
echo "File changed"
git commit -m "[deps] Bump T1 dependencies"
git push origin "$branch" --force-with-lease
nix run '.#gh' -- \
pr create --title "Bump T1 dependencies" --body "Updated: $updatedFiles"
fi