-
Notifications
You must be signed in to change notification settings - Fork 1.3k
234 lines (211 loc) · 7.37 KB
/
tests.yml
File metadata and controls
234 lines (211 loc) · 7.37 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
name: Tests
on:
workflow_dispatch:
inputs:
repo:
description: Repository
type: string
ref:
description: Commit, branch, or tag
type: string
general:
description: Generate general preset
default: true
type: boolean
minimal:
description: Generate minimal preset
default: true
type: boolean
mainnet:
description: Generate mainnet preset
default: false
type: boolean
phase0:
description: Generate phase0 tests
default: true
type: boolean
altair:
description: Generate altair tests
default: true
type: boolean
bellatrix:
description: Generate bellatrix tests
default: true
type: boolean
capella:
description: Generate capella tests
default: true
type: boolean
deneb:
description: Generate deneb tests
default: true
type: boolean
electra:
description: Generate electra tests
default: true
type: boolean
fulu:
description: Generate fulu tests
default: true
type: boolean
gloas:
description: Generate gloas tests
default: true
type: boolean
heze:
description: Generate heze tests
default: true
type: boolean
schedule:
- cron: "0 0 * * *"
jobs:
config:
runs-on: ubuntu-latest
outputs:
repo: ${{ steps.config.outputs.repo }}
ref: ${{ steps.config.outputs.ref }}
presets: ${{ steps.config.outputs.presets }}
forks: ${{ steps.config.outputs.forks }}
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
# Presets
if [[ "${{ github.event_name }}" == "schedule" ]]; then
presets='["general","minimal","mainnet"]'
else
selected=()
[[ "${{ inputs.general }}" == "true" ]] && selected+=("general")
[[ "${{ inputs.minimal }}" == "true" ]] && selected+=("minimal")
[[ "${{ inputs.mainnet }}" == "true" ]] && selected+=("mainnet")
if [[ ${#selected[@]} -eq 0 ]]; then
echo "No presets selected." >&2
exit 1
fi
json=$(printf '"%s",' "${selected[@]}")
presets="[${json%,}]"
fi
echo "presets=$presets" >> "$GITHUB_OUTPUT"
# Forks
if [[ "${{ github.event_name }}" == "schedule" ]]; then
forks='["phase0","altair","bellatrix","capella","deneb","electra","fulu","gloas","heze"]'
else
selected=()
[[ "${{ inputs.phase0 }}" == "true" ]] && selected+=("phase0")
[[ "${{ 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")
[[ "${{ inputs.heze }}" == "true" ]] && selected+=("heze")
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"
# Summary
echo "Configuration:"
echo " repo: $repo"
echo " ref: ${ref:-<default>}"
echo " presets: $presets"
echo " forks: $forks"
generate:
needs: config
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
preset: ${{ fromJson(needs.config.outputs.presets) }}
fork: ${{ fromJson(needs.config.outputs.forks) }}
steps:
- name: Checkout repository
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
with:
repository: ${{ needs.config.outputs.repo }}
ref: ${{ needs.config.outputs.ref }}
- name: Setup python
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version-file: "pyproject.toml"
- name: Install uv
uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8.2.0
with:
enable-cache: true
- name: Generate tests
run: make test component=pyspec preset=${{ matrix.preset }} fork=${{ matrix.fork }} reftests=true coverage=${{ matrix.preset != 'general' && 'true' || 'false' }}
- name: Upload reference tests
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: reftests-${{ matrix.preset }}-${{ matrix.fork }}
path: reftests/${{ matrix.preset }}
if-no-files-found: ignore
# Renamed because upload-artifact excludes hidden files.
- name: Stage coverage data
if: matrix.preset != 'general'
run: mv .coverage coverage-data
- name: Upload coverage data
if: matrix.preset != 'general'
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: coverage-data-${{ matrix.preset }}-${{ matrix.fork }}
path: coverage-data
coverage:
needs: [config, generate]
if: >-
contains(fromJson(needs.config.outputs.presets), 'minimal') ||
contains(fromJson(needs.config.outputs.presets), 'mainnet')
runs-on: ubuntu-latest
permissions:
actions: write
steps:
- name: Checkout repository
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
with:
repository: ${{ needs.config.outputs.repo }}
ref: ${{ needs.config.outputs.ref }}
- name: Combine coverages
uses: ./.github/actions/combine-coverages
with:
artifact-prefix: coverage-data
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Upload coverage report
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: coverage
path: coverage
package:
needs: [config, generate]
runs-on: ubuntu-latest
permissions:
actions: write
strategy:
matrix:
preset: ${{ fromJson(needs.config.outputs.presets) }}
steps:
- name: Checkout repository
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
- name: Package reference tests
uses: ./.github/actions/package
with:
name: ${{ matrix.preset }}
artifact-prefix: reftests
source-path: tests/${{ matrix.preset }}
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Upload ${{ matrix.preset }}.tar.gz
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
path: ${{ matrix.preset }}.tar.gz
archive: false