-
Notifications
You must be signed in to change notification settings - Fork 29
225 lines (225 loc) · 8.22 KB
/
ci.yml
File metadata and controls
225 lines (225 loc) · 8.22 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
216
217
218
219
220
221
222
223
224
225
permissions:
contents: read
on:
push:
branches: [main, kernel]
pull_request:
name: CI
jobs:
# commit_list job copied & adapted from <https://github.com/landlock-lsm/rust-landlock/blob/0f4246a54e17eb57ee938e67c5d85a07d1f977a5/.github/workflows/rust.yml>
commit_list:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get commit list (push)
id: get_commit_list_push
if: ${{github.event_name == 'push'}}
run: |
git rev-list --reverse ${{github.event.before}}..${{github.event.after}} | \
awk '{ printf "{\"num\":" NR ",\"sha\":\"" $1 "\",\"short\":\"" substr($1, 0, 12) "\"}," }' | \
sed 's/,$//' | \
awk '{ printf "[" $1 "]" }' | \
jq -c . | \
awk '{ print "commits=" $1 }' >> $GITHUB_OUTPUT
cat $GITHUB_OUTPUT
- name: Get commit list (PR)
id: get_commit_list_pr
if: ${{github.event_name == 'pull_request'}}
run: |
git rev-list --reverse ${{github.event.pull_request.base.sha}}..${{github.event.pull_request.head.sha}} | \
awk '{ printf "{\"num\":" NR ",\"sha\":\"" $1 "\",\"short\":\"" substr($1, 0, 12) "\"}," }' | \
sed 's/,$//' | \
awk '{ printf "[" $1 "]" }' | \
jq -c . | \
awk '{ print "commits=" $1 }' >> $GITHUB_OUTPUT
cat $GITHUB_OUTPUT
outputs:
commits: ${{toJSON(steps.*.outputs.commits)}}
fmt:
needs: commit_list
strategy:
matrix:
commit: ${{fromJSON(needs.commit_list.outputs.commits)}}
name: "fmt #${{matrix.commit.num}} (${{matrix.commit.short}})"
runs-on: ubuntu-latest
steps:
- run: echo "${{fromJSON(needs.commit_list.outputs.commits)}}"
- uses: actions/checkout@v4
with:
ref: ${{matrix.commit.sha}}
- uses: dtolnay/rust-toolchain@nightly
with:
components: rustfmt
- run: cargo fmt --check
- run: cd internal && cargo fmt --check
readme:
needs: commit_list
runs-on: ubuntu-latest
strategy:
matrix:
commit: ${{fromJSON(needs.commit_list.outputs.commits)}}
name: "readme #${{matrix.commit.num}} (${{matrix.commit.short}})"
steps:
- uses: actions/checkout@v4
with:
ref: ${{matrix.commit.sha}}
- uses: dtolnay/rust-toolchain@nightly
- run: cargo install cargo-rdme
- run: cargo rdme --check
docs:
needs: commit_list
runs-on: ubuntu-latest
strategy:
matrix:
commit: ${{fromJSON(needs.commit_list.outputs.commits)}}
name: "docs #${{matrix.commit.num}} (${{matrix.commit.short}})"
steps:
- uses: actions/checkout@v4
with:
ref: ${{matrix.commit.sha}}
- uses: dtolnay/rust-toolchain@nightly
- uses: dtolnay/rust-toolchain@nightly
with:
components: rust-src
- run: cargo doc --no-deps
clippy:
needs: commit_list
runs-on: ubuntu-latest
strategy:
matrix:
commit: ${{fromJSON(needs.commit_list.outputs.commits)}}
name: "clippy #${{matrix.commit.num}} (${{matrix.commit.short}})"
steps:
- uses: actions/checkout@v4
with:
ref: ${{matrix.commit.sha}}
- uses: dtolnay/rust-toolchain@nightly
with:
components: clippy
- run: cargo install cargo-hack
- run: cargo hack --clean-per-run --feature-powerset clippy --locked
test:
needs: commit_list
runs-on: ubuntu-latest
strategy:
matrix:
commit: ${{fromJSON(needs.commit_list.outputs.commits)}}
name: "test #${{matrix.commit.num}} (${{matrix.commit.short}})"
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@nightly
with:
components: rust-src
- run: cargo install cargo-expand
- run: cargo test --locked
miri:
needs: commit_list
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
commit: ${{fromJSON(needs.commit_list.outputs.commits)}}
flags: [
"",
"-Zmiri-tree-borrows",
"-Zmiri-strict-provenance",
"-Zmiri-tree-borrows -Zmiri-strict-provenance",
]
name: "miri #${{matrix.commit.num}} (${{matrix.commit.short}})"
steps:
- uses: actions/checkout@v4
with:
ref: ${{matrix.commit.sha}}
- run: |
echo "NIGHTLY=nightly-$(curl -s https://rust-lang.github.io/rustup-components-history/x86_64-unknown-linux-gnu/miri)" >> $GITHUB_ENV
- name: Install ${{env.NIGHTLY}}
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{env.NIGHTLY}}
components: miri, rust-src
- run: cargo install cargo-expand
- name: ${{matrix.flags}} cargo miri test
run: cargo miri test --locked
env:
MIRIFLAGS: ${{matrix.flags}}
sanitizers:
needs: commit_list
runs-on: ubuntu-latest
strategy:
matrix:
commit: ${{fromJSON(needs.commit_list.outputs.commits)}}
name: "sanitizers #${{matrix.commit.num}} (${{matrix.commit.short}})"
steps:
- uses: actions/checkout@v4
with:
ref: ${{matrix.commit.sha}}
- uses: dtolnay/rust-toolchain@nightly
with:
components: rust-src
- name: enable debug symbols
run: |
sudo apt install llvm
# https://github.com/japaric/rust-san#unrealiable-leaksanitizer
sed -i '/\[features\]/i [profile.dev]' Cargo.toml
sed -i '/profile.dev/a opt-level = 1' Cargo.toml
cat Cargo.toml
- run: cargo test --lib --tests --target x86_64-unknown-linux-gnu
env:
ASAN_OPTIONS: "detect_odr_violation=0:detect_leaks=0"
RUSTFLAGS: "--cfg NO_UI_TESTS --cfg NO_ALLOC_FAIL_TESTS -Z sanitizer=address"
- run: cargo test --target x86_64-unknown-linux-gnu
env:
RUSTFLAGS: "--cfg NO_UI_TESTS --cfg NO_ALLOC_FAIL_TESTS -Z sanitizer=leak"
msrv:
needs: commit_list
runs-on: ubuntu-latest
strategy:
matrix:
commit: ${{fromJSON(needs.commit_list.outputs.commits)}}
name: "msrv #${{matrix.commit.num}} (${{matrix.commit.short}})"
steps:
- uses: actions/checkout@v4
with:
ref: ${{matrix.commit.sha}}
- uses: dtolnay/rust-toolchain@stable
- run: cargo install cargo-hack
- run: cargo hack --clean-per-run --feature-powerset --exclude-features alloc --exclude-features default --version-range 1.82.. --clean-per-version check --locked
nightly-msrv:
needs: commit_list
runs-on: ubuntu-latest
strategy:
matrix:
commit: ${{fromJSON(needs.commit_list.outputs.commits)}}
name: "nightly-msrv #${{matrix.commit.num}} (${{matrix.commit.short}})"
steps:
- uses: actions/checkout@v4
with:
ref: ${{matrix.commit.sha}}
- uses: dtolnay/rust-toolchain@stable
with:
components: rust-src
- run: cargo install cargo-hack
- run: cargo install cargo-expand
- run: cargo hack --clean-per-run --feature-powerset --version-range 1.78.. --clean-per-version check --locked
env:
RUSTC_BOOTSTRAP: 1
os-check:
needs: commit_list
strategy:
fail-fast: false
matrix:
os: [macos-latest, windows-latest]
commit: ${{fromJSON(needs.commit_list.outputs.commits)}}
runs-on: ${{matrix.os}}
name: "os-check (${{matrix.os}}) #${{matrix.commit.num}} (${{matrix.commit.short}})"
steps:
- uses: actions/checkout@v4
with:
ref: ${{matrix.commit.sha}}
- uses: dtolnay/rust-toolchain@nightly
with:
components: rust-src
- run: cargo install cargo-expand
- run: cargo test --locked