-
Notifications
You must be signed in to change notification settings - Fork 39
296 lines (247 loc) · 8.06 KB
/
ci.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
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
name: CI
on:
push:
# Empty configuration means use default (ie. test all branches)
branches-ignore:
# Everything would have passed bors before going into devel
- devel
# Bors temporary branches
- staging.tmp
- trying.tmp
- staging-squash-merge.tmp
# Github Merge Queue temporary branches
- gh-readonly-queue/**
pull_request:
# Only take PRs to devel
branches:
- devel
# Type of events to run CI on
types:
- opened
- synchronize
- reopened
- ready_for_review
merge_group:
# Test all additions to merge queue
# Run every script actions in bash
defaults:
run:
shell: bash
concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true
jobs:
pre_run:
name: Provide additional context for the workflow
runs-on: ubuntu-latest
outputs:
skip: ${{ steps.skip_result.outputs.result }}
target_matrix: ${{ steps.matrix.outputs.result }}
shared_builder: ${{ steps.matrix.outputs.shared }}
steps:
- id: skip_result
name: Whether to skip checks
run: |
if [[ $IS_DRAFT == true ]]; then
echo "Pull request is in draft state, skipping"
echo "result=true" >> $GITHUB_OUTPUT
else
echo "result=false" >> $GITHUB_OUTPUT
fi
env:
IS_DRAFT: ${{ github.event.pull_request.draft }}
- id: matrix
name: Obtain build target matrix
run: |
# This matrix will be shared by the jobs following it.
#
# The schema is:
# [
# {
# name: String, ## The name of the target being tested
# runner: String, ## The runner to use of this target
# batch-count?: Int, ## Number of parallel test batches
# }
# ]
cat << "EOF" > matrix.json
[
{
"name": "Linux",
"runner": "ubuntu-20.04"
},
{
"name": "macOS",
"runner": "macos-13"
},
{
"name": "macOS (M1)",
"runner": "macos-14"
},
{
"name": "Windows",
"runner": "windows-2022",
"batch-count": 3
}
]
EOF
# Use jq to compact the matrix into one line to be used as the result
echo "result=$(jq -c . matrix.json)" >> $GITHUB_OUTPUT
test:
needs: [pre_run]
if: needs.pre_run.outputs.skip != 'true'
strategy:
fail-fast: false
matrix:
target: ${{ fromJson(needs.pre_run.outputs.target_matrix) }}
name: Build and test (${{ matrix.target.name }})
uses: ./.github/workflows/build-and-test.yml
with:
runner: ${{ matrix.target.runner }}
batch-count: ${{ matrix.target.batch-count || 1 }}
source:
needs: [pre_run]
if: needs.pre_run.outputs.skip != 'true'
name: Build source archive
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
filter: tree:0
- name: Enable annotations
run: echo "::add-matcher::.github/nim-problem-matcher.json"
- name: Build compiler
run: ./koch.py boot -d:danger
- name: Generate csources
run: ./koch.py csource -d:danger
- id: archive
name: Build release source
run: |
./koch.py archive
archive=build/archive/$(jq -r .name build/archive/archive.json)
# Rename the archive manifest to avoid collision with manifest of
# other archives
mv build/archive/archive.json build/archive/source.json
echo "archive=$archive" >> $GITHUB_OUTPUT
echo "metadata=build/archive/source.json" >> $GITHUB_OUTPUT
- name: Publish source archive to artifacts
uses: actions/upload-artifact@v4
with:
name: source archive
path: |
${{ steps.archive.outputs.archive }}
${{ steps.archive.outputs.metadata }}
if-no-files-found: error
package-git:
needs: [pre_run]
strategy:
fail-fast: false
matrix:
target: ${{ fromJson(needs.pre_run.outputs.target_matrix) }}
name: Package from Git (${{ matrix.target.name }})
uses: ./.github/workflows/package.yml
with:
runner: ${{ matrix.target.runner }}
output-name-format: release binaries {0} {1}
package-source:
needs: [pre_run, source]
strategy:
fail-fast: false
matrix:
target: ${{ fromJson(needs.pre_run.outputs.target_matrix) }}
name: Package from archive (${{ matrix.target.name }})
uses: ./.github/workflows/package.yml
with:
runner: ${{ matrix.target.runner }}
source-archive: source archive
output-name-format: binaries from source archive {0} {1}
test-package:
needs: [pre_run, package-git, package-source]
name: Test release artifacts
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
filter: tree:0
- name: Download binaries built from source archive
uses: actions/download-artifact@v4
with:
pattern: binaries from source archive*
path: binary-from-source
merge-multiple: true
- name: Download release package
uses: actions/download-artifact@v4
with:
# Download all release binaries to the same folder
pattern: release binaries*
path: release-binary
merge-multiple: true
- name: Download release source archive
uses: actions/download-artifact@v4
with:
name: source archive
path: source-archive
- name: Binaries from git and source archive should be the same
run: |
podman run \
--rm \
--workdir /src \
-v "$(pwd):/src" \
--user 0:0 \
registry.salsa.debian.org/reproducible-builds/diffoscope:latest \
--progress \
--html=build/diffoscope.html \
--exclude-directory-metadata=yes \
release-binary/ \
binary-from-source/
- name: Upload diffoscope output on failure
id: diffoscope-output
if: failure()
uses: actions/upload-artifact@v4
with:
name: differences between git and source binaries
path: build/diffoscope.html
- name: Write summary on failure
if: failure() && steps.diffoscope-output.outputs.artifact-url != ''
run: |
cat <<EOF >> "$GITHUB_STEP_SUMMARY"
### Binaries from git and source archive are not the same!
The report can be downloaded [here]($DIFFOSCOPE_OUTPUT_URL)
EOF
env:
DIFFOSCOPE_OUTPUT_URL: ${{ steps.diffoscope-output.outputs.artifact-url }}
- name: Enable annotations
run: echo "::add-matcher::.github/nim-problem-matcher.json"
- name: Build compiler
run: ./koch.py boot -d:danger
- name: Verify archive manifests
run: |
# Verify them by using the manifest builder tool to create a manifest
# for the full bundle.
bin/nim c tools/release_manifest.nim
cd release-binary
../tools/release_manifest add ../source-archive/*.json *.json
# Print the resulting manifest
echo "Success! Generated manifest:"
jq . manifest.json
# This allow the publisher to run the tool directly without having to
# clone the compiler.
- name: Upload release manifest tool
uses: actions/upload-artifact@v4
with:
name: release manifest tool
path: tools/release_manifest
passed:
name: All check passed
needs:
- test
- test-package
if: cancelled() || failure()
runs-on: ubuntu-latest
steps:
- name: Raise failure
if: contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled')
run: |
echo "::error::There are failing required jobs"
exit 1