Skip to content

Commit f3df706

Browse files
authored
Improve CI (#1113)
- switch to `dtolnay/rust-toolchain` GitHub action - restore release Git tag format and correct `cargo-release` integration - enable MSRV check - integrate `cargo-careful`
1 parent 3a2254b commit f3df706

30 files changed

+233
-141
lines changed

.github/workflows/ci.yml

Lines changed: 110 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: CI
33
on:
44
push:
55
branches: ["master"]
6-
tags: ["juniper*@*"]
6+
tags: ["juniper*"]
77
pull_request:
88
branches: ["master"]
99

@@ -27,6 +27,7 @@ jobs:
2727
- clippy
2828
- example
2929
- feature
30+
- msrv
3031
- release-check
3132
- rustfmt
3233
- test
@@ -47,9 +48,8 @@ jobs:
4748
runs-on: ubuntu-latest
4849
steps:
4950
- uses: actions/checkout@v3
50-
- uses: actions-rs/toolchain@v1
51+
- uses: dtolnay/rust-toolchain@v1
5152
with:
52-
profile: minimal
5353
toolchain: stable
5454
components: clippy
5555

@@ -59,9 +59,8 @@ jobs:
5959
runs-on: ubuntu-latest
6060
steps:
6161
- uses: actions/checkout@v3
62-
- uses: actions-rs/toolchain@v1
62+
- uses: dtolnay/rust-toolchain@v1
6363
with:
64-
profile: minimal
6564
toolchain: nightly
6665
components: rustfmt
6766

@@ -78,11 +77,9 @@ jobs:
7877
runs-on: ubuntu-latest
7978
steps:
8079
- uses: actions/checkout@v3
81-
- uses: actions-rs/toolchain@v1
80+
- uses: dtolnay/rust-toolchain@v1
8281
with:
83-
profile: minimal
8482
toolchain: stable
85-
override: true
8683

8784
- run: cargo clippy -p juniper_benchmarks --benches -- -D warnings
8885
- run: cargo bench -p juniper_benchmarks
@@ -107,11 +104,10 @@ jobs:
107104
runs-on: ${{ matrix.os }}-latest
108105
steps:
109106
- uses: actions/checkout@v3
110-
- uses: actions-rs/toolchain@v1
107+
- uses: dtolnay/rust-toolchain@v1
111108
with:
112-
profile: minimal
113109
toolchain: ${{ matrix.toolchain }}
114-
override: true
110+
- run: rustup default ${{ matrix.toolchain }}
115111

116112
- run: cargo check -p example_${{ matrix.example }}
117113

@@ -141,14 +137,14 @@ jobs:
141137
runs-on: ubuntu-latest
142138
steps:
143139
- uses: actions/checkout@v3
144-
- uses: actions-rs/toolchain@v1
140+
- uses: dtolnay/rust-toolchain@v1
145141
with:
146-
profile: minimal
147142
toolchain: stable
148-
override: true
143+
- uses: dtolnay/rust-toolchain@v1
144+
with:
145+
toolchain: nightly
149146

150-
# TODO: Enable once MSRV is supported.
151-
#- run: cargo +nightly update -Z minimal-versions
147+
- run: cargo +nightly update -Z minimal-versions
152148

153149
- run: cargo check -p ${{ matrix.crate }} --no-default-features
154150
${{ matrix.feature != '<none>'
@@ -157,23 +153,58 @@ jobs:
157153
env:
158154
RUSTFLAGS: -D warnings
159155

156+
msrv:
157+
name: MSRV
158+
strategy:
159+
fail-fast: false
160+
matrix:
161+
msrv: ["1.62.0"]
162+
crate:
163+
- juniper_codegen
164+
- juniper
165+
- juniper_subscriptions
166+
- juniper_graphql_ws
167+
- juniper_actix
168+
- juniper_hyper
169+
#- juniper_iron
170+
- juniper_rocket
171+
- juniper_warp
172+
os:
173+
- ubuntu
174+
- macOS
175+
- windows
176+
runs-on: ${{ matrix.os }}-latest
177+
steps:
178+
- uses: actions/checkout@v3
179+
- uses: dtolnay/rust-toolchain@v1
180+
with:
181+
toolchain: ${{ matrix.msrv }}
182+
- run: rustup default ${{ matrix.msrv }}
183+
- uses: dtolnay/rust-toolchain@v1
184+
with:
185+
toolchain: nightly
186+
187+
- run: cargo +nightly update -Z minimal-versions
188+
189+
- run: make test.cargo crate=${{ matrix.crate }}
190+
160191
package:
161192
if: ${{ startsWith(github.ref, 'refs/tags/juniper') }}
162193
runs-on: ubuntu-latest
163194
steps:
164195
- uses: actions/checkout@v3
165-
- uses: actions-rs/toolchain@v1
196+
- uses: dtolnay/rust-toolchain@v1
166197
with:
167-
profile: minimal
168198
toolchain: stable
169199

170-
- name: Parse crate name
171-
id: crate
172-
run: echo ::set-output
173-
name=NAME::$(printf "$GITHUB_REF" | cut -d '/' -f3
174-
| cut -d '@' -f1)
200+
- name: Parse crate name and version from Git tag
201+
id: tag
202+
uses: actions-ecosystem/action-regex-match@v2
203+
with:
204+
text: ${{ github.ref }}
205+
regex: '^refs/tags/(([a-z_]+)-v([0-9]+\.[0-9]+\.[0-9]+(-.+)?))$'
175206

176-
- run: cargo package -p ${{ steps.crate.outputs.NAME }}
207+
- run: cargo package -p ${{ steps.tag.outputs.group2 }}
177208

178209
test:
179210
strategy:
@@ -211,13 +242,18 @@ jobs:
211242
runs-on: ${{ matrix.os }}-latest
212243
steps:
213244
- uses: actions/checkout@v3
214-
- uses: actions-rs/toolchain@v1
245+
- uses: dtolnay/rust-toolchain@v1
215246
with:
216-
profile: minimal
217247
toolchain: ${{ matrix.toolchain }}
218-
override: true
248+
components: rust-src
249+
- run: rustup default ${{ matrix.toolchain }}
250+
251+
- run: cargo install cargo-careful
252+
if: ${{ matrix.toolchain == 'nightly' }}
219253

220254
- run: make test.cargo crate=${{ matrix.crate }}
255+
careful=${{ (matrix.toolchain == 'nightly' && 'yes')
256+
|| 'no' }}
221257

222258
test-book:
223259
name: test Book
@@ -237,11 +273,10 @@ jobs:
237273
runs-on: ${{ matrix.os }}-latest
238274
steps:
239275
- uses: actions/checkout@v3
240-
- uses: actions-rs/toolchain@v1
276+
- uses: dtolnay/rust-toolchain@v1
241277
with:
242-
profile: minimal
243278
toolchain: ${{ matrix.toolchain }}
244-
override: true
279+
- run: rustup default ${{ matrix.toolchain }}
245280

246281
- run: cargo install mdbook
247282

@@ -261,12 +296,11 @@ jobs:
261296
runs-on: ubuntu-latest
262297
steps:
263298
- uses: actions/checkout@v3
264-
- uses: actions-rs/toolchain@v1
299+
- uses: dtolnay/rust-toolchain@v1
265300
with:
266-
profile: minimal
267301
toolchain: ${{ matrix.toolchain }}
268302
target: wasm32-unknown-unknown
269-
override: true
303+
- run: rustup default ${{ matrix.toolchain }}
270304

271305
- run: cargo check --target wasm32-unknown-unknown -p ${{ matrix.crate }}
272306

@@ -278,7 +312,7 @@ jobs:
278312
#############
279313

280314
release-check:
281-
name: Check release automation
315+
name: check release
282316
if: ${{ !startsWith(github.ref, 'refs/tags/juniper') }}
283317
strategy:
284318
fail-fast: false
@@ -296,23 +330,45 @@ jobs:
296330
runs-on: ubuntu-latest
297331
steps:
298332
- uses: actions/checkout@v3
299-
- uses: actions-rs/toolchain@v1
333+
- uses: dtolnay/rust-toolchain@v1
300334
with:
301-
profile: minimal
302335
toolchain: stable
303336

304337
- run: cargo install cargo-release
305338

306339
- run: make cargo.release crate=${{ matrix.crate }} ver=minor
307340
exec=no install=no
308341

342+
release-crate:
343+
name: release on crates.io
344+
needs: ["release-github"]
345+
if: ${{ startsWith(github.ref, 'refs/tags/juniper') }}
346+
runs-on: ubuntu-latest
347+
steps:
348+
- uses: actions/checkout@v3
349+
- uses: dtolnay/rust-toolchain@v1
350+
with:
351+
toolchain: stable
352+
353+
- name: Parse crate name and version from Git tag
354+
id: tag
355+
uses: actions-ecosystem/action-regex-match@v2
356+
with:
357+
text: ${{ github.ref }}
358+
regex: '^refs/tags/(([a-z_]+)-v([0-9]+\.[0-9]+\.[0-9]+(-.+)?))$'
359+
360+
- name: Publish `${{ steps.tag.outputs.group2 }}` crate
361+
run: cargo publish -p ${{ steps.tag.outputs.group2 }}
362+
--token ${{ secrets.CRATESIO_TOKEN }}
363+
309364
release-github:
310-
name: Release on GitHub
365+
name: release on GitHub
311366
needs:
312367
- bench
313368
- clippy
314369
- example
315370
- feature
371+
- msrv
316372
- package
317373
- rustfmt
318374
- test
@@ -323,56 +379,31 @@ jobs:
323379
steps:
324380
- uses: actions/checkout@v3
325381

326-
- name: Parse crate name
327-
id: crate
328-
run: echo ::set-output
329-
name=NAME::$(printf "$GITHUB_REF" | cut -d '/' -f3
330-
| cut -d '@' -f1)
331-
- name: Parse release version
332-
id: release
333-
run: echo ::set-output
334-
name=VERSION::$(printf "$GITHUB_REF" | cut -d '@' -f2)
335-
382+
- name: Parse crate name and version from Git tag
383+
id: tag
384+
uses: actions-ecosystem/action-regex-match@v2
385+
with:
386+
text: ${{ github.ref }}
387+
regex: '^refs/tags/(([a-z_]+)-v([0-9]+\.[0-9]+\.[0-9]+(-.+)?))$'
336388
- name: Verify release version matches crate's Cargo manifest
337-
run: >-
338-
test "${{ steps.release.outputs.VERSION }}" \
339-
== "$(grep -m1 'version = "' ${{ steps.crate.outputs.NAME }}/Cargo.toml | cut -d '"' -f2)"
389+
run: |
390+
test "${{ steps.tag.outputs.group3 }}" \
391+
== "$(grep -m1 'version = "' \
392+
${{ steps.tag.outputs.group2 }}/Cargo.toml \
393+
| cut -d '"' -f2)"
394+
340395
- name: Parse CHANGELOG link
341396
id: changelog
342397
run: echo ::set-output
343-
name=LINK::${{ github.server_url }}/${{ github.repository }}/blob/${{ steps.crate.outputs.NAME }}%40${{ steps.release.outputs.VERSION }}//${{ steps.crate.outputs.NAME }}/CHANGELOG.md#$(sed -n '/^## \[${{ steps.release.outputs.VERSION }}\]/{s/^## \[\(.*\)\][^0-9]*\([0-9].*\)/\1--\2/;s/[^0-9a-z-]*//g;p;}' ${{ steps.crate.outputs.NAME }}/CHANGELOG.md)
398+
name=link::${{ github.server_url }}/${{ github.repository }}/blob/${{ steps.tag.outputs.group1 }}/${{ steps.tag.outputs.group2 }}/CHANGELOG.md#$(sed -n '/^## \[${{ steps.tag.outputs.group3 }}\]/{s/^## \[\(.*\)\][^0-9]*\([0-9].*\)/\1--\2/;s/[^0-9a-z-]*//g;p;}' ${{ steps.tag.outputs.group2 }}/CHANGELOG.md)
344399

345400
- uses: softprops/action-gh-release@v1
346-
env:
347-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
348401
with:
349-
name: ${{ steps.crate.outputs.NAME }} ${{ steps.release.outputs.VERSION }}
402+
name: ${{ steps.tag.outputs.group2 }} ${{ steps.tag.outputs.group3 }}
350403
body: |
351-
[API docs](https://docs.rs/${{ steps.crate.outputs.NAME }}/${{ steps.release.outputs.VERSION }})
352-
[Changelog](${{ steps.changelog.outputs.LINK }})
353-
prerelease: ${{ contains(steps.release.outputs.VERSION, '-') }}
354-
355-
release-crate:
356-
name: Release on crates.io
357-
needs: ["release-github"]
358-
if: ${{ startsWith(github.ref, 'refs/tags/juniper') }}
359-
runs-on: ubuntu-latest
360-
steps:
361-
- uses: actions/checkout@v3
362-
- uses: actions-rs/toolchain@v1
363-
with:
364-
profile: minimal
365-
toolchain: stable
366-
367-
- name: Parse crate name
368-
id: crate
369-
run: echo ::set-output
370-
name=NAME::$(printf "$GITHUB_REF" | cut -d '/' -f3
371-
| cut -d '@' -f1)
372-
373-
- name: Publish crate
374-
run: cargo publish -p ${{ steps.crate.outputs.NAME }}
375-
--token ${{ secrets.CRATESIO_TOKEN }}
404+
[API docs](https://docs.rs/${{ steps.tag.outputs.group2 }}/${{ steps.tag.outputs.group3 }})
405+
[Changelog](${{ steps.changelog.outputs.link }})
406+
prerelease: ${{ contains(steps.tag.outputs.group3, '-') }}
376407

377408

378409

Makefile

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,21 @@ endif
100100
# Run Rust tests of project crates.
101101
#
102102
# Usage:
103-
# make test.cargo [crate=<crate-name>]
103+
# make test.cargo [crate=<crate-name>] [careful=(no|yes)]
104104

105105
test.cargo:
106-
cargo $(if $(call eq,$(crate),juniper_codegen_tests),+nightly,) test \
107-
$(if $(call eq,$(crate),),--workspace,-p $(crate)) --all-features
106+
ifeq ($(careful),yes)
107+
ifeq ($(shell cargo install --list | grep cargo-careful),)
108+
cargo install cargo-careful
109+
endif
110+
ifeq ($(shell rustup component list --toolchain=nightly \
111+
| grep 'rust-src (installed)'),)
112+
rustup component add --toolchain=nightly rust-src
113+
endif
114+
endif
115+
cargo $(if $(call eq,$(careful),yes),+nightly careful,\
116+
$(if $(call eq,$(crate),juniper_codegen_tests),+nightly,)) \
117+
test $(if $(call eq,$(crate),),--workspace,-p $(crate)) --all-features
108118

109119

110120

0 commit comments

Comments
 (0)