Refactor into try_test + syn::Result #47
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Copyright (C) 2022-2023 Daniel Mueller <deso@posteo.net> | |
# SPDX-License-Identifier: (Apache-2.0 OR MIT) | |
name: Test | |
on: | |
pull_request: | |
push: | |
workflow_call: | |
env: | |
CARGO_TERM_COLOR: always | |
RUST_BACKTRACE: 1 | |
jobs: | |
test: | |
name: Build and test [${{ matrix.rust }}, ${{ matrix.profile }}] | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
rust: [stable] | |
profile: [dev, release] | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: ${{ matrix.rust }} | |
profile: minimal | |
override: true | |
- if: ${{ matrix.profile == 'dev' }} | |
name: Build & test dev | |
run: | | |
cargo build | |
cargo build --all-features | |
cargo test | |
# We need to duplicate the logic here, because up to 1.56 Cargo | |
# considers the --profile option unstable. Once our minimum | |
# supported Rust version is above that, we should remove the above | |
# block. | |
- if: ${{ matrix.rust == 'stable' && matrix.profile != 'dev'}} | |
name: Build & test release | |
run: | | |
cargo build --profile=${{ matrix.profile }} | |
cargo build --all-features --profile=${{ matrix.profile }} | |
cargo test --profile=${{ matrix.profile }} | |
build-minimum: | |
name: Build using minimum versions of dependencies | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Install Nightly Rust | |
uses: actions-rs/toolchain@v1 | |
with: | |
profile: minimal | |
toolchain: nightly | |
- run: cargo +nightly -Z minimal-versions update | |
- name: Install minimum Rust | |
uses: actions-rs/toolchain@v1 | |
with: | |
profile: minimal | |
# Please adjust README and rust-version field in Cargo.toml files when | |
# bumping version. | |
toolchain: 1.56 | |
default: true | |
- uses: Swatinem/rust-cache@v2 | |
- name: Build | |
run: cargo build --locked --all-features | |
rustfmt: | |
name: Check code formatting | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: nightly | |
components: rustfmt | |
override: true | |
- run: cargo +nightly fmt -- --check | |
clippy: | |
name: Lint with clippy | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: stable | |
components: clippy | |
override: true | |
- run: cargo clippy --no-deps --all-targets --all-features -- -A unknown_lints -D warnings | |
rustdoc: | |
name: Generate documentation | |
runs-on: ubuntu-latest | |
env: | |
RUSTDOCFLAGS: '-D warnings -D rustdoc::broken_intra_doc_links' | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: stable | |
override: true | |
- run: cargo doc --no-deps |