Skip to content

Commit a60f158

Browse files
committed
Build binaries for multiple targets
1 parent bd3f5a4 commit a60f158

File tree

5 files changed

+288
-15
lines changed

5 files changed

+288
-15
lines changed
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
name: Continue Timeout Job
2+
3+
on:
4+
workflow_run:
5+
workflows:
6+
- "Windows Precommit Tests"
7+
- "CI Tests"
8+
types:
9+
- completed
10+
11+
permissions:
12+
contents: read
13+
14+
jobs:
15+
restart:
16+
name: "Restart Job"
17+
permissions:
18+
actions: write
19+
runs-on: ubuntu-22.04
20+
if: github.event.workflow_run.conclusion == 'failure'
21+
steps:
22+
- name: "Restart Job"
23+
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea #v7.0.1
24+
with:
25+
script: |
26+
const response = await github.rest.actions.listWorkflowRunArtifacts({
27+
owner: context.repo.owner,
28+
repo: context.repo.repo,
29+
run_id: context.payload.workflow_run.id
30+
})
31+
32+
job_ids = [];
33+
34+
for (artifact of response.data.artifacts) {
35+
console.log(artifact);
36+
const match = artifact.name.match(/timeout-([0-9]+)/);
37+
console.log(match);
38+
if (!match) {
39+
continue;
40+
}
41+
job_ids.push(match[1]);
42+
43+
// Delete the timeout artifact to prepare for the next run
44+
await github.rest.actions.deleteArtifact({
45+
owner: context.repo.owner,
46+
repo: context.repo.repo,
47+
artifact_id: artifact.id
48+
});
49+
}
50+
51+
if (job_ids.length == 0) {
52+
return;
53+
}
54+
55+
if (job_ids.length > 1) {
56+
// We aren't able to re-start multiple jobs individually, so our
57+
// only option is to restart all failed jobs.
58+
await github.rest.actions.reRunWorkflowFailedJobs({
59+
owner: context.repo.owner,
60+
repo: context.repo.repo,
61+
run_id: context.payload.workflow_run.id
62+
})
63+
console.log("Restarted workflow: " + context.payload.workflow_run.id);
64+
return;
65+
}
66+
67+
job_id = job_ids[0];
68+
// This function does not exist even though it is in the document
69+
//github.rest.actions.reRunJobForWorkflow({
70+
await github.request('POST /repos/{owner}/{repo}/actions/jobs/{job_id}/rerun', {
71+
owner: context.repo.owner,
72+
repo: context.repo.repo,
73+
job_id: job_id
74+
})
75+
console.log("Restarted job: " + job_id);
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Get Job ID
2+
inputs:
3+
job-name:
4+
required: false
5+
type: 'string'
6+
7+
outputs:
8+
job-id:
9+
description: "A space delimited list of check-targets to pass to ninja."
10+
value: ${{ steps.job-id.outputs.result }}
11+
12+
runs:
13+
using: "composite"
14+
steps:
15+
- uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea #v7.0.1
16+
id: job-id
17+
with:
18+
script: |
19+
const job_data = await github.rest.actions.listJobsForWorkflowRun({
20+
owner: context.repo.owner,
21+
repo: context.repo.repo,
22+
run_id: context.runId,
23+
});
24+
25+
for (job of job_data.data.jobs) {
26+
console.log(job)
27+
if (job.name == "${{ inputs.job-name }}") {
28+
return job.id
29+
}
30+
}

.github/workflows/release-binaries.yml

Lines changed: 56 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,16 @@ jobs:
8585
build-stage1-linux:
8686
name: "Build Stage 1 Linux"
8787
needs: prepare
88-
runs-on: ubuntu-22.04
88+
runs-on: ${{ matrix.runs-on }}
8989
if: github.repository == 'llvm/llvm-project'
90+
strategy:
91+
fail-fast: false
92+
matrix:
93+
runs-on:
94+
- ubuntu-22.04
95+
- windows-2022
96+
- macos-13
97+
- macos-14
9098
steps:
9199
- name: Checkout LLVM
92100
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
@@ -100,7 +108,7 @@ jobs:
100108
uses: hendrikmuhs/ccache-action@ca3acd2731eef11f1572ccb126356c2f9298d35e # v1.2.9
101109
with:
102110
max-size: 250M
103-
key: sccache-${{ runner.os }}-release
111+
key: sccache-${{ runner.os }}-${{ runner.arch }}-release
104112
variant: sccache
105113

