Repository navigation
133 lines (130 loc) · 4.74 KB
/
Copy pathrust-tests.yml
File metadata and controls
133 lines (130 loc) · 4.74 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
name: Rust test partitions
on:
workflow_call:
inputs:
runner:
type: string
required: true
partitions:
type: string
default: '[1]'
artifact:
type: string
required: true
checks:
type: boolean
default: false
clippy:
type: boolean
default: true
nightly:
type: boolean
default: false
probe:
type: string
default: none
jobs:
run:
timeout-minutes: 60
if: ${{ inputs.probe != 'skipped' }}
runs-on: ${{ inputs.runner }}
strategy:
fail-fast: false
matrix:
partition: ${{ fromJSON(inputs.partitions) }}
steps:
- uses: actions/checkout@v7
# A dispatch-only probe fails the first partition alone, exercising this
# job and the real stable gates without a deliberately broken Rust test.
- name: Gate probe
if: ${{ inputs.probe != 'none' && matrix.partition == 1 }}
env:
PROBE: ${{ inputs.probe }}
run: |
printf 'Deliberate gate probe: %s\n' "$PROBE"
exit 1
- name: Install toolchain
if: ${{ inputs.probe == 'none' }}
run: |
rustup toolchain install
rustc --version
- uses: Swatinem/rust-cache@v2
if: ${{ inputs.probe == 'none' }}
id: cache
- name: Tooling checks
if: ${{ inputs.checks && inputs.probe == 'none' && matrix.partition == 1 }}
run: |
python3 -m unittest discover -s scripts -p 'test_*.py'
curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.33.0/cargo-dist-installer.sh | sh
python3 scripts/generate-release.py --check
cargo fmt --check
- name: Clippy
if: ${{ inputs.clippy && inputs.probe == 'none' && matrix.partition == 1 }}
run: cargo clippy --all-targets -- -D warnings
- uses: taiki-e/install-action@v2
if: ${{ !inputs.nightly && inputs.probe == 'none' }}
with:
tool: cargo-nextest@0.9.151
- name: Compile tests
if: ${{ inputs.probe == 'none' }}
run: cargo test --no-run
- name: Test inventory
if: ${{ !inputs.nightly && inputs.probe == 'none' }}
env:
PARTITION: ${{ matrix.partition }}/${{ strategy.job-total }}
REPORT: target/ci-report/${{ inputs.artifact }}-${{ matrix.partition }}
CACHE_HIT: ${{ steps.cache.outputs.cache-hit }}
run: |
python3 scripts/ci-timings.py inventory "$REPORT" --partition "$PARTITION"
git rev-parse HEAD > "$REPORT/revision.txt"
printf '%s\n' "$CACHE_HIT" > "$REPORT/cache-hit.txt"
- name: Nextest execution
if: ${{ !inputs.nightly && inputs.probe == 'none' }}
env:
PARTITION: ${{ matrix.partition }}/${{ strategy.job-total }}
run: cargo nextest run --profile ci --partition "hash:$PARTITION"
- name: Contributor cargo test execution
if: ${{ inputs.nightly && inputs.probe == 'none' }}
run: cargo test
- name: Summarize timings
if: ${{ always() && !inputs.nightly && inputs.probe == 'none' }}
env:
REPORT: target/ci-report/${{ inputs.artifact }}-${{ matrix.partition }}
run: |
if test -f target/nextest/ci/junit.xml; then
mkdir -p "$REPORT"
cp target/nextest/ci/junit.xml "$REPORT/junit.xml"
python3 scripts/ci-timings.py summary "$REPORT" >> "$GITHUB_STEP_SUMMARY"
fi
- uses: actions/upload-artifact@v4
if: ${{ always() && !inputs.nightly && inputs.probe == 'none' }}
with:
name: ${{ inputs.artifact }}-${{ matrix.partition }}
path: target/ci-report/${{ inputs.artifact }}-${{ matrix.partition }}/
retention-days: 14
if-no-files-found: error
overwrite: true
complete:
timeout-minutes: 5
runs-on: ubuntu-24.04
needs: run
if: ${{ always() }}
steps:
- name: Require every partition
env:
RESULT: ${{ needs.run.result }}
run: test "$RESULT" = success
- uses: actions/checkout@v7
if: ${{ !inputs.nightly && inputs.probe == 'none' }}
- uses: actions/download-artifact@v4
if: ${{ !inputs.nightly && inputs.probe == 'none' }}
with:
pattern: ${{ inputs.artifact }}-*
path: reports
- name: Prove coverage and report balance
if: ${{ !inputs.nightly && inputs.probe == 'none' }}
env:
PARTITIONS: ${{ inputs.partitions }}
run: |
count=$(python3 -c 'import json,os; print(len(json.loads(os.environ["PARTITIONS"])))')
python3 scripts/ci-timings.py verify --count "$count" reports/* >> "$GITHUB_STEP_SUMMARY"