Repository navigation
215 lines (185 loc) · 7.27 KB
/
Copy pathci.yml
File metadata and controls
215 lines (185 loc) · 7.27 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
name: CI
on:
merge_group:
pull_request:
schedule:
- cron: "0 3 * * tue"
workflow_dispatch:
concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true
env:
CARGO_TERM_COLOR: always
permissions:
contents: read
jobs:
check-up-to-dateness:
outputs:
is-up-to-date: ${{ steps.main.outputs.is-up-to-date }}
runs-on: ubuntu-latest
steps:
- id: main
uses: trailofbits/check-up-to-dateness@v2
test:
needs: [check-up-to-dateness]
if: needs.check-up-to-dateness.outputs.is-up-to-date != 'true'
strategy:
fail-fast: ${{ github.event_name == 'merge_group' }}
matrix:
environment: [ubuntu-latest, macos-latest, windows-latest]
package:
[
cargo-dylint,
dylint_examples,
expensive-auto_correct,
expensive-alpine,
expensive-boundary_toolchains,
expensive-custom_toolchain,
other,
]
include:
- environment: ubuntu-latest
package: cargo-dylint-ci
runs-on: ${{ matrix.environment }}
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0
# smoelius: The `nightly_toolchain` test makes sense only if the nightly driver is cached.
- uses: actions/cache@v6
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
~/.cargo/git/checkouts/
~/.dylint_drivers/
target/dylint/libraries/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Rustup
run: rustup update
- name: Install dylint-link
run: cargo install --path ./dylint-link --features=__copy_library_disabled_by_default --force
- uses: taiki-e/install-action@v2.90.1
with:
tool: cargo-hack, cargo-nested, cargo-udeps
- name: Install tools
run: |
rustup install nightly
rustup component add rustfmt --toolchain nightly
npm install -g prettier
- name: Install CI tools
if: ${{ matrix.package == 'cargo-dylint-ci' }}
run: |
cargo install cargo-license || true
cargo install cargo-msrv --locked || true
cargo install cargo-rdme || true
cargo install cargo-supply-chain || true
cargo install cargo-unmaintained || true
cargo install rustdoc-prettier || true
- name: Free up space on Ubuntu
if: ${{ matrix.environment == 'ubuntu-latest' }}
run: |
# https://github.com/actions/runner-images/issues/2606#issuecomment-772683150
# du -sh /usr/*/* 2>/dev/null | sort -h
sudo rm -rfv /usr/lib/google-cloud-sdk | grep . >/dev/null
sudo rm -rfv /usr/lib/jvm | grep . >/dev/null
sudo rm -rfv /usr/share/az_* | grep . >/dev/null
sudo rm -rfv /usr/share/dotnet | grep . >/dev/null
sudo rm -rfv /usr/share/swift | grep . >/dev/null
- name: Free up space on macOS
if: ${{ matrix.environment == 'macos-latest' }}
run: |
# https://github.com/actions/runner-images/issues/2840#issuecomment-2334584217
# du -sh /*/* 2>/dev/null | sort -h
sudo rm -rfv /Applications/Xcode* | grep . >/dev/null
- name: Free up space on Windows
if: ${{ matrix.environment == 'windows-latest' }}
run: |
# du -sh /c/*/* 2>/dev/null | sort -h
rm -rfv /c/Program\ Files\ \(x86\)/Android | grep . >/dev/null
rm -rfv /c/ghcup/ghc | grep . >/dev/null
rm -rfv /c/rtools* | grep . >/dev/null
# smoelius: The next step avoids tests having to use `rustup` concurrently. Toolchain
# nightly-2026-08-05 is needed for cargo-rdme 2.2.0.
- name: Preinstall toolchains
run: |
cargo run -p dylint_internal --bin preinstall-toolchains
rustup toolchain add nightly-2026-08-05
rustup component add llvm-tools-preview rustc-dev --toolchain nightly-2026-08-05
- name: Fetch dependencies
run: cargo nested fetch
- name: Test
run: |
if [[ '${{ matrix.package }}' =~ ^cargo-dylint ]]; then
case '${{ matrix.package }}' in
cargo-dylint)
cargo test -p cargo-dylint --no-default-features --features=cargo-cli
;;
cargo-dylint-ci)
cargo test -p cargo-dylint --test ci
if [[ '${{ github.event_name }}' = 'schedule' || '${{ github.event_name }}' = 'workflow_dispatch' ]] ||
git diff --name-only ${{ github.event.pull_request.base.sha }} | grep -w 'scheduled'
then
cargo test -p scheduled
fi
;;
*)
exit 1
;;
esac
elif [[ '${{ matrix.package }}' != 'other' ]]; then
PACKAGE=''
TEST=''
if [[ '${{ matrix.package }}' =~ ^expensive- ]]; then
if [[ '${{ github.event_name }}' != 'schedule' && '${{ github.event_name }}' != 'workflow_dispatch' ]] &&
! git diff --name-only ${{ github.event.pull_request.base.sha }} | grep -w 'expensive'
then
exit
fi
PACKAGE='expensive'
TEST='${{ matrix.package }}'
TEST="--test=${TEST#'expensive-'}"
else
PACKAGE='${{ matrix.package }}'
fi
cargo test -p "$PACKAGE" "$TEST"
else
cargo test --all-features --workspace --exclude cargo-dylint --exclude dylint --exclude dylint_examples --exclude expensive --exclude scheduled
cargo test -p dylint --features=library_packages,package_options
cargo +nightly test -p dylint_internal --test build
# smoelius: The `cdylib` -> `lib` trick is due to @MinerSebas.
for X in examples/*/*; do
if [[ ! -d "$X" ]]; then
continue
fi
if [[ "$(basename "$X")" = '.cargo' || "$(basename "$X")" = 'src' ]]; then
continue
fi
pushd "$X"
sed -i.bak 's/"cdylib"/"lib"/g' Cargo.toml
# smoelius: `RUSTUP_WINDOWS_PATH_ADD_BIN=1` is needed for the `redundant_reference`
# doc tests to pass on Windows.
RUSTUP_WINDOWS_PATH_ADD_BIN=1 cargo test --doc
popd
done
fi
env:
CARGO_INCREMENTAL: 0
GITHUB_TOKEN: ${{ github.token }}
all-checks:
needs: [test]
# smoelius: From "Defining prerequisite jobs"
# (https://docs.github.com/en/actions/using-jobs/using-jobs-in-a-workflow#defining-prerequisite-jobs):
# > If you would like a job to run even if a job it is dependent on did not succeed, use the
# > `always()` conditional expression in `jobs.<job_id>.if`.
if: ${{ always() }}
runs-on: ubuntu-latest
steps:
- name: Check results
if: ${{ contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') }}
run: exit 1