forked from sonos/tract
-
Notifications
You must be signed in to change notification settings - Fork 0
267 lines (241 loc) · 9.05 KB
/
Copy pathexamples.yml
File metadata and controls
267 lines (241 loc) · 9.05 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
name: Examples
on:
schedule:
- cron: '0 3 * * *'
workflow_dispatch:
inputs:
pr_number:
description: "Optional PR number to test (from fork ok). Leave empty to run on selected branch."
required: false
type: number
env:
CARGO_INCREMENTAL: false
CARGO_NET_RETRY: 10
CARGO_HTTP_MULTIPLEXING: false
CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse
FORCE_JAVASCRIPT_ACTIONS_TO_NODE20: true
permissions:
contents: read
jobs:
prepare:
runs-on: ubuntu-latest
permissions:
contents: read
statuses: write
outputs:
test_ref: ${{ steps.set.outputs.test_ref }}
pr_number: ${{ steps.set.outputs.pr_number }}
steps:
- id: set
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
env:
STATUS_CONTEXT: "CI / examples"
RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
with:
script: |
const prInput = context.payload.inputs?.pr_number;
core.setOutput('pr_number', prInput ? String(prInput) : '');
if (!prInput) {
core.setOutput('test_ref', process.env.GITHUB_SHA);
return;
}
const pr = await github.rest.pulls.get({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: Number(prInput),
});
const sha = pr.data.head.sha;
core.setOutput('test_ref', sha);
await github.rest.repos.createCommitStatus({
owner: context.repo.owner,
repo: context.repo.repo,
sha,
state: 'pending',
context: process.env.STATUS_CONTEXT,
target_url: process.env.RUN_URL,
description: 'Running',
});
examples:
runs-on: ubuntu-latest
needs: prepare
outputs:
examples: ${{steps.set-matrix.outputs.examples}}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: ${{ needs.prepare.outputs.test_ref }}
persist-credentials: false
- id: set-matrix
run: |
echo examples=`find examples -name ci.sh | cut -d/ -f 2 | jq -Rsc '. / "\n" - [""]'` >> "$GITHUB_OUTPUT"
example:
name: ${{ matrix.ex }}
runs-on: ubuntu-latest
needs: [ prepare, examples ]
permissions:
id-token: write
contents: read
strategy:
fail-fast: false
matrix:
ex: ${{fromJSON(needs.examples.outputs.examples)}}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: ${{ needs.prepare.outputs.test_ref }}
persist-credentials: false
- uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 # v2.9.2
with:
save-if: false # restore-only: schedule/dispatch job, never save (would evict the per-PR caches under the 10 GB cap)
- name: CPU features
run: .travis/cpu-features.sh
- name: example tests
env:
MATRIX_EX: ${{matrix.ex}}
timeout-minutes: 30
run: |
cd examples/${MATRIX_EX}
./ci.sh
build-tract-cli:
runs-on: ubuntu-latest
needs: prepare
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: ${{ needs.prepare.outputs.test_ref }}
persist-credentials: false
- uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 # v2.9.2
with:
save-if: false # restore-only: schedule/dispatch job, never save (would evict the per-PR caches under the 10 GB cap)
- run: cargo build -p tract-cli --profile opt-no-lto
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: tract-cli-x86_64
path: ./target/opt-no-lto/tract
build-tract-cli-macos:
runs-on: macOS
needs: prepare
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: ${{ needs.prepare.outputs.test_ref }}
persist-credentials: false
- run: cargo build -p tract-cli --profile opt-no-lto
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: tract-cli-aarch64-apple
path: ./target/opt-no-lto/tract
gpu-examples:
runs-on: ubuntu-latest
needs: prepare
outputs:
examples: ${{steps.set-matrix.outputs.examples}}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: ${{ needs.prepare.outputs.test_ref }}
persist-credentials: false
- id: set-matrix
run: |
echo examples=`find examples -name ci-gpu.sh | cut -d/ -f 2 | jq -Rsc '. / "\n" - [""]'` >> "$GITHUB_OUTPUT"
gpu-example:
name: ${{ matrix.ex }} (CUDA)
runs-on: cuda-lovelace
needs: [prepare, gpu-examples, build-tract-cli]
strategy:
fail-fast: false
matrix:
ex: ${{fromJSON(needs.gpu-examples.outputs.examples)}}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: ${{ needs.prepare.outputs.test_ref }}
persist-credentials: false
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: tract-cli-x86_64
path: target/opt-no-lto
- run: chmod +x target/opt-no-lto/tract
- name: GPU example tests
timeout-minutes: 60
env:
EX: ${{ matrix.ex }}
run: |
cd "examples/$EX"
./ci-gpu.sh
gpu-example-metal:
name: ${{ matrix.ex }} (Metal)
runs-on: macOS
needs: [prepare, gpu-examples, build-tract-cli-macos]
strategy:
fail-fast: false
matrix:
ex: ${{fromJSON(needs.gpu-examples.outputs.examples)}}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: ${{ needs.prepare.outputs.test_ref }}
persist-credentials: false
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: tract-cli-aarch64-apple
path: target/opt-no-lto
- run: chmod +x target/opt-no-lto/tract
- name: Metal GPU example tests
timeout-minutes: 60
run: |
cd examples/${MATRIX_EX}
./ci-gpu.sh
env:
MATRIX_EX: ${{matrix.ex}}
report:
name: Report result to PR
needs: [ prepare, examples, example, build-tract-cli, build-tract-cli-macos, gpu-examples, gpu-example, gpu-example-metal ]
if: ${{ always() && needs.prepare.outputs.pr_number != '' }}
runs-on: ubuntu-latest
permissions:
contents: read
statuses: write
pull-requests: write
steps:
- uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
env:
NEEDS: ${{ toJSON(needs) }}
PR_NUMBER: ${{ needs.prepare.outputs.pr_number }}
HEAD_SHA: ${{ needs.prepare.outputs.test_ref }}
RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
STATUS_CONTEXT: "CI / examples"
with:
script: |
const needs = JSON.parse(process.env.NEEDS);
const prNumber = Number(process.env.PR_NUMBER);
const sha = process.env.HEAD_SHA;
const runUrl = process.env.RUN_URL;
const statusContext = process.env.STATUS_CONTEXT;
const icon = r => r === 'success' ? '✅' : r === 'skipped' ? '⏭️' : '❌';
const jobs = Object.entries(needs).filter(([k]) => k !== 'prepare');
const failed = jobs.filter(([, v]) => v.result !== 'success' && v.result !== 'skipped');
const state = failed.length ? 'failure' : 'success';
await github.rest.repos.createCommitStatus({
owner: context.repo.owner, repo: context.repo.repo, sha, state,
context: statusContext, target_url: runUrl,
description: failed.length ? `${failed.length} job(s) failed` : 'All jobs passed',
});
const marker = `<!-- ${statusContext} -->`;
const body = [
marker,
`### ${icon(state)} ${statusContext}: ${state}`,
'',
...jobs.map(([k, v]) => `- ${icon(v.result)} \`${k}\`: ${v.result}`),
'',
`[View workflow run](${runUrl})`,
].join('\n');
const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner, repo: context.repo.repo, issue_number: prNumber, per_page: 100,
});
const prev = comments.find(c => c.body?.includes(marker));
if (prev) {
await github.rest.issues.updateComment({ owner: context.repo.owner, repo: context.repo.repo, comment_id: prev.id, body });
} else {
await github.rest.issues.createComment({ owner: context.repo.owner, repo: context.repo.repo, issue_number: prNumber, body });
}