-
Notifications
You must be signed in to change notification settings - Fork 23
178 lines (144 loc) · 5.02 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
name: CI
on:
merge_group:
pull_request:
workflow_dispatch:
concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true
env:
CARGO_TERM_COLOR: always
jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Log github refs
run: |
{
echo '```'
echo 'github.ref: ${{ github.ref }}'
echo 'github.sha: ${{ github.sha }}'
echo '```'
} >> "$GITHUB_STEP_SUMMARY"
- uses: actions/checkout@v4
- uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
~/.dylint_drivers/
~/.rustup/toolchains/
key: ${{ runner.os }}-drivers-${{ hashFiles('driver/**') }}
- name: Install dylint-link
run: cargo install --path ./dylint-link --force
- name: Actionlint
run: |
go install github.com/rhysd/actionlint/cmd/actionlint@latest
"$HOME"/go/bin/actionlint
- name: Shellcheck
run: shellcheck --exclude=SC2002 scripts/*
- name: Install tools
run: |
# smoelius: Prettier is still needed for scripts/update_example_READMEs.sh.
npm install -g prettier
rm -f "$HOME"/.cargo/bin/cargo-fmt
rm -f "$HOME"/.cargo/bin/rustfmt
rustup install nightly
rustup component add rustfmt --toolchain nightly
cargo install cargo-license || true
cargo install cargo-rdme || true
cargo install cargo-sort || true
- name: Cargo sort
run: find . -name Cargo.toml -print0 | xargs -0 -n 1 dirname | xargs -n 1 cargo sort --check --grouped
- name: Format
run: ./scripts/format.sh && git diff --exit-code
- name: Format example READMEs
run: ./scripts/update_example_READMEs.sh && git diff --exit-code
- name: Format util READMEs
run: ./scripts/update_util_READMEs.sh && git diff --exit-code
- name: Check lockfiles
run: ./scripts/update_lockfiles.sh && git diff --exit-code
- name: Check licenses
run: ./scripts/check_licenses.sh
- name: Lint
run: ./scripts/lint.sh
test:
strategy:
fail-fast: false
matrix:
environment: [ubuntu-latest, macos-latest, windows-latest]
package: [cargo-dylint, examples, other]
runs-on: ${{ matrix.environment }}
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v4
# smoelius: The `nightly_toolchain` test makes sense only if the nightly driver is cached.
- uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
~/.dylint_drivers/
~/.rustup/toolchains/
key: ${{ runner.os }}-drivers-${{ hashFiles('driver/**') }}
- name: Rustup
run: rustup update
- name: Install dylint-link
run: cargo install --path ./dylint-link --force
# smoelius: This list will grow: https://github.com/trailofbits/dylint/issues/636
- name: Install tools
run: |
npm install -g prettier
rustup install nightly
cargo install cargo-hack || true
cargo install cargo-msrv || true
cargo install cargo-supply-chain || true
cargo install cargo-udeps || true
- name: Free up space on Ubuntu
if: ${{ matrix.environment == 'ubuntu-latest' }}
run: |
# https://github.com/actions/runner-images/issues/2606#issuecomment-772683150
sudo rm -rf /usr/local/lib/android
sudo rm -rf /usr/share/dotnet
sudo rm -rf /usr/share/swift
# du -sh /usr/*/* 2>/dev/null | sort -h || true
- name: Test
run: |
if [[ '${{ matrix.environment }}' = 'windows-latest' ]]; then
export CARGO_INCREMENTAL=0
fi
if [[ '${{ matrix.package }}' != 'other' ]]; then
cargo test -p '${{ matrix.package }}' --all-features -- --nocapture
else
cargo test --workspace --exclude cargo-dylint --exclude examples --all-features -- --nocapture
pushd driver
cargo test --all-features -- --nocapture
popd
pushd utils/linting
cargo test --all-features -- --nocapture
popd
# 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
cargo test --doc
popd
done
fi
all-checks:
needs: [lint, test]
runs-on: ubuntu-latest
steps:
- run: true