forked from ethereum/consensus-specs
-
Notifications
You must be signed in to change notification settings - Fork 0
314 lines (285 loc) · 9.87 KB
/
Copy pathcomptests.yml
File metadata and controls
314 lines (285 loc) · 9.87 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
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
name: Compliance Tests
run-name: >-
${{
inputs.release
&& format('Compliance Tests for {0}', inputs.release)
|| 'Compliance Tests'
}}
permissions:
contents: read
on:
workflow_dispatch:
inputs:
repo:
description: Repository
type: string
ref:
description: Commit, branch, or tag
type: string
release:
description: Release (leave empty)
default: ""
type: string
altair:
description: Generate altair fork
default: true
type: boolean
bellatrix:
description: Generate bellatrix fork
default: true
type: boolean
capella:
description: Generate capella fork
default: true
type: boolean
deneb:
description: Generate deneb fork
default: true
type: boolean
electra:
description: Generate electra fork
default: true
type: boolean
fulu:
description: Generate fulu fork
default: true
type: boolean
gloas:
description: Generate gloas fork
default: true
type: boolean
tiny:
description: Generate tiny config
default: false
type: boolean
small:
description: Generate small config
default: true
type: boolean
standard:
description: Generate standard config
default: false
type: boolean
seed:
description: Seed (random if empty)
default: ""
type: string
schedule:
- cron: "0 0 * * *"
jobs:
config:
runs-on: ubuntu-latest
env:
COMPTEST_SLICING_CONFIG: '{"tiny":1,"small":4,"standard":4}'
outputs:
repo: ${{ steps.config.outputs.repo }}
ref: ${{ steps.config.outputs.ref }}
release: ${{ steps.config.outputs.release }}
configs: ${{ steps.config.outputs.configs }}
seed: ${{ steps.config.outputs.seed }}
matrix: ${{ steps.config.outputs.matrix }}
steps:
- name: Resolve configuration
id: config
run: |
# Repo
repo="${{ inputs.repo || github.repository }}"
echo "repo=$repo" >> "$GITHUB_OUTPUT"
# Ref
ref="${{ inputs.ref }}"
if [[ -n "$ref" ]]; then
echo "ref=$ref" >> "$GITHUB_OUTPUT"
fi
# Release tag
release="${{ inputs.release }}"
if [[ -n "$release" ]]; then
if [[ "$repo" != "${{ github.repository }}" ]]; then
echo "Release-tagged compliance runs must use ${{ github.repository }} as the repository." >&2
exit 1
fi
if [[ "$ref" != "$release" ]]; then
echo "Release-tagged compliance runs must use the release tag as the ref." >&2
exit 1
fi
echo "release=$release" >> "$GITHUB_OUTPUT"
fi
# Presets
presets='["minimal"]'
echo "presets=$presets" >> "$GITHUB_OUTPUT"
# Forks
if [[ "${{ github.event_name }}" == "schedule" ]]; then
forks='["fulu","gloas"]'
else
selected=()
[[ "${{ inputs.altair }}" == "true" ]] && selected+=("altair")
[[ "${{ inputs.bellatrix }}" == "true" ]] && selected+=("bellatrix")
[[ "${{ inputs.capella }}" == "true" ]] && selected+=("capella")
[[ "${{ inputs.deneb }}" == "true" ]] && selected+=("deneb")
[[ "${{ inputs.electra }}" == "true" ]] && selected+=("electra")
[[ "${{ inputs.fulu }}" == "true" ]] && selected+=("fulu")
[[ "${{ inputs.gloas }}" == "true" ]] && selected+=("gloas")
if [[ ${#selected[@]} -eq 0 ]]; then
echo "No forks selected." >&2
exit 1
fi
json=$(printf '"%s",' "${selected[@]}")
forks="[${json%,}]"
fi
echo "forks=$forks" >> "$GITHUB_OUTPUT"
# Configs
if [[ "${{ github.event_name }}" == "schedule" ]]; then
configs='["small"]'
else
selected=()
[[ "${{ inputs.tiny }}" == "true" ]] && selected+=("tiny")
[[ "${{ inputs.small }}" == "true" ]] && selected+=("small")
[[ "${{ inputs.standard }}" == "true" ]] && selected+=("standard")
if [[ ${#selected[@]} -eq 0 ]]; then
echo "No generator configs selected." >&2
exit 1
fi
json=$(printf '"%s",' "${selected[@]}")
configs="[${json%,}]"
fi
echo "configs=$configs" >> "$GITHUB_OUTPUT"
# Seed
seed_input="${{ inputs.seed }}"
if [[ -z "$seed_input" ]]; then
seed=$(shuf -i 1-2147483647 -n 1)
elif [[ "$seed_input" =~ ^[0-9]+$ ]]; then
seed="$seed_input"
else
echo "Invalid seed value: '$seed_input'. Must be empty or a number." >&2
exit 1
fi
echo "seed=$seed" >> "$GITHUB_OUTPUT"
# Matrix
matrix=$(
jq -cn \
--argjson presets "$presets" \
--argjson forks "$forks" \
--argjson configs "$configs" \
--argjson slices '${{ env.COMPTEST_SLICING_CONFIG }}' \
'
[
$presets[] as $preset
| $forks[] as $fork
| $configs[] as $config
| (($slices[$config] // 1) | tonumber) as $slice_count
| if $slice_count < 1 then
error("Invalid slice count for config \($config): \($slice_count)")
else
range(0; $slice_count) as $slice_index
| {
preset: $preset,
fork: $fork,
config: $config,
slice_index: $slice_index,
slice_count: $slice_count
}
end
]
'
)
echo "matrix=$matrix" >> "$GITHUB_OUTPUT"
# Summary
echo "Configuration:"
echo " repo: $repo"
echo " ref: ${ref:-<default>}"
echo " release: ${release:-<none>}"
echo " presets: $presets"
echo " forks: $forks"
echo " configs: $configs"
echo " seed: $seed"
echo " matrix: $matrix"
echo " slicing: ${{ env.COMPTEST_SLICING_CONFIG }}"
generate:
needs: config
name: generate (${{ matrix.fork }}, ${{ matrix.config }}, ${{ matrix.slice_index }})
runs-on: ubuntu-latest
permissions:
contents: read
strategy:
fail-fast: false
matrix:
include: ${{ fromJson(needs.config.outputs.matrix) }}
steps:
- name: Checkout repository
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
repository: ${{ needs.config.outputs.repo }}
ref: ${{ needs.config.outputs.ref }}
persist-credentials: false
- name: Setup python
uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6.3.0
with:
python-version-file: "pyproject.toml"
- name: Install uv
uses: astral-sh/setup-uv@d31148d669074a8d0a63714ba94f3201e7020bc3 # v8.3.0
with:
enable-cache: true
- name: Generate compliance tests
run: |
extra_args=()
if [[ "${{ matrix.slice_count }}" -gt 1 ]]; then
extra_args+=(
"group_slice_index=${{ matrix.slice_index }}"
"group_slice_count=${{ matrix.slice_count }}"
)
fi
make comptests \
fc_gen_config=${{ matrix.config }} \
preset=${{ matrix.preset }} \
fork=${{ matrix.fork }} \
comptests_dir=./compliance-spec-tests/${{ matrix.config }} \
seed=${{ needs.config.outputs.seed }} \
"${extra_args[@]}"
- name: Upload compliance tests
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: comptests-${{ matrix.config }}-${{ matrix.preset }}-${{ matrix.fork }}-${{ matrix.slice_index }}
path: compliance-spec-tests/${{ matrix.config }}
if-no-files-found: ignore
package:
needs: [config, generate]
runs-on: ubuntu-latest
permissions:
actions: write
contents: write
strategy:
matrix:
config: ${{ fromJson(needs.config.outputs.configs) }}
steps:
- name: Checkout repository
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- name: Package compliance tests
uses: ./.github/actions/package
with:
name: ${{ matrix.config }}
artifact-prefix: comptests
source-path: tests
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Name packaged archive
id: archive
run: |
archive="${{ matrix.config }}.tar.gz"
# Release archives are named comptests.tar.gz
release="${{ needs.config.outputs.release }}"
if [[ -n "$release" ]]; then
renamed="comptests.tar.gz"
mv "$archive" "$renamed"
archive="$renamed"
fi
echo "archive=$archive" >> "$GITHUB_OUTPUT"
- name: Upload ${{ steps.archive.outputs.archive }}
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: ${{ steps.archive.outputs.archive }}
path: ${{ steps.archive.outputs.archive }}
archive: false
- name: Upload to release
if: ${{ needs.config.outputs.release != '' }}
run: gh release upload "${{ needs.config.outputs.release }}" "${{ steps.archive.outputs.archive }}"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_REPO: ${{ github.repository }}