Skip to content

Commit

Permalink
Improve CI pipeline (#233)
Browse files Browse the repository at this point in the history
- switch to `dtolnay/rust-toolchain` GitHub action
- use `cargo-careful` for nightly tests
  • Loading branch information
tyranron committed Oct 12, 2022
1 parent f81c556 commit e2c825e
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 33 deletions.
57 changes: 26 additions & 31 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
- uses: dtolnay/rust-toolchain@v1
with:
profile: minimal
toolchain: stable
components: clippy

Expand All @@ -57,9 +56,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
- uses: dtolnay/rust-toolchain@v1
with:
profile: minimal
toolchain: nightly
components: rustfmt

Expand All @@ -86,15 +84,12 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
- uses: dtolnay/rust-toolchain@v1
with:
profile: minimal
toolchain: nightly
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- uses: dtolnay/rust-toolchain@v1
with:
toolchain: nightly

- run: cargo +nightly update -Z minimal-versions

Expand All @@ -121,15 +116,13 @@ jobs:
runs-on: ${{ matrix.os }}-latest
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
- uses: dtolnay/rust-toolchain@v1
with:
profile: minimal
toolchain: nightly
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ matrix.msrv }}
override: true
- run: rustup default ${{ matrix.msrv }}
- uses: dtolnay/rust-toolchain@v1
with:
toolchain: nightly

- run: cargo +nightly update -Z minimal-versions

Expand All @@ -153,16 +146,21 @@ jobs:
runs-on: ${{ matrix.os }}-latest
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
- uses: dtolnay/rust-toolchain@v1
with:
profile: minimal
toolchain: ${{ matrix.toolchain }}
override: true
components: rust-src
- run: rustup default ${{ matrix.toolchain }}

- run: cargo install cargo-careful
if: ${{ matrix.toolchain == 'nightly' }}

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

test-book:
name: Test Book
name: test Book
strategy:
fail-fast: false
matrix:
Expand All @@ -173,9 +171,8 @@ jobs:
runs-on: ${{ matrix.os }}-latest
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
- uses: dtolnay/rust-toolchain@v1
with:
profile: minimal
toolchain: stable

- run: make test.book
Expand All @@ -197,9 +194,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
- uses: dtolnay/rust-toolchain@v1
with:
profile: minimal
toolchain: nightly

- run: make cargo.doc crate=${{ matrix.crate }}
Expand All @@ -214,15 +210,14 @@ jobs:
#############

release-crate:
name: Release on crates.io
name: release on crates.io
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
needs: ["release-github"]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
- uses: dtolnay/rust-toolchain@v1
with:
profile: minimal
toolchain: stable

- name: Publish `cucumber-codegen` crate
Expand All @@ -237,7 +232,7 @@ jobs:
--token ${{ secrets.CRATESIO_TOKEN }}

release-github:
name: Release on GitHub
name: release on GitHub
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
needs:
- clippy
Expand Down Expand Up @@ -285,7 +280,7 @@ jobs:
##########

deploy-book:
name: Deploy Book
name: deploy Book
if: ${{ github.ref == 'refs/heads/main'
|| startsWith(github.ref, 'refs/tags/v') }}
needs: ["test-book"]
Expand Down
14 changes: 12 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,20 @@ cargo.lint:
# Run Rust tests of project crates.
#
# Usage:
# make test.cargo [crate=<crate-name>]
# make test.cargo [crate=<crate-name>] [careful=(no|yes)]

test.cargo:
cargo test $(if $(call eq,$(crate),),--workspace,-p $(crate)) --all-features
ifeq ($(careful),yes)
ifeq ($(shell cargo install --list | grep cargo-careful),)
cargo install cargo-careful
endif
ifeq ($(shell rustup component list --toolchain=nightly \
| grep 'rust-src (installed)'),)
rustup component add --toolchain=nightly rust-src
endif
endif
cargo $(if $(call eq,$(careful),yes),+nightly careful,) test \
$(if $(call eq,$(crate),),--workspace,-p $(crate)) --all-features


# Run Rust tests of Book.
Expand Down

0 comments on commit e2c825e

Please sign in to comment.