-
Notifications
You must be signed in to change notification settings - Fork 55
245 lines (227 loc) · 7.05 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
name: CI
on:
pull_request:
branches:
- main
push:
branches:
- main
env:
RUSTFLAGS: -Dwarnings
RUST_BACKTRACE: 1
jobs:
pr-status-checks:
name: Pull Request Status Checks
runs-on: ubuntu-latest
needs:
- docs
- deny
- clippy
- fmt
- check-features
- test
steps:
- run: exit 0
docs:
name: Doc checks
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: "recursive"
- name: Install Rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: nightly
- uses: Swatinem/rust-cache@v2
- name: Run doc checks
run: |
cargo doc --lib --no-deps --all-features --document-private-items
env:
RUSTDOCFLAGS: -Dwarnings --cfg tokio_unstable --cfg foundations_unstable
RUSTFLAGS: -Dwarnings --cfg tokio_unstable --cfg foundations_unstable
deny:
name: Cargo deny checks
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: "recursive"
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- name: Run cargo deny checks
uses: EmbarkStudios/cargo-deny-action@v1
with:
command: check
clippy:
name: Clippy checks
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: "recursive"
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
components: clippy
- uses: Swatinem/rust-cache@v2
- name: Run Clippy
run: |
cargo clippy --all-targets -- \
-D warnings \
-D unreachable_pub \
-D clippy::await_holding_lock \
-D clippy::clone_on_ref_ptr
env:
RUSTFLAGS: -Dwarnings --cfg tokio_unstable --cfg foundations_unstable
fmt:
name: fmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: "recursive"
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt
- uses: Swatinem/rust-cache@v2
# Check fmt
- name: "rustfmt --check"
# Workaround for rust-lang/cargo#7732
# based on tokio's ci job
run: |
if ! rustfmt --check --edition 2021 $(git ls-files '*.rs'); then
printf "Please run \`rustfmt --edition 2021 \$(git ls-files '*.rs')\` to fix rustfmt errors.\n" >&2
exit 1
fi
check-features:
name: Check feature combinations
strategy:
matrix:
os: [ ubuntu-latest, macos-latest ]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
with:
submodules: "recursive"
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- name: Install cargo hack
uses: taiki-e/install-action@cargo-hack
- name: Check
run: ./scripts/check-features.sh
shell: bash
check-tokio-unstable:
name: Check unstable
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: "recursive"
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- name: Install cargo hack
uses: taiki-e/install-action@cargo-hack
- name: Check unstable
run: cargo hack check --no-dev-deps
env:
RUSTFLAGS: -Dwarnings --cfg tokio_unstable --cfg foundations_unstable
test-tokio-unstable:
name: Test unstable
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: "recursive"
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- name: Test unstable
run: cargo test --all-features
env:
RUSTFLAGS: -Dwarnings --cfg tokio_unstable --cfg foundations_unstable
_RJEM_MALLOC_CONF: prof:true
test:
name: Test
runs-on: ${{ matrix.os }}
strategy:
matrix:
thing:
- x86_64-linux
- aarch64-linux
- arm64-android
- arm-android
- aarch64-ios
- x86_64-macos
include:
- apt_packages: ""
- custom_env: {}
- build_only: false
- cargo_args: ""
- thing: x86_64-linux
target: x86_64-unknown-linux-gnu
rust: stable
os: ubuntu-latest
- thing: aarch64-linux
build_only: true
target: aarch64-unknown-linux-gnu
rust: stable
os: ubuntu-latest
apt_packages: crossbuild-essential-arm64
custom_env:
CC: aarch64-linux-gnu-gcc
CXX: aarch64-linux-gnu-g++
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-g++
- thing: arm64-android
build_only: true
target: aarch64-linux-android
rust: stable
os: ubuntu-latest
cargo_args: --no-default-features --features server-client-common-default
- thing: arm-android
build_only: true
target: armv7-linux-androideabi
rust: stable
os: ubuntu-latest
cargo_args: --no-default-features --features server-client-common-default
- thing: aarch64-ios
build_only: true
target: aarch64-apple-ios
rust: stable
os: macos-latest
cargo_args: --no-default-features --features server-client-common-default
- thing: x86_64-macos
target: x86_64-apple-darwin
rust: stable
os: macos-latest
steps:
- uses: actions/checkout@v4
with:
submodules: "recursive"
- name: Install Rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.rust }}
targets: ${{ matrix.target }}
- uses: Swatinem/rust-cache@v2
- name: Install target-specific APT dependencies
if: "matrix.apt_packages != ''"
run: sudo apt update && sudo apt install -y ${{ matrix.apt_packages }}
shell: bash
- name: Set Android Linker path
if: endsWith(matrix.thing, '-android')
run: echo "CARGO_TARGET_$(echo ${{ matrix.target }} | tr \\-a-z _A-Z)_LINKER=$ANDROID_NDK/toolchains/llvm/prebuilt/linux-x86_64/bin/$(echo ${{ matrix.target }} | sed s/armv7/armv7a/)21-clang++" >> "$GITHUB_ENV"
- name: Build tests
# We `build` because we want the linker to verify we are cross-compiling correctly for check-only targets.
run: cargo build --target ${{ matrix.target }} ${{matrix.cargo_args}}
shell: bash
env: ${{ matrix.custom_env }}
- name: Run tests
if: "!matrix.build_only"
run: _RJEM_MALLOC_CONF=prof:true cargo test --target ${{ matrix.target }} ${{matrix.cargo_args}}
shell: bash
env: ${{ matrix.custom_env }}