106114
- name: Build Stage 1 Clang
@@ -119,14 +127,14 @@ jobs:
119127
- name: Upload Stage 1 Source
120128
uses: actions/upload-artifact@26f96dfa697d77e81fd5907df203aa23a56210a8 #v4.3.0
121129
with:
122-
name: stage1-source
130+
name: ${{ runner.os }}-${{ runner.arch }}-stage1-source
123131
path: llvm-project.tar.zst
124132
retention-days: 2
125133

126134
- name: Upload Stage 1 Build Dir
127135
uses: actions/upload-artifact@26f96dfa697d77e81fd5907df203aa23a56210a8 #v4.3.0
128136
with:
129-
name: stage1-build
137+
name: ${{ runner.os}}-${{ runner.arch }}-stage1-build
130138
path: build.tar.zst
131139
retention-days: 2
132140

@@ -135,16 +143,24 @@ jobs:
135143
needs:
136144
- prepare
137145
- build-stage1-linux
138-
runs-on: ubuntu-22.04
146+
runs-on: ${{ matrix.runs-on }}
139147
if: github.repository == 'llvm/llvm-project'
148+
strategy:
149+
fail-fast: false
150+
matrix:
151+
runs-on:
152+
- ubuntu-22.04
153+
- windows-2022
154+
- macos-13
155+
- macos-14
140156
steps:
141157
- name: Install Ninja
142158
uses: llvm/actions/install-ninja@22e9f909d35b50bd1181709564bfe816eaeaae81 # main
143159

144160
- name: Download Stage 1 Artifacts
145161
uses: actions/download-artifact@6b208ae046db98c579e8a3aa621ab581ff575935 # v4.1.1
146162
with:
147-
pattern: stage1-*
163+
pattern: ${{ runner.os }}-${{ runner.arch }}-stage1-*
148164
merge-multiple: true
149165

150166
- name: Unpack Artifacts
@@ -156,6 +172,7 @@ jobs:
156172
rm build.tar.zst
157173
158174
- name: Build Stage 2
175+
if: false
159176
run: |
160177
ninja -C /mnt/build stage2-instrumented
161178
@@ -169,14 +186,14 @@ jobs:
169186
- name: Upload Stage 2 Source
170187
uses: actions/upload-artifact@26f96dfa697d77e81fd5907df203aa23a56210a8 #v4.3.0
171188
with:
172-
name: stage2-source
189+
name: ${{ runner.os }}-${{ runner.arch }}-stage2-source
173190
path: ${{ github.workspace }}/llvm-project.tar.zst
174191
retention-days: 2
175192

176193
- name: Upload Stage 2 Build Dir
177194
uses: actions/upload-artifact@26f96dfa697d77e81fd5907df203aa23a56210a8 #v4.3.0
178195
with:
179-
name: stage2-build
196+
name: ${{ runner.os }}-${{ runner.arch }}-stage2-build
180197
path: ${{ github.workspace }}/build.tar.zst
181198
retention-days: 2
182199

@@ -197,7 +214,7 @@ jobs:
197214
- name: 'Download artifact'
198215
uses: actions/download-artifact@6b208ae046db98c579e8a3aa621ab581ff575935 # v4.1.1
199216
with:
200-
pattern: stage2-*
217+
pattern: ${{ runner.os }}-${{ runner.arch }}-stage2-*
201218
merge-multiple: true
202219

203220
- name: Unpack Artifact
@@ -208,10 +225,26 @@ jobs:
208225
tar --zstd -C /mnt -xf build.tar.zst
209226
rm build.tar.zst
210227
228+
- name: Timeout Restore
229+
id: timeout
230+
uses: ./.github/workflows/timeout-restore
231+
with:
232+
artifact-name-suffix: ${{ runner.os }}-${{ runner.arch }}
233+
211234
- name: Build Release Package
235+
name: Build
212236
run: |
213237
ninja -C /mnt/build stage2-package
214238
239+
- name: Timeout Save
240+
if: always()
241+
uses: ./.github/workflows/timeout-save
242+
with:
243+
job-name: "Build (${{ matrix.runs-on}})"
244+
artifact-name-suffix: ${{ matrix.name }}
245+
timeout-step: "Build"
246+
timeout-minutes: 330
247+
215248
- id: package-info
216249
run: |
217250
filename="LLVM-${{ needs.prepare.outputs.release-version }}-Linux.tar.gz"
@@ -221,7 +254,7 @@ jobs:
221254
- uses: actions/upload-artifact@26f96dfa697d77e81fd5907df203aa23a56210a8 #v4.3.0
222255
if: always()
223256
with:
224-
name: release-binary
257+
name: ${{ runner.os }}-${{ runner.arch }}-release-binary
225258
path: ${{ steps.package-info.outputs.path }}
226259

