-
Notifications
You must be signed in to change notification settings - Fork 169
252 lines (223 loc) · 8.5 KB
/
test.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
name: ci
on:
push:
branches:
- main
pull_request:
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
env:
RUSTFLAGS: "-D warnings"
CARGO_INCREMENTAL: 0
CARGO_PROFILE_DEV_DEBUG: 0
defaults:
run:
shell: bash
jobs:
test_matrix:
name: test (${{ matrix.os }} / stable)
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]
go-bin: ['~/go/bin']
include:
- os: windows-latest
go-bin: 'c:/Users/runneradmin/go/bin'
steps:
- name: Check out repository
uses: actions/checkout@v3
- name: Generate go.sum # go.sum is required by caching on the next step
run: touch go.sum
- name: Set up Go
id: setup-go
uses: actions/setup-go@v4 # v4 uses caching out of the box
with:
go-version: '1.22'
- name: Install nats-server
run: go install github.com/nats-io/nats-server/v2@main
- name: Install stable Rust on ${{ matrix.os }}
id: install-rust
uses: dtolnay/rust-toolchain@stable
- name: Cache the build artifacts
uses: Swatinem/rust-cache@v2 # caches dependencies only, not the whole ./target.
with:
shared-key: ${{ runner.os }}-${{ steps.install-rust.outputs.cachekey }}-${{ hashFiles('**/Cargo.toml') }}
# Cache the dependencies if they are built successfully even when tests fail.
cache-on-failure: true
- name: Build all packages
id: build-packages
run: cargo build --all --all-targets
- name: Setup deno for service tests
if: ${{ matrix.os }} != windows-latest
uses: denoland/setup-deno@v1
with:
deno-version: v1.x
- name: Run tests
env:
RUST_BACKTRACE: 1
run: |
nats-server --jetstream --port=4222 &
cargo test --features=${{ matrix.features }} --features slow_tests -- --nocapture
check_format:
name: check format (ubuntu-latest / nightly)
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v3
- name: Install nightly Rust on ubuntu-latest
id: install-rust
uses: dtolnay/rust-toolchain@nightly
with:
components: rustfmt
- name: Run the check
run: cargo fmt -- --check
check_lint:
name: check linter (ubuntu-latest / stable)
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v3
- name: Install stable Rust on ubuntu-latest
id: install-rust
uses: dtolnay/rust-toolchain@stable
with:
components: clippy # to reuse the cache
- name: Restore cached build artifacts
uses: Swatinem/rust-cache@v2
with:
shared-key: ${{ runner.os }}-${{ steps.install-rust.outputs.cachekey }}-${{ hashFiles('**/Cargo.toml') }}
save-if: false # the linter only run checks but not builds, so we don't have the full build to be cached.
- name: Run linter
run: cargo clippy --benches --tests --examples --all-features --workspace --exclude nats -- --deny clippy::all
check_docs:
name: check docs (ubuntu-latest / stable)
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v3
- name: Install stable Rust on ubuntu-latest
id: install-rust
uses: dtolnay/rust-toolchain@stable
- name: Restore cached build artifacts
uses: Swatinem/rust-cache@v2
with:
shared-key: ${{ runner.os }}-${{ steps.install-rust.outputs.cachekey }}-${{ hashFiles('**/Cargo.toml') }}
save-if: false # we only build docs, so we don't have the full build to be cached.
- name: Check lint
run: cargo doc --no-deps --all-features
check_features:
name: check feature flags (ubuntu-latest / stable)
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v3
- name: Install stable Rust on ubuntu-latest
id: install-rust
uses: dtolnay/rust-toolchain@stable
- name: Restore cached build artifacts
uses: Swatinem/rust-cache@v2
with:
shared-key: ${{ runner.os }}-${{ steps.install-rust.outputs.cachekey }}-${{ hashFiles('**/Cargo.toml') }}
save-if: false # we only build docs, so we don't have the full build to be cached.
- name: Install cargo hack
run: cargo install cargo-hack
- name: Check lint
run: cargo hack check --feature-powerset --at-least-one-of aws-lc-rs,ring --no-dev-deps -p async-nats
check_licenses:
name: check licenses (ubuntu-latest / stable)
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v3
- name: Run cargo deny
uses: EmbarkStudios/cargo-deny-action@v1
with:
command: check
command-arguments: licenses
check_msrv:
name: check minimal supported rust version (ubuntu-latest / msrv)
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v3
- name: Install msrv Rust on ubuntu-latest
id: install-rust
uses: dtolnay/[email protected]
- name: Cache the build artifacts
uses: Swatinem/rust-cache@v2
with:
shared-key: ${{ runner.os }}-${{ steps.install-rust.outputs.cachekey }}-${{ hashFiles('**/Cargo.toml') }}
# The cache for the msrv won't contain a full packages' builds (we only run check).
# We still cache these partial builds because they aren't reused by the other jobs.
- name: Check all packages
run: |
set -eo pipefail
cargo +${{ steps.install-rust.outputs.name }} check
check_examples:
name: check examples (ubuntu-latest / stable)
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v3
- name: Install stable Rust on ubuntu-latest
id: install-rust
uses: dtolnay/rust-toolchain@stable
- name: Restore cached build artifacts
uses: Swatinem/rust-cache@v2
with:
shared-key: ${{ runner.os }}-${{ steps.install-rust.outputs.cachekey }}-${{ hashFiles('**/Cargo.toml') }}
save-if: false # we are only checking examples, so we don't have the full build to be cached.
- name: Run the check
env:
RUST_LOG: trace
run: cargo check --examples
check_spelling:
name: check spelling (ubuntu-latest / nightly)
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v3
- name: Install llvm-config
run: sudo apt-get install -y libclang-dev
- name: Install nightly Rust on ubuntu-latest
id: install-rust
uses: dtolnay/rust-toolchain@nightly
- name: Cache cargo-spellcheck
id: cache-cargo-spellcheck
uses: actions/cache@v3
with:
path: ~/.cargo/bin/cargo-spellcheck
key: ${{ runner.os }}-${{ steps.install-rust.outputs.cachekey }}-cargo-spellcheck
- name: Install cargo-spellcheck
if: steps.cache-cargo-spellcheck.outputs.cache-hit != 'true'
run: cargo install cargo-spellcheck
- name: Check spelling
run: cargo spellcheck --code 1
check_min_versions:
name: check minimal versions of transitive dependencies (ubuntu-latest / stable)
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Install nightly for -Zminimal-versions
uses: dtolnay/rust-toolchain@nightly
- name: Lock minimal versions
# Update openssl-sys to not depend on the stale libssl-dev package.
run: |
cargo +nightly update -Zminimal-versions
cargo +nightly update -p openssl-sys -p openssl
- name: Install stable
id: install-stable-rust
uses: dtolnay/rust-toolchain@stable
- name: Restore cached build artifacts
uses: Swatinem/rust-cache@v2
with:
shared-key: ${{ runner.os }}-${{ steps.install-stable-rust.outputs.cachekey }}-${{ hashFiles('Cargo.lock') }}
- name: Run the check
env:
RUST_BACKTRACE: 1
# cannot check against all packages because min versions of [email protected] are broken
run: cargo +${{ steps.install-stable-rust.outputs.name }} check --package async-nats --locked --all-features --all-targets