Test on min rust version and nightly #42
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
name: CI | |
on: | |
push: | |
branches: [ "main" ] | |
pull_request: | |
branches: [ "main" ] | |
env: | |
CARGO_TERM_COLOR: always | |
RUSTFLAGS: -Dwarnings | |
jobs: | |
pre-build: | |
name: Pre-Build | |
runs-on: ubuntu-latest | |
outputs: | |
rust-version: ${{ steps.rust-version.outputs.rust-version }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Determine Rust Version | |
id: rust-version | |
run: | | |
rust_version=$(cargo metadata --format-version 1 --no-deps | jq -r '.packages[] | select(.name == "terminal-trx") | .rust_version') | |
echo "rust-version=$rust_version" >> "$GITHUB_OUTPUT" | |
build: | |
needs: pre-build | |
name: ${{ format('Build ({0})', matrix.rust-version) }} | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
rust-version: ['${{needs.pre-build.outputs.rust-version}}', stable, nightly] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Use Rust ${{matrix.rust-version}} | |
if: matrix.rust-version != 'stable' | |
run: rustup override set '${{matrix.rust-version}}' | |
- name: Ensure rustfmt is installed | |
run: rustup component add rustfmt | |
if: matrix.rust-version != 'stable' | |
- name: Build | |
run: cargo build --all-features | |
- name: Check fallback implementation | |
run: cargo check --workspace --features __test_unsupported | |
- name: Docs | |
run: cargo doc --all-features | |
lint: | |
runs-on: ubuntu-latest | |
name: Lint | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Check format | |
run: cargo fmt -- --check | |
- name: Run clippy | |
run: cargo clippy --workspace --all-targets --all-features -- --deny warnings | |
test: | |
name: Test | |
strategy: | |
matrix: | |
os: [ubuntu-latest, macos-latest, windows-latest] | |
runs-on: ${{ matrix.os }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Run tests | |
run: cargo test --workspace --all-features |