227260
# Clean up some build files to reduce size of artifact.
@@ -239,14 +272,14 @@ jobs:
239272
- name: Upload Stage 3 Source
240273
uses: actions/upload-artifact@26f96dfa697d77e81fd5907df203aa23a56210a8 #v4.3.0
241274
with:
242-
name: stage3-source
275+
name: ${{ runner.os }}-${{ runner.arch }}-stage3-source
243276
path: llvm-project.tar.zst
244277
retention-days: 2
245278

246279
- name: Upload Stage 3 Build Dir
247280
uses: actions/upload-artifact@26f96dfa697d77e81fd5907df203aa23a56210a8 #v4.3.0
248281
with:
249-
name: stage3-build
282+
name: ${{ runner.os }}-${{ runner.arch }}-stage3-build
250283
path: build.tar.zst
251284
retention-days: 2
252285

@@ -264,7 +297,7 @@ jobs:
264297
- name: 'Download artifact'
265298
uses: actions/download-artifact@6b208ae046db98c579e8a3aa621ab581ff575935 # v4.1.1
266299
with:
267-
name: release-binary
300+
pattern: *-release-binary
268301

269302
- name: Upload Release
270303
run: |
@@ -273,7 +306,7 @@ jobs:
273306
--token ${{ github.token }} \
274307
--release ${{ needs.prepare.outputs.release-version }} \
275308
upload \
276-
--files ${{ needs.build-stage3-linux.outputs.release-filename }}
309+
--files *.tar.gz #${{ needs.build-stage3-linux.outputs.release-filename }}
277310
278311
279312
test-stage3-linux:
@@ -283,14 +316,22 @@ jobs:
283316
- build-stage3-linux
284317
runs-on: ubuntu-22.04
285318
if: github.repository == 'llvm/llvm-project'
319+
strategy:
320+
fail-fast: false
321+
matrix:
322+
runs-on:
323+
- ubuntu-22.04
324+
- windows-2022
325+
- macos-13
326+
- macos-14
286327
steps:
287328
- name: Install Ninja
288329
uses: llvm/actions/install-ninja@22e9f909d35b50bd1181709564bfe816eaeaae81 # main
289330

290331
- name: 'Download artifact'
291332
uses: actions/download-artifact@6b208ae046db98c579e8a3aa621ab581ff575935 # v4.1.1
292333
with:
293-
pattern: stage3-*
334+
pattern: ${{ runner.os }}-${{ runner.arch }}-stage3-*
294335
merge-multiple: true
295336

296337
- name: Unpack Artifact
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Timeout Restore
2+
description: Save build state from a timed out job.
3+
inputs:
4+
artifact-name-suffix:
5+
desciption: Suffix to add to the name of the artifact containing the build state.
6+
required: true
7+
8+
outputs:
9+
exists:
10+
description: "This is true if a previous timeout build was restored, false otherwise."
11+
value: ${{ steps.timeout-artifact.exists }}
12+
13+
runs:
14+
using: "composite"
15+
steps:
16+
- name: Download Artifact
17+
uses: actions/download-artifact@6b208ae046db98c579e8a3aa621ab581ff575935 # v4.1.1
18+
with:
19+
pattern: timeout-build-${{ inputs.artifact-name-suffix }}
20+
merge-multiple: true
21+
22+
- name: Unpack Artifact
23+
id: timeout-artifact
24+
shell: bash
25+
run: |
26+
if [ -e llvm-project.tar.zst ]; then
27+
tar --zstd -xf llvm-project.tar.zst
28+
rm llvm-project.tar.zst
29+
echo "exists=true" >> $GITHUB_OUTPUT
30+
else
31+
echo "exists=false" >> $GITHUB_OUTPUT
32+
fi
33+

0 commit comments

Comments
 (0)