-
Notifications
You must be signed in to change notification settings - Fork 0
235 lines (211 loc) · 7.39 KB
/
tests.yaml
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
# Run all tests, with or without flaky tests.
name: Tests
on:
workflow_call:
inputs:
rust-version:
description: 'The version of the rust compiler to run'
type: string
default: 'stable'
flaky:
description: 'Whether to also run flaky tests'
type: boolean
default: false
git-ref:
description: 'Which git ref to checkout'
type: string
default: ${{ github.ref }}
env:
RUST_BACKTRACE: 1
RUSTFLAGS: -Dwarnings
RUSTDOCFLAGS: -Dwarnings
SCCACHE_CACHE_SIZE: "10G"
CRATES_LIST: "iroh-metrics"
IROH_FORCE_STAGING_RELAYS: "1"
jobs:
build_and_test_nix:
timeout-minutes: 30
name: "Tests"
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
name: [ubuntu-latest, macOS-arm-latest]
rust: [ '${{ inputs.rust-version }}' ]
features: [all, none, default]
include:
- name: ubuntu-latest
os: ubuntu-latest
release-os: linux
release-arch: amd64
runner: [self-hosted, linux, X64]
- name: macOS-arm-latest
os: macOS-latest
release-os: darwin
release-arch: aarch64
runner: [self-hosted, macOS, ARM64]
env:
# Using self-hosted runners so use local cache for sccache and
# not SCCACHE_GHA_ENABLED.
RUSTC_WRAPPER: "sccache"
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ inputs.git-ref }}
- name: Install ${{ matrix.rust }} rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.rust }}
- name: Install cargo-nextest
uses: taiki-e/install-action@v2
with:
tool: nextest
- name: Install sccache
uses: mozilla-actions/[email protected]
- name: Select features
run: |
case "${{ matrix.features }}" in
all)
echo "FEATURES=--all-features" >> "$GITHUB_ENV"
;;
none)
echo "FEATURES=--no-default-features" >> "$GITHUB_ENV"
;;
default)
echo "FEATURES=" >> "$GITHUB_ENV"
;;
*)
exit 1
esac
- name: check features
if: ${{ ! inputs.flaky }}
run: |
for i in ${CRATES_LIST//,/ }
do
echo "Checking $i $FEATURES"
if [ $i = "iroh-cli" ]; then
targets="--bins"
else
targets="--lib --bins"
fi
echo cargo check -p $i $FEATURES $targets
cargo check -p $i $FEATURES $targets
done
env:
RUST_LOG: ${{ runner.debug && 'TRACE' || 'DEBUG'}}
- name: build tests
run: |
cargo nextest run --workspace ${{ env.FEATURES }} --lib --bins --tests --no-run
- name: list ignored tests
run: |
cargo nextest list --workspace ${{ env.FEATURES }} --lib --bins --tests --run-ignored ignored-only
env:
NEXTEST_NO_TESTS: "pass"
- name: run tests
run: |
mkdir -p output
cargo nextest run --workspace ${{ env.FEATURES }} --lib --bins --tests --profile ci --run-ignored ${{ inputs.flaky && 'all' || 'default' }} --no-fail-fast --message-format ${{ inputs.flaky && 'libtest-json' || 'human' }} > output/${{ matrix.name }}_${{ matrix.features }}_${{ matrix.rust }}.json
env:
RUST_LOG: ${{ runner.debug && 'TRACE' || 'DEBUG'}}
NEXTEST_EXPERIMENTAL_LIBTEST_JSON: 1
NEXTEST_NO_TESTS: "pass"
- name: upload results
if: ${{ failure() && inputs.flaky }}
uses: actions/upload-artifact@v4
with:
name: libtest_run_${{ github.run_number }}-${{ github.run_attempt }}-${{ matrix.name }}_${{ matrix.features }}_${{ matrix.rust }}.json
path: output
retention-days: 45
compression-level: 0
- name: doctests
if: ${{ (! inputs.flaky) && matrix.features == 'all' }}
run: |
if [ -n "${{ runner.debug }}" ]; then
export RUST_LOG=TRACE
else
export RUST_LOG=DEBUG
fi
cargo test --workspace --all-features --doc
build_and_test_windows:
timeout-minutes: 30
name: "Tests"
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
name: [windows-latest]
rust: [ '${{ inputs.rust-version}}' ]
features: [all, none, default]
target:
- x86_64-pc-windows-msvc
include:
- name: windows-latest
os: windows
runner: [self-hosted, windows, x64]
env:
# Using self-hosted runners so use local cache for sccache and
# not SCCACHE_GHA_ENABLED.
RUSTC_WRAPPER: "sccache"
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ inputs.git-ref }}
- name: Install ${{ matrix.rust }}
run: |
rustup toolchain install ${{ matrix.rust }}
rustup toolchain default ${{ matrix.rust }}
rustup target add ${{ matrix.target }}
rustup set default-host ${{ matrix.target }}
- name: Install cargo-nextest
shell: powershell
run: |
$tmp = New-TemporaryFile | Rename-Item -NewName { $_ -replace 'tmp$', 'zip' } -PassThru
Invoke-WebRequest -OutFile $tmp https://get.nexte.st/latest/windows
$outputDir = if ($Env:CARGO_HOME) { Join-Path $Env:CARGO_HOME "bin" } else { "~/.cargo/bin" }
$tmp | Expand-Archive -DestinationPath $outputDir -Force
$tmp | Remove-Item
- name: Select features
run: |
switch ("${{ matrix.features }}") {
"all" {
echo "FEATURES=--all-features" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append
}
"none" {
echo "FEATURES=--no-default-features" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append
}
"default" {
echo "FEATURES=" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append
}
default {
Exit 1
}
}
- name: Install sccache
uses: mozilla-actions/[email protected]
- uses: msys2/setup-msys2@v2
- name: build tests
run: |
cargo nextest run --workspace ${{ env.FEATURES }} --lib --bins --tests --target ${{ matrix.target }} --no-run
- name: list ignored tests
run: |
cargo nextest list --workspace ${{ env.FEATURES }} --lib --bins --tests --target ${{ matrix.target }} --run-ignored ignored-only
env:
NEXTEST_NO_TESTS: "pass"
- name: tests
run: |
mkdir -p output
cargo nextest run --workspace ${{ env.FEATURES }} --lib --bins --tests --profile ci --target ${{ matrix.target }} --run-ignored ${{ inputs.flaky && 'all' || 'default' }} --no-fail-fast --message-format ${{ inputs.flaky && 'libtest-json' || 'human' }} > output/${{ matrix.name }}_${{ matrix.features }}_${{ matrix.rust }}.json
env:
RUST_LOG: ${{ runner.debug && 'TRACE' || 'DEBUG'}}
NEXTEST_EXPERIMENTAL_LIBTEST_JSON: 1
NEXTEST_NO_TESTS: "pass"
- name: upload results
if: ${{ failure() && inputs.flaky }}
uses: actions/upload-artifact@v4
with:
name: libtest_run_${{ github.run_number }}-${{ github.run_attempt }}-${{ matrix.name }}_${{ matrix.features }}_${{ matrix.rust }}.json
path: output
retention-days: 1
compression-level: 0