-
Notifications
You must be signed in to change notification settings - Fork 553
376 lines (344 loc) · 13.7 KB
/
ci.yml
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
name: ci
on: [push, pull_request]
jobs:
lint:
name: ${{ matrix.component }} ${{ matrix.os }}
runs-on: ${{ matrix.os }}
timeout-minutes: 15
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macOS-latest, windows-latest]
component: [clippy]
include:
- component: rustfmt
cargo_cmd: fmt -- --check
os: ubuntu-latest
- component: clippy
cargo_cmd: clippy --locked --all-targets -- -D warnings -A unknown-lints -A clippy::type_complexity -A clippy::new-without-default
steps:
- name: Clone repository
uses: actions/checkout@v4
- name: Install rust
uses: ./.github/actions/rust-toolchain
with:
components: ${{ matrix.component }}
# Oldest supported version, keep in sync with README.md
toolchain: "1.70.0"
- name: clippy version
run: cargo clippy --version
if: ${{ matrix.component == 'clippy' }}
- name: Check
run: cargo ${{ matrix.cargo_cmd }}
check_features:
runs-on: ubuntu-latest
strategy:
matrix:
feature: [azure, gcs, gha, memcached, redis, s3, webdav]
steps:
- name: Clone repository
uses: actions/checkout@v4
- name: Check feature ${{ matrix.feature }}
run: cargo check --no-default-features --features ${{ matrix.feature }}
toml_format:
runs-on: ubuntu-latest
steps:
- name: Clone repository
uses: actions/checkout@v4
- name: Check
run: npx --yes @taplo/cli fmt --check
test:
name: test ${{ matrix.os }} rust ${{ matrix.rustc || 'stable' }} ${{ matrix.extra_desc }}
runs-on: ${{ matrix.os }}
continue-on-error: ${{ matrix.allow_failure || false }}
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-20.04
# Oldest supported version, keep in sync with README.md
rustc: "1.70.0"
- os: ubuntu-22.04
# Oldest supported version, keep in sync with README.md
rustc: "1.70.0"
extra_desc: dist-server
extra_args: --no-default-features --features=dist-tests test_dist_ -- --test-threads 1
- os: ubuntu-20.04
rustc: stable
- os: ubuntu-20.04
rustc: beta
- os: ubuntu-20.04
rustc: nightly
allow_failure: true
extra_args: --features=unstable
- os: ubuntu-20.04
extra_desc: no-default-features
extra_args: --no-default-features
allow_failure: true
- os: ubuntu-22.04
- os: macOS-11
# M1 CPU
- os: macos-14
- os: windows-2019
# Oldest supported version, keep in sync with README.md
rustc: "1.70.0"
- os: windows-2019
rustc: nightly
allow_failure: true
extra_args: --features=unstable
- os: windows-2019
rustc: beta
env:
RUST_BACKTRACE: 1
steps:
- name: Clone repository
uses: actions/checkout@v4
- name: Install rust
uses: ./.github/actions/rust-toolchain
with:
toolchain: ${{ matrix.rustc }}
- name: Install gcc & clang for tests
run: sudo apt-get install -y clang gcc
if: ${{ matrix.os == 'ubuntu-20.04' || matrix.os == 'ubuntu-22.04' }}
- name: Build tests
run: cargo test --no-run --locked --all-targets ${{ matrix.extra_args }}
- name: Run tests
run: cargo test --locked --all-targets ${{ matrix.extra_args }}
- name: Upload failure
if: failure()
uses: ./.github/actions/artifact_failure
with:
name: test-${{ matrix.os }}-${{ matrix.rustc || 'stable' }}-${{ matrix.extra_desc }}
build:
name: build ${{ matrix.binary || 'sccache' }} ${{ matrix.target }}
runs-on: ${{ matrix.os }}
container: ${{ fromJson(matrix.container || '{"image":null}') }}
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-20.04
target: x86_64-unknown-linux-musl
container: '{"image": "messense/rust-musl-cross:x86_64-musl"}'
- os: ubuntu-20.04
binary: sccache-dist
extra_args: --no-default-features --features="dist-server"
target: x86_64-unknown-linux-musl
container: '{"image": "messense/rust-musl-cross:x86_64-musl"}'
- os: ubuntu-20.04
target: aarch64-unknown-linux-musl
container: '{"image": "messense/rust-musl-cross:aarch64-musl"}'
- os: ubuntu-20.04
target: armv7-unknown-linux-musleabi
container: '{"image": "messense/rust-musl-cross:armv7-musleabi"}'
- os: ubuntu-20.04
target: i686-unknown-linux-musl
container: '{"image": "messense/rust-musl-cross:i686-musl"}'
- os: macOS-11
target: x86_64-apple-darwin
macosx_deployment_target: 10.13
developer_dir: /Applications/Xcode_11.7.app
sdkroot: /Applications/Xcode_11.7.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk
- os: macos-14
target: aarch64-apple-darwin
macosx_deployment_target: 11.0
- os: windows-2019
target: x86_64-pc-windows-msvc
rustflags: -Ctarget-feature=+crt-static
steps:
- name: Clone repository
uses: actions/checkout@v4
- name: Install rust
uses: ./.github/actions/rust-toolchain
with:
toolchain: ${{ matrix.target == 'aarch64-apple-darwin' && 'beta' || 'stable' }}
target: ${{ matrix.target }}
if: ${{ !matrix.container }}
- name: Build
run: cargo build --locked --release --bin ${{ matrix.binary || 'sccache' }} --target ${{ matrix.target }} --features=openssl/vendored ${{ matrix.extra_args }}
env:
MACOSX_DEPLOYMENT_TARGET: ${{ matrix.macosx_deployment_target }}
DEVELOPER_DIR: ${{ matrix.developer_dir }}
SDKROOT: ${{ matrix.sdkroot }}
RUSTFLAGS: ${{ matrix.rustflags }}
# Workaround for the lack of substring() function in github actions expressions.
- name: Id
id: id
shell: bash
run: echo "id=${ID#refs/tags/}" >> $GITHUB_OUTPUT
env:
ID: ${{ startsWith(github.ref, 'refs/tags/') && github.ref || github.sha }}
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.binary || 'sccache' }}-${{ steps.id.outputs.id }}-${{ matrix.target }}
path: target/${{ matrix.target }}/release/${{ matrix.binary || 'sccache' }}${{ endsWith(matrix.target, '-msvc') && '.exe' || '' }}
if-no-files-found: error
coverage:
name: coverage ${{ matrix.os }} rust ${{ matrix.rustc || 'stable' }} ${{ matrix.extra_desc }}
runs-on: ${{ matrix.os }}
continue-on-error: ${{ matrix.allow_failure || false }}
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-20.04
rustc: nightly
allow_failure: true
extra_args: --features=unstable
- os: macOS-11
rustc: nightly
# Disable on Windows for now as it fails with:
# found invalid metadata files for crate `vte_generate_state_changes`
# - os: windows-2019
# rustc: nightly
env:
RUST_BACKTRACE: 1
steps:
- name: Clone repository
uses: actions/checkout@v4
- name: Install rust
uses: ./.github/actions/rust-toolchain
with:
toolchain: ${{ matrix.rustc }}
- name: Install gcc & clang for tests
run: sudo apt-get install -y clang gcc
if: ${{ matrix.os == 'ubuntu-20.04' }}
- name: "`grcov` ~ install"
run: cargo install grcov
- name: Execute tests
run: cargo test --no-fail-fast --locked --all-targets ${{ matrix.extra_args }}
env:
CARGO_INCREMENTAL: "0"
RUSTC_WRAPPER: ""
RUSTFLAGS: "-Zprofile -Ccodegen-units=1 -Copt-level=0 -Clink-dead-code -Coverflow-checks=off"
- name: Generate coverage data (via `grcov`)
id: coverage
shell: bash
run: |
## Generate coverage data
COVERAGE_REPORT_DIR="target/debug"
COVERAGE_REPORT_FILE="${COVERAGE_REPORT_DIR}/lcov.info"
# GRCOV_IGNORE_OPTION='--ignore build.rs --ignore "/*" --ignore "[a-zA-Z]:/*"' ## `grcov` ignores these params when passed as an environment variable (why?)
# GRCOV_EXCLUDE_OPTION='--excl-br-line "^\s*((debug_)?assert(_eq|_ne)?!|#\[derive\()"' ## `grcov` ignores these params when passed as an environment variable (why?)
mkdir -p "${COVERAGE_REPORT_DIR}"
# display coverage files
grcov . --output-type files --ignore build.rs --ignore "/*" --ignore "[a-zA-Z]:/*" --excl-br-line "^\s*((debug_)?assert(_eq|_ne)?!|#\[derive\()" | sort --unique
# generate coverage report
grcov . --output-type lcov --output-path "${COVERAGE_REPORT_FILE}" --branch --ignore build.rs --ignore "/*" --ignore "[a-zA-Z]:/*" --excl-br-line "^\s*((debug_)?assert(_eq|_ne)?!|#\[derive\()"
echo "report=${COVERAGE_REPORT_FILE}" >> $GITHUB_OUTPUT
- name: Upload coverage results (to Codecov.io)
uses: codecov/codecov-action@v4
with:
file: ${{ steps.coverage.outputs.report }}
## flags: IntegrationTests, UnitTests, ${{ steps.vars.outputs.CODECOV_FLAGS }}
flags: ${{ steps.vars.outputs.CODECOV_FLAGS }}
name: codecov-umbrella
fail_ci_if_error: false
test_freebsd:
name: test freebsd-13.2 rust stable
runs-on: ${{ matrix.job.os }}
timeout-minutes: 70
strategy:
fail-fast: false
matrix:
job:
- { os: ubuntu-22.04 }
steps:
- uses: actions/checkout@v4
- name: Prepare, build and test
uses: vmactions/freebsd-vm@v1.0.7
with:
mem: 8192
usesh: true
sync: rsync
copyback: false
prepare: pkg install -y ca_root_nss curl gmake gtar pot sudo
run: |
#####################################################################################
### Prepare, build, and test
#####################################################################################
### based on ref: <https://github.com/rust-lang/rustup/pull/2783>
### and on ref: <https://github.com/uutils/coreutils/commit/86c610a84b8b6c>
### * NOTE: All steps need to be run in this block, otherwise, we are operating back
### on the mac host.
set -exo pipefail
#
### Basic user setup ################################################################
TEST_USER=tester
TEST_USER_HOME="/opt/$TEST_USER"
REPO_NAME=${GITHUB_WORKSPACE##*/}
WORKSPACE_PARENT="/home/runner/work/${REPO_NAME}"
WORKSPACE="${WORKSPACE_PARENT}/${REPO_NAME}"
export WORKSPACE
#
mkdir -p "$TEST_USER_HOME"
pw adduser -n "$TEST_USER" -d "$TEST_USER_HOME" -c "Tester" -h -
chown -R "$TEST_USER":"$TEST_USER" "$TEST_USER_HOME"
chown -R "$TEST_USER":"$TEST_USER" "/$WORKSPACE_PARENT"/
cat > /usr/local/etc/sudoers.d/wheel<<EOF
$TEST_USER ALL=(ALL) NOPASSWD: ALL
EOF
#
### Install rust stable from rustup ################################################
su "$TEST_USER" -c "/bin/sh -exo pipefail" <<"EOH"
whoami
echo "$HOME"
fetch -o /tmp/rustup.sh https://sh.rustup.rs
sh /tmp/rustup.sh -y --profile=minimal
### Run tests #######################################################################
. "$HOME/.cargo/env"
"$WORKSPACE/scripts/freebsd-ci-test.sh"
EOH
# end
- name: Upload failure
if: failure()
uses: ./.github/actions/artifact_failure
with:
name: test-freebsd-13.2-stable
release:
name: release
runs-on: ubuntu-latest
needs: [build, lint, test]
if: ${{ startsWith(github.ref, 'refs/tags/') }}
steps:
- name: Clone repository
uses: actions/checkout@v4
- name: Check versions
run: |
tag_name=${GITHUB_REF#refs/tags/}
v=$(grep -m 1 "^version" Cargo.toml|sed -e "s|version = \"\(.*\)\"|\1|")
if ! echo $tag_name|grep -q $v; then
echo "Mistmatch of the version:"
echo "Cargo.toml says $v while the tag is $tag_name"
exit 2
fi
- name: Get artifacts
uses: actions/download-artifact@v4
- name: Create release assets
run: |
for d in sccache-*; do
chmod +x "$d/sccache"*
cp README.md LICENSE "$d/"
tar -zcvf "$d.tar.gz" "$d"
echo -n "$(shasum -ba 256 "$d.tar.gz" | cut -d " " -f 1)" > "$d.tar.gz.sha256"
if [[ $d =~ (sccache-)(.*)?(x86_64-pc-windows)(.*)? ]]; then
zip -r "$d.zip" "$d"
echo -n "$(shasum -ba 256 "$d.zip" | cut -d " " -f 1)" > "$d.zip.sha256"
fi
done
- name: Create release
run: |
sudo apt-get update && sudo apt-get install -y hub
tag_name=${GITHUB_REF#refs/tags/}
for f in sccache-*.tar.gz* sccache-*.zip*; do
if [[ -f "$f" ]]; then
files="$files -a $f";
fi
done
hub release create -m $tag_name $tag_name $files
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}