Skip to content

Commit 5affbae

Browse files
committed
Refactor CI actions, add separate jobs for cargo test and cargo check
Gets rid of separate jobs for nightly and MSRV
1 parent 8a7a817 commit 5affbae

File tree

1 file changed

+38
-70
lines changed

1 file changed

+38
-70
lines changed

.github/workflows/ci.yml

Lines changed: 38 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -17,24 +17,27 @@ jobs:
1717
name:
1818
- stable
1919
- beta
20-
# The build matrix doesn't support the `env` variable in expressions
21-
# see: jobs.nightly
22-
# - nightly
20+
- nightly
2321
- Windows
22+
- macOS
2423
- native-tls
2524
- no default features
2625
- no cache
2726
- no gateway
28-
- unstable Discord API features
27+
- chrono
2928
- zlib compression
3029
- zstd compression
3130
- zlib and zstd compression
3231

3332
include:
3433
- name: beta
3534
toolchain: beta
35+
- name: nightly
36+
toolchain: nightly
3637
- name: Windows
3738
os: windows-latest
39+
- name: macOS
40+
os: macos-latest
3841
- name: native-tls
3942
features: default_native_tls
4043
- name: no default features
@@ -45,15 +48,6 @@ jobs:
4548
features: model rustls_backend
4649
- name: chrono
4750
features: chrono
48-
- name: unstable API + typesize
49-
features: default unstable typesize
50-
dont-test: true
51-
- name: builder without model
52-
features: builder
53-
dont-test: true
54-
- name: unstable Discord API (no default features)
55-
features: unstable
56-
dont-test: true
5751
- name: zlib compression
5852
features: default transport_compression_zlib
5953
- name: zstd compression
@@ -68,60 +62,40 @@ jobs:
6862
- name: Install toolchain
6963
uses: dtolnay/rust-toolchain@master
7064
with:
71-
toolchain: ${{ matrix.toolchain || 'stable' }}
65+
toolchain: ${{
66+
(matrix.toolchain == 'nightly' && env.rust_nightly)
67+
|| matrix.toolchain
68+
|| 'stable'
69+
}}
7270

7371
- name: Add problem matchers
74-
shell: bash
7572
run: echo "::add-matcher::.github/matchers/rust.json"
7673

7774
- name: Cache
7875
uses: Swatinem/rust-cache@v2
7976

80-
- name: Build all features
81-
if: matrix.features == ''
82-
run: cargo build --features full
83-
84-
- name: Test all features
85-
if: matrix.features == ''
86-
run: cargo test --features full
77+
- name: Run tests
78+
run: cargo test --no-default-features --features "${{ matrix.features || 'full' }}"
8779

88-
- name: Build some features
89-
if: matrix.features
90-
run: cargo build --no-default-features --features "${{ matrix.features }}"
91-
92-
- name: Test some features
93-
if: ${{ !matrix.dont-test && matrix.features }}
94-
run: cargo test --no-default-features --features "${{ matrix.features }}"
95-
96-
nightly:
97-
name: Test (nightly)
80+
check:
81+
name: Check
9882
runs-on: ubuntu-latest
9983

100-
steps:
101-
- name: Checkout sources
102-
uses: actions/checkout@v4
103-
104-
- name: Install toolchain (${{ env.rust_nightly }})
105-
uses: dtolnay/rust-toolchain@master
106-
with:
107-
toolchain: ${{ env.rust_nightly }}
108-
109-
- name: Add problem matchers
110-
shell: bash
111-
run: echo "::add-matcher::.github/matchers/rust.json"
112-
113-
- name: Cache
114-
uses: Swatinem/rust-cache@v2
115-
116-
- name: Build all features
117-
run: cargo build --features full
118-
119-
- name: Test all features
120-
run: cargo test --features full
84+
strategy:
85+
fail-fast: false
86+
matrix:
87+
name:
88+
- builder without model
89+
- unstable + typesize
90+
- unstable (no default features)
12191

122-
macOS:
123-
name: Test (macOS)
124-
runs-on: macos-latest
92+
include:
93+
- name: builder without model
94+
features: builder
95+
- name: unstable + typesize
96+
features: default unstable typesize
97+
- name: unstable (no default features)
98+
features: unstable
12599

126100
steps:
127101
- name: Checkout sources
@@ -131,24 +105,20 @@ jobs:
131105
uses: dtolnay/rust-toolchain@stable
132106

133107
- name: Add problem matchers
134-
shell: bash
135108
run: echo "::add-matcher::.github/matchers/rust.json"
136109

137110
- name: Cache
138111
uses: Swatinem/rust-cache@v2
139112

140-
- name: Build
141-
run: cargo build
142-
143-
- name: Test
144-
run: cargo test
113+
- name: Run checks
114+
run: cargo check --no-default-features --features "${{ matrix.features || 'full' }}"
145115

146116
MSRV:
147117
runs-on: ubuntu-latest
148118

149119
# We only run this job on the current branch as keeping MSRV the same is not important on next.
150120
if: (github.event_name == 'push' && github.ref_name == 'current') ||
151-
(github.event_name == 'pull_request' && github.base_ref == 'current')
121+
(github.event_name == 'pull_request' && github.base_ref == 'current')
152122

153123
steps:
154124
- name: Checkout sources
@@ -165,7 +135,7 @@ jobs:
165135
- name: Cache
166136
uses: Swatinem/rust-cache@v2
167137

168-
- name: Check
138+
- name: Run checks
169139
run: cargo check --features full
170140

171141
min_versions:
@@ -200,10 +170,8 @@ jobs:
200170
- name: Checkout sources
201171
uses: actions/checkout@v4
202172

203-
- name: Install toolchain (${{ env.rust_nightly }})
204-
uses: dtolnay/rust-toolchain@master
205-
with:
206-
toolchain: ${{ env.rust_nightly }}
173+
- name: Install toolchain
174+
uses: dtolnay/rust-toolchain@stable
207175

208176
- name: Add problem matchers
209177
run: echo "::add-matcher::.github/matchers/rust.json"
@@ -214,8 +182,6 @@ jobs:
214182
- name: Build docs
215183
run: |
216184
cargo doc --no-deps --features full,unstable
217-
env:
218-
RUSTDOCFLAGS: -D rustdoc::broken_intra_doc_links
219185
220186
examples:
221187
name: Examples
@@ -266,3 +232,5 @@ jobs:
266232
run: cargo check -p e15_webhook
267233
- name: 'Check example 16'
268234
run: cargo check -p e16_interactions_endpoint
235+
- name: 'Check testing example'
236+
run: cargo check -p testing

0 commit comments

Comments
 (0)