-
Notifications
You must be signed in to change notification settings - Fork 0
427 lines (421 loc) · 17.7 KB
/
Copy pathrust_test.yml
File metadata and controls
427 lines (421 loc) · 17.7 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
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
on:
workflow_call:
inputs:
required_packages:
type: string
default: ""
description: Package that needs to be installed before Rust compilation can happens
toolchain:
type: string
default: "1.75"
description: Rust toolchain to install. Do not set this to moving targets like "stable", instead leave it empty and regularly bump the default in this file.
nightly_toolchain:
type: string
default: "nightly-2023-08-02"
description: Rust toolchain to install. Do not set this to moving targets like "nightly", instead leave it empty and regularly bump the default in this file.
additional_args:
type: string
default: ""
description: Additional arguments to pass to the cargo command
additional_cache_path:
type: string
default: ""
description: Path of additional cache to get
additional_cache_key:
type: string
default: ""
description: Key of additional cache to get
additional_cache_miss:
type: string
default: ""
description: Script to run if additional cache miss
additional_script:
type: string
default: ""
description: Additional script to run before the additional packages
working_directory:
type: string
default: ""
description: Subdirectory to treat as repo root
custom_cargo_commands:
type: string
default: ""
description: Custom cargo commands that will be run after login
fail_fast:
type: string
default: "true"
description: Should all the test ran or fail early
skip_miri_test:
type: string
default: "false"
description: Should we skip miri test (useful when tests are incompatible)
test_publish_required:
type: string
default: "false"
description: "Should the publish dry-run test be marked as required"
test_doc_required:
type: string
default: "false"
description: "Should the doc test be required"
service_database:
type: string
default: "false"
description: "Should Postgres be deployed alongside for testing"
service_azurite:
type: string
default: "false"
description: "Should Azurite emulator be deployed alongside for testing"
env:
CARGO_TERM_COLOR: never
CARGO_NET_GIT_FETCH_WITH_CLI: true
CARGO_HTTP_USER_AGENT: "shipyard ${{ secrets.CARGO_PRIVATE_REGISTRY_TOKEN }}"
CARGO_PROFILE_TEST_DEBUG: false
LAUNCHER_APP_NAME: ""
LAUNCHER_APP_FALLBACK: ""
SQLX_OFFLINE: true
jobs:
derive_runner:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
sparse-checkout: "rust-toolchain.toml"
- name: Get rust channel
id: rust-channel
shell: bash
run: |
rust_version="$(yq -p toml '.toolchain.channel' < rust-toolchain.toml || echo '${{ inputs.toolchain }}')"
rust_version="${rust_version/./-}"
echo "rust_version=${rust_version}" >> $GITHUB_OUTPUT
sanitized_working_directory="${{ inputs.working_directory }}"
sanitized_working_directory="${sanitized_working_directory//\//_}"
echo "sanitized_working_directory=${sanitized_working_directory}" >> "$GITHUB_OUTPUT"
outputs:
rust-channel: ${{ steps.rust-channel.outputs.rust_version }}
sanitized_working_directory: ${{ steps.rust-channel.outputs.sanitized_working_directory }}
check:
name: Rust ${{ matrix.type }} ${{ inputs.working_directory }}
runs-on: "rust-${{ needs.derive_runner.outputs.rust-channel }}-scale-set"
needs: derive_runner
env:
CARGO_HTTP_USER_AGENT: "shipyard ${{ secrets.CARGO_PRIVATE_REGISTRY_TOKEN }}"
RUSTC_WRAPPER: "sccache"
strategy:
matrix:
type: [check, test, miri]
include:
- toolchain: ${{ inputs.toolchain }}
- type: miri
toolchain: ${{ inputs.nightly_toolchain }}
fail-fast: ${{ inputs.fail_fast == 'true' }}
services:
azurite:
# Hack for conditionally enabling the service:
# https://github.com/actions/runner/issues/822
image: ${{ (inputs.service_azurite == 'true') && 'mcr.microsoft.com/azure-storage/azurite' || '' }}
ports:
- 10000:10000 # BLOB
- 10001:10001 # Queue
- 10002:10002 # Table
options: --health-cmd "nc -z 127.0.0.1 10000"
credentials:
username: ${{ secrets.FSLABS_DOCKERHUB_USERNAME }}
password: ${{ secrets.FSLABS_DOCKERHUB_PASSWORD }}
postgres:
# Hack for conditionally enabling the service:
# https://github.com/actions/runner/issues/822
image: ${{ (inputs.service_database == 'true') && 'postgres' || '' }}
env:
POSTGRES_PASSWORD: postgres
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
credentials:
username: ${{ secrets.FSLABS_DOCKERHUB_USERNAME }}
password: ${{ secrets.FSLABS_DOCKERHUB_PASSWORD }}
ports:
- 5432:5432
steps:
- name: Set DATABASE_URL
if: inputs.service_database == 'true'
shell: bash
run: |
echo "DATABASE_URL=postgresql://postgres:postgres@localhost/postgres" >> "$GITHUB_ENV"
- name: Globally configure Git
shell: bash
run: |
git config --global core.excludesfile ~/.gitignore_global
git config --global core.compression 0
- name: "Ensure we don't track the new resources in git"
shell: bash
run: |
echo "output.txt" >> ~/.gitignore_global
echo "deny.toml" >> ~/.gitignore_global
- name: "Update rustup only if version is different thant toolchain"
shell: bash
run: |
rustup set auto-self-update disable
- name: Checkout
uses: actions/checkout@v4
- uses: ForesightMiningSoftwareCorporation/github/.github/actions/login-private-registry@v3.2.0
with:
private_key: ${{ secrets.CARGO_PRIVATE_REGISTRY_SSH_PRIVATE_KEY }}
host: ${{ secrets.CARGO_PRIVATE_REGISTRY_HOST }}
name: ${{ secrets.CARGO_PRIVATE_REGISTRY_NAME }}
token: ${{ secrets.CARGO_PRIVATE_REGISTRY_TOKEN }}
cos_username: ${{ secrets.CARGO_COS_PRIVATE_REGISTRY_USERNAME }}
cos_password: ${{ secrets.CARGO_COS_PRIVATE_REGISTRY_PASSWORD }}
cos_tenant: ${{ secrets.CARGO_COS_PRIVATE_REGISTRY_TENANT }}
cos_subscription: ${{ secrets.CARGO_COS_PRIVATE_REGISTRY_SUBSCRIPTION }}
additional_private_keys: |
${{ secrets.FSE_SSH_PRIVATE_KEY }}
${{ secrets.BEVY_CLIPMAP_SSH_PRIVATE_KEY }}
${{ secrets.DAG_TABLES_SSH_PRIVATE_KEY }}
${{ secrets.VOLUMESIGHT_SSH_PRIVATE_KEY }}
${{ secrets.SPARKL_BLAST_SSH_PRIVATE_KEY }}
- name: Additional Cache
id: additional-cache
uses: actions/cache@v4
if: inputs.additional_cache_key != '' && inputs.additional_cache_path != ''
with:
path: ${{ inputs.additional_cache_path }}
key: ${{ inputs.additional_cache_key }}-${{ github.ref_name }}
restore-keys: |
${{ inputs.additional_cache_key }}-${{ github.base_ref }}
${{ inputs.additional_cache_key }}
- name: Additional Cache Miss Command
if: steps.additional-cache.outputs.cache-hit != 'true'
shell: bash
run: ${{ inputs.additional_cache_miss }}
- name: Additional Script
if: ${{ inputs.additional_script != '' }}
shell: bash
working-directory: ${{ inputs.working_directory }}
run: ${{ inputs.additional_script }}
- name: Cache Dependencies
uses: Swatinem/rust-cache@v2
with:
shared-key: "${{ github.job }}-${{ matrix.type }}"
workspaces: ${{ inputs.working_directory }}
env-vars: ""
- name: Get crate name
id: name
if: always()
shell: bash
working-directory: ${{ inputs.working_directory }}
run: |
echo "value=$(yq -p toml '.package.name' < Cargo.toml)" >> $GITHUB_OUTPUT
- name: Set start time as env variable
id: start_time
run: echo "value=$(date +'%s')000" >> $GITHUB_OUTPUT
- name: custom
uses: ForesightMiningSoftwareCorporation/github/.github/actions/shell-with-output@v2
id: custom
if: inputs.custom_cargo_commands != ''
continue-on-error: true
with:
command: ${{ inputs.custom_cargo_commands }}
working_directory: ${{ inputs.working_directory }}
- name: fmt
id: fmt
uses: ForesightMiningSoftwareCorporation/github/.github/actions/shell-with-output@v2
continue-on-error: true
if: matrix.type == 'check' && (inputs.fail_fast == 'false' || inputs.custom_cargo_commands == '' || steps.custom.outcome == 'success' && !cancelled())
with:
command: "cargo fmt --verbose -- --check"
working_directory: ${{ inputs.working_directory }}
- name: check
id: check
uses: ForesightMiningSoftwareCorporation/github/.github/actions/shell-with-output@v2
continue-on-error: true
if: matrix.type == 'check' && (inputs.fail_fast == 'false' || steps.fmt.outcome == 'success' && !cancelled())
with:
command: "cargo check ${{ inputs.additional_args }}" # todo: feed back the `workspace
working_directory: ${{ inputs.working_directory }}
- name: clippy
id: clippy
uses: ForesightMiningSoftwareCorporation/github/.github/actions/shell-with-output@v2
continue-on-error: true
if: matrix.type == 'check' && (inputs.fail_fast == 'false' || steps.check.outcome == 'success' && !cancelled())
with:
command: "cargo clippy ${{ inputs.additional_args }} -- -D warnings"
working_directory: ${{ inputs.working_directory }}
- name: doc
id: doc
uses: ForesightMiningSoftwareCorporation/github/.github/actions/shell-with-output@v2
continue-on-error: true
if: matrix.type == 'check' && (inputs.fail_fast == 'false' || steps.clippy.outcome == 'success' && !cancelled())
with:
command: "RUSTDOCFLAGS='-D warnings' cargo doc --no-deps"
working_directory: ${{ inputs.working_directory }}
- name: Copy Default deny if not exists
shell: bash
working-directory: ${{ inputs.working_directory }}
if: matrix.type == 'check' && (inputs.fail_fast == 'false' || steps.clippy.outcome == 'success' && !cancelled())
run: |
if [ ! -f deny.toml ]; then
curl -o deny.toml https://raw.githubusercontent.com/ForesightMiningSoftwareCorporation/github/main/deny.toml
fi
- name: deny-license
uses: ForesightMiningSoftwareCorporation/github/.github/actions/shell-with-output@v2
id: deny-license
continue-on-error: true
if: matrix.type == 'check' && (inputs.fail_fast == 'false' || steps.clippy.outcome == 'success' && !cancelled())
with:
command: "cargo deny check licenses"
working_directory: ${{ inputs.working_directory }}
- name: deny-bans
uses: ForesightMiningSoftwareCorporation/github/.github/actions/shell-with-output@v2
id: deny-bans
continue-on-error: true
if: matrix.type == 'check' && (inputs.fail_fast == 'false' || steps.clippy.outcome == 'success' && !cancelled())
with:
command: "cargo deny check bans"
working_directory: ${{ inputs.working_directory }}
- name: deny-advisories
uses: ForesightMiningSoftwareCorporation/github/.github/actions/shell-with-output@v2
id: deny-advisories
continue-on-error: true
if: matrix.type == 'check' && (inputs.fail_fast == 'false' || steps.clippy.outcome == 'success' && !cancelled())
with:
command: "cargo deny check advisories"
working_directory: ${{ inputs.working_directory }}
- name: deny-sources
uses: ForesightMiningSoftwareCorporation/github/.github/actions/shell-with-output@v2
id: deny-sources
continue-on-error: true
if: matrix.type == 'check' && (inputs.fail_fast == 'false' || steps.clippy.outcome == 'success' && !cancelled())
with:
command: "cargo deny check sources"
working_directory: ${{ inputs.working_directory }}
- name: dependencies
uses: ForesightMiningSoftwareCorporation/github/.github/actions/shell-with-output@v2
id: dependencies
continue-on-error: true
if: matrix.type == 'check' && (inputs.fail_fast == 'false' || steps.clippy.outcome == 'success' && !cancelled())
with:
command: "cargo machete"
working_directory: ${{ inputs.working_directory }}
- name: publish-dryrun
uses: ForesightMiningSoftwareCorporation/github/.github/actions/shell-with-output@v2
id: publish-dryrun
continue-on-error: true
if: matrix.type == 'check' && (inputs.fail_fast == 'false' || steps.clippy.outcome == 'success' && !cancelled())
with:
command: "cargo package"
working_directory: ${{ inputs.working_directory }}
- name: tests
uses: ForesightMiningSoftwareCorporation/github/.github/actions/shell-with-output@v2
id: tests
if: matrix.type == 'test' && (inputs.fail_fast == 'false' || !cancelled())
with:
command: "cargo test ${{ inputs.fail_fast == 'false' && '--no-fail_fast' || '' }} ${{ inputs.additional_args }}"
working_directory: ${{ inputs.working_directory }}
- name: miri
uses: ForesightMiningSoftwareCorporation/github/.github/actions/shell-with-output@v2
id: miri
continue-on-error: true
if: matrix.type == 'miri' && inputs.skip_miri_test == 'false' && (inputs.fail_fast == 'false' || !cancelled())
with:
command: "cargo miri test ${{ inputs.fail_fast == 'false' && '--keep-going' || '' }} ${{ inputs.additional_args }}"
working_directory: ${{ inputs.working_directory }}
- name: Write output to file
shell: bash
if: always()
working-directory: ${{ runner.temp }}
run: |
tee -a ${{ steps.name.outputs.value }}-${{ matrix.type }}.json <<EOF
{
"name": "${{ steps.name.outputs.value }}",
"start_time": "${{ steps.start_time.outputs.value }}",
"end_time": "$(date +'%s')000",
"working_directory": "${{ inputs.working_directory }}",
"type": "${{ matrix.type }}",
"server_url": "${{ github.server_url }}",
"repository": "${{ github.repository }}",
"run_id": "${{ github.run_id }}",
"run_attempt": "${{ github.run_attempt }}",
"actor": "${{ github.actor }}",
"event_name": "${{ github.event_name }}",
"outputs": {
EOF
case "${{ matrix.type }}" in
"check")
tee -a ${{ steps.name.outputs.value }}-${{ matrix.type }}.json <<EOF
"custom": {
"outcome": "${{ steps.custom.outcome }}",
"required": false
},
"fmt": {
"outcome": "${{ steps.fmt.outcome }}",
"required": true
},
"check": {
"outcome": "${{ steps.check.outcome }}",
"required": true
},
"clippy": {
"outcome": "${{ steps.clippy.outcome }}",
"required": true
},
"doc": {
"outcome": "${{ steps.doc.outcome }}",
"required": ${{ inputs.test_doc_required }}
},
"dependencies": {
"outcome": "${{ steps.dependencies.outcome }}",
"required": false
},
"deny-advisories": {
"outcome": "${{ steps.deny-advisories.outcome }}",
"required": false
},
"deny-bans": {
"outcome": "${{ steps.deny-bans.outcome }}",
"required": false
},
"deny-license": {
"outcome": "${{ steps.deny-license.outcome }}",
"required": false
},
"deny-sources": {
"outcome": "${{ steps.deny-sources.outcome }}",
"required": false
},
"publish-dryrun": {
"outcome": "${{ steps.publish-dryrun.outcome }}",
"required": ${{ inputs.test_publish_required }}
}
}
EOF
;;
"miri")
tee -a ${{ steps.name.outputs.value }}-${{ matrix.type }}.json <<EOF
"miri": {
"outcome": "${{ steps.miri.outcome }}",
"required": false
}
}
EOF
;;
"test")
tee -a ${{ steps.name.outputs.value }}-${{ matrix.type }}.json <<EOF
"tests": {
"outcome": "${{ steps.tests.outcome }}",
"required": true
}
}
EOF
;;
*)
esac
tee -a ${{ steps.name.outputs.value }}-${{ matrix.type }}.json <<EOF
}
EOF
- uses: actions/upload-artifact@v4
if: always()
with:
name: fslabs__checks__${{ github.run_id }}__${{ github.run_attempt }}__${{ steps.name.outputs.value }}-${{ matrix.type }}
path: ${{ runner.temp }}/${{ steps.name.outputs.value }}-${{ matrix.type }}.json