From 3602c57ec2dd71fb5ba7241e235777c05c2e0b04 Mon Sep 17 00:00:00 2001 From: daxpedda Date: Thu, 14 Dec 2023 14:46:20 +0100 Subject: [PATCH] Improve CI (#93) --- .github/workflows/audit.yml | 25 ++++++++------- .github/workflows/format.yml | 34 +++++++++++---------- .github/workflows/lint.yml | 24 ++++++++++----- .github/workflows/publish.yml | 15 +++++++-- .github/workflows/spellcheck.yml | 49 +++++++++++++++++++----------- .github/workflows/test.yml | 52 ++++++++++++++++++++------------ .github/workflows/validate.yml | 22 ++++++++++---- src/attr/item.rs | 4 +-- 8 files changed, 144 insertions(+), 81 deletions(-) diff --git a/.github/workflows/audit.yml b/.github/workflows/audit.yml index 7259de5..2c9278b 100644 --- a/.github/workflows/audit.yml +++ b/.github/workflows/audit.yml @@ -1,6 +1,16 @@ name: Audit -on: [push, pull_request] +on: + push: + branches: ["main"] + pull_request: + +concurrency: + group: ${{ github.workflow }}-${{ github.ref_name }} + cancel-in-progress: true + +env: + CARGO_TERM_COLOR: always jobs: audit: @@ -9,17 +19,10 @@ jobs: runs-on: ubuntu-latest steps: - - name: Cache cargo-audit - uses: actions/cache@v3 - with: - path: | - ~/.cargo/.crates.toml - ~/.cargo/.crates2.json - ~/.cargo/bin/cargo-audit - key: cargo-audit - - name: Install cargo-audit - run: cargo install cargo-audit - name: Checkout uses: actions/checkout@v4 + - uses: taiki-e/install-action@v2 + with: + tool: cargo-audit - name: Run Audit run: cargo audit -D warnings diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml index dda66ce..e5e16ad 100644 --- a/.github/workflows/format.yml +++ b/.github/workflows/format.yml @@ -1,6 +1,16 @@ name: Format -on: [push, pull_request] +on: + push: + branches: ["main"] + pull_request: + +concurrency: + group: ${{ github.workflow }}-${{ github.ref_name }} + cancel-in-progress: true + +env: + CARGO_TERM_COLOR: always jobs: rustfmt: @@ -9,15 +19,14 @@ jobs: runs-on: ubuntu-latest steps: - - name: Update Rust + - name: Checkout + uses: actions/checkout@v4 + - name: Install Rust nightly run: | rustup toolchain install nightly --profile minimal --component rustfmt --allow-downgrade rustup default nightly - - name: Checkout - uses: actions/checkout@v4 - name: Run Rustfmt - run: - cargo fmt --check + run: cargo fmt --check taplo: name: Taplo @@ -25,17 +34,10 @@ jobs: runs-on: ubuntu-latest steps: - - name: Cache Taplo - uses: actions/cache@v3 - with: - path: | - ~/.cargo/.crates.toml - ~/.cargo/.crates2.json - ~/.cargo/bin/taplo - key: taplo - - name: Install Taplo - run: cargo install taplo-cli - name: Checkout uses: actions/checkout@v4 + - uses: taiki-e/install-action@v2 + with: + tool: taplo-cli - name: Run Taplo run: taplo fmt --check diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index f7d4833..307df28 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -1,10 +1,22 @@ name: Lint -on: [push, pull_request] +on: + push: + branches: ["main"] + pull_request: + +concurrency: + group: ${{ github.workflow }}-${{ github.ref_name }} + cancel-in-progress: true + +env: + CARGO_TERM_COLOR: always jobs: clippy-rustdoc: - name: Clippy + Rustdoc + name: Clippy & Rustdoc + + runs-on: ubuntu-latest strategy: fail-fast: false @@ -33,15 +45,13 @@ jobs: - channel: nightly features: --all-features - runs-on: ubuntu-latest - steps: - - name: Update Rust + - name: Checkout + uses: actions/checkout@v4 + - name: Install Rust run: | rustup toolchain install ${{ matrix.channel }} --profile minimal --component clippy --allow-downgrade rustup default ${{ matrix.channel }} - - name: Checkout - uses: actions/checkout@v4 - name: Run Clippy run: cargo clippy --all-targets --workspace ${{ matrix.features }} -- -D warnings diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 6e61043..c3dbccd 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,6 +1,16 @@ name: Publish -on: [push, pull_request] +on: + push: + branches: ["main"] + pull_request: + +concurrency: + group: ${{ github.workflow }}-${{ github.ref_name }} + cancel-in-progress: true + +env: + CARGO_TERM_COLOR: always jobs: publish: @@ -12,5 +22,4 @@ jobs: - name: Checkout uses: actions/checkout@v4 - name: Test Publish - run: - cargo publish --dry-run + run: cargo publish --dry-run diff --git a/.github/workflows/spellcheck.yml b/.github/workflows/spellcheck.yml index 52f611e..ce82f5c 100644 --- a/.github/workflows/spellcheck.yml +++ b/.github/workflows/spellcheck.yml @@ -1,29 +1,44 @@ name: Spellcheck -on: [push, pull_request] +on: + push: + branches: ["main"] + pull_request: + +concurrency: + group: ${{ github.workflow }}-${{ github.ref_name }} + cancel-in-progress: true + +env: + CARGO_TERM_COLOR: always jobs: - rustfmt: + spellcheck: name: Spellcheck runs-on: ubuntu-latest steps: - - name: Cache cargo-spellcheck - uses: actions/cache@v3 - with: - path: | - ~/.cargo/.crates.toml - ~/.cargo/.crates2.json - ~/.cargo/bin/cargo-spellcheck - key: cargo-spellcheck - - name: Install libclang-dev - run: sudo apt-get install libclang-dev - - name: Install cargo-spellcheck - run: cargo install cargo-spellcheck --locked - name: Checkout uses: actions/checkout@v4 + - uses: taiki-e/install-action@v2 + with: + tool: cargo-spellcheck - name: Run Spellcheck - run: cargo spellcheck check -m 1 2>/dev/null - - name: Run Spellcheck on CHANGELOG.md - run: cargo spellcheck check -m 1 CHANGELOG.md 2>/dev/null + run: | + cargo spellcheck check -m 1 + cargo spellcheck check -m 1 CHANGELOG.md + + typos: + name: Typos + + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + - uses: taiki-e/install-action@v2 + with: + tool: typos-cli + - name: Run Typos + run: typos diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 929f2c3..b69fe44 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,10 +1,22 @@ name: Test -on: [push, pull_request] +on: + push: + branches: ["main"] + pull_request: + +concurrency: + group: ${{ github.workflow }}-${{ github.ref_name }} + cancel-in-progress: true + +env: + CARGO_TERM_COLOR: always jobs: build-test: - name: Build + Test + name: Build & Test + + runs-on: ubuntu-latest strategy: fail-fast: false @@ -21,6 +33,8 @@ jobs: - --features safe,zeroize - --features safe,zeroize-on-drop include: + - rust: 1.57.0 + msrv: true - rust: nightly features: --features nightly - rust: nightly @@ -32,17 +46,15 @@ jobs: - rust: nightly features: --all-features - runs-on: ubuntu-latest - steps: - - name: Update Rust + - name: Checkout + uses: actions/checkout@v4 + - name: Install Rust run: | rustup toolchain install ${{ matrix.rust }} --profile minimal --allow-downgrade rustup default ${{ matrix.rust }} - - name: Checkout - uses: actions/checkout@v4 - name: Pin `zeroize` for MSRV - if: matrix.rust == '1.57.0' + if: matrix.msrv run: cargo update -p zeroize --precise 1.6.0 - name: Build @@ -58,6 +70,8 @@ jobs: no-std-build: name: no_std Build + runs-on: ubuntu-latest + strategy: fail-fast: false matrix: @@ -73,6 +87,8 @@ jobs: - --features safe,zeroize - --features safe,zeroize-on-drop include: + - rust: 1.57.0 + msrv: true - rust: nightly features: --features nightly - rust: nightly @@ -84,17 +100,15 @@ jobs: - rust: nightly features: --all-features - runs-on: ubuntu-latest - steps: - - name: Update Rust + - name: Checkout + uses: actions/checkout@v4 + - name: Install Rust run: | rustup toolchain install ${{ matrix.rust }} --target thumbv6m-none-eabi --profile minimal --allow-downgrade rustup default ${{ matrix.rust }} - - name: Checkout - uses: actions/checkout@v4 - name: Pin `zeroize` for MSRV - if: matrix.rust == '1.57.0' + if: matrix.msrv run: cargo update -p zeroize --precise 1.6.0 - name: Build @@ -104,6 +118,8 @@ jobs: minimal-versions: name: Minimal Versions + runs-on: ubuntu-latest + strategy: fail-fast: false matrix: @@ -113,18 +129,16 @@ jobs: - version: stable features: safe,zeroize-on-drop - runs-on: ubuntu-latest - steps: - - name: Update Rust + - name: Checkout + uses: actions/checkout@v4 + - name: Install Rust run: | rustup toolchain install ${{ matrix.rust.version }} --profile minimal --allow-downgrade rustup default ${{ matrix.rust.version }} - name: Install nightly Rust run: rustup toolchain install nightly --profile minimal --allow-downgrade - - name: Checkout - uses: actions/checkout@v4 - name: Build working-directory: test-crates/minimal-versions run: | diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml index af40a15..4e07dc4 100644 --- a/.github/workflows/validate.yml +++ b/.github/workflows/validate.yml @@ -1,11 +1,23 @@ name: Validate -on: [push, pull_request] +on: + push: + branches: ["main"] + pull_request: + +concurrency: + group: ${{ github.workflow }}-${{ github.ref_name }} + cancel-in-progress: true + +env: + CARGO_TERM_COLOR: always jobs: miri: name: Miri + runs-on: ubuntu-latest + strategy: fail-fast: false matrix: @@ -13,15 +25,13 @@ jobs: - "" - --features nightly - runs-on: ubuntu-latest - steps: - - name: Update Rust + - name: Checkout + uses: actions/checkout@v4 + - name: Install Rust run: | rustup toolchain install nightly --profile minimal --component miri,rust-src --allow-downgrade rustup default nightly - - name: Checkout - uses: actions/checkout@v4 - name: Test run: cargo miri test --workspace ${{ matrix.features }} --all-targets --no-fail-fast diff --git a/src/attr/item.rs b/src/attr/item.rs index 5f003e5..e0b6d03 100644 --- a/src/attr/item.rs +++ b/src/attr/item.rs @@ -78,7 +78,7 @@ impl ItemAttr { .push(DeriveWhere::from_attr(span, data, attr)?), } } - // Anything list that isn't using `,` as seperator, is because we expect + // Anything list that isn't using `,` as separator, is because we expect // `A, B; C`. else { self_ @@ -198,7 +198,7 @@ impl DeriveWhere { // If we found a semi-colon, start parsing generics. if !input.is_empty() { - // `parse_teminated` parses everything left, which should end the + // `parse_terminated` parses everything left, which should end the // while-loop. // Not checking for duplicates here, as even Rust doesn't give a warning // for those: `where T: Clone, T: Clone` produces no error or warning.