From 3a720d293a0316f45b6d81efd073700eecf12d07 Mon Sep 17 00:00:00 2001 From: EdJoPaTo Date: Tue, 24 Oct 2023 19:09:08 +0200 Subject: [PATCH] ci(rust): improve workflow --- .github/workflows/coverage.yml | 10 ++--- .github/workflows/rust.yml | 81 ++++++++++++++++------------------ 2 files changed, 43 insertions(+), 48 deletions(-) diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 9aebd66..b022754 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -9,17 +9,17 @@ jobs: runs-on: ubuntu-latest steps: - name: Setup Rust - shell: bash -eux {0} - run: | - rustup toolchain install stable --profile minimal --component llvm-tools-preview - rustup default stable + uses: dtolnay/rust-toolchain@master + with: + toolchain: stable + components: llvm-tools-preview - name: Install cargo-llvm-cov uses: taiki-e/install-action@v2 with: tool: cargo-llvm-cov - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: actions/cache@v3 with: diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 6789b34..87da4f1 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -7,23 +7,25 @@ on: # Check if it works with current dependencies - cron: '42 2 * * 6' # weekly on Saturday 2:42 UTC +env: + RUSTFLAGS: --deny warnings + jobs: rustfmt: runs-on: ubuntu-latest steps: - name: Setup Rust - shell: bash -eux {0} - run: | - rm ~/.cargo/bin/{rustfmt,cargo-fmt} - rustup toolchain install stable --profile minimal --component rustfmt - rustup default stable - - uses: actions/checkout@v3 + uses: dtolnay/rust-toolchain@master + with: + toolchain: stable + components: rustfmt + - uses: actions/checkout@v4 - run: cargo fmt --check --verbose test: - name: Test ${{ matrix.toolchain }} ${{ matrix.os }} + name: Test ${{ matrix.toolchain }} ${{ matrix.os }} ${{ matrix.features }} runs-on: ${{ matrix.os }} - continue-on-error: ${{ matrix.toolchain == 'nightly' }} + continue-on-error: ${{ (matrix.toolchain == 'beta') || (matrix.toolchain == 'nightly') }} strategy: fail-fast: false matrix: @@ -34,51 +36,42 @@ jobs: - macos-latest - windows-latest clippyargs: - - -D clippy::pedantic -D warnings + - -D clippy::pedantic features: - - --all-features + - "" # default features include: # Check future versions and maybe get some glances on soon to be lints - toolchain: beta os: ubuntu-latest features: --all-features - clippyargs: -W clippy::pedantic -W clippy::nursery -W clippy::cargo + clippyargs: -D clippy::pedantic -D clippy::nursery -D clippy::cargo - toolchain: nightly os: ubuntu-latest features: --all-features - clippyargs: -W clippy::pedantic + clippyargs: -D clippy::pedantic steps: - name: Setup Rust - shell: bash -eux {0} - run: | - rustup toolchain install ${{ matrix.toolchain }} --profile minimal --component clippy - rustup default ${{ matrix.toolchain }} + uses: dtolnay/rust-toolchain@master + with: + toolchain: ${{ matrix.toolchain }} + components: clippy - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Fetch dependencies - uses: actions-rs/cargo@v1 - with: - command: fetch - args: --verbose + run: cargo fetch --verbose - name: Check clippy - uses: actions-rs/cargo@v1 - with: - command: clippy - args: --verbose --all-targets ${{ matrix.features }} -- ${{ matrix.clippyargs }} + run: cargo clippy --verbose --all-targets ${{ matrix.features }} -- ${{ matrix.clippyargs }} - name: Check docs - uses: actions-rs/cargo@v1 - with: - command: doc - args: --verbose --no-deps ${{ matrix.features }} + run: cargo doc --verbose --no-deps ${{ matrix.features }} + + - name: Build + run: cargo build --verbose --all-targets ${{ matrix.features }} - name: Run tests - uses: actions-rs/cargo@v1 - with: - command: test - args: --verbose ${{ matrix.features }} + run: cargo test --verbose ${{ matrix.features }} github-release: name: Release ${{ matrix.triple }} @@ -110,19 +103,21 @@ jobs: os: windows-latest steps: - name: Setup Rust - shell: bash -eux {0} - run: | - rustup toolchain install stable --profile minimal --target ${{ matrix.triple }} - rustup default stable + uses: dtolnay/rust-toolchain@master + with: + toolchain: stable + targets: ${{ matrix.triple }} - - uses: actions/checkout@v3 + - name: Install cargo tools + if: runner.os == 'Linux' + uses: taiki-e/install-action@v2 + with: + tool: cross + + - uses: actions/checkout@v4 - name: Fetch dependencies run: cargo fetch --verbose - name: Build - uses: actions-rs/cargo@v1 - with: - command: build - args: --release --verbose --all-features --target ${{ matrix.triple }} - use-cross: ${{ runner.os == 'Linux' }} + run: ${{ runner.os == 'Linux' && 'cross' || 'cargo' }} build --release --verbose --target ${{ matrix.triple }}