From 332cc70f3e8604994fa565e547b26b320613eb79 Mon Sep 17 00:00:00 2001 From: LingMan Date: Wed, 15 Mar 2023 15:27:29 +0100 Subject: [PATCH 1/7] Only specify the major version of `actions/checkout` to use These tags are setup such that `v3` always points to the latest version of 3.x. Fixes the pointless PR spam by Dependabot. --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c717a20..320066c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,7 +19,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout sources - uses: actions/checkout@v3.2.0 + uses: actions/checkout@v3 - name: Install Rust toolchain uses: actions-rs/toolchain@v1 @@ -47,7 +47,7 @@ jobs: - nightly steps: - name: Checkout sources - uses: actions/checkout@v3.2.0 + uses: actions/checkout@v3 - name: Restore cargo cache uses: actions/cache@v3.2.1 From b987aa740388ed3e5d13cc7acf32046b873e3c97 Mon Sep 17 00:00:00 2001 From: LingMan Date: Wed, 15 Mar 2023 15:47:12 +0100 Subject: [PATCH 2/7] Use `Swatinem/rust-cache` instead of rolling our own caching Fixes Dependabot's PR spam of updates for `actions/cache` by only specifying the major version to use. --- .github/workflows/ci.yml | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 320066c..322ac71 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -49,18 +49,6 @@ jobs: - name: Checkout sources uses: actions/checkout@v3 - - name: Restore cargo cache - uses: actions/cache@v3.2.1 - env: - cache-name: ci - with: - path: | - ~/.cargo/registry - ~/.cargo/git - ~/.cargo/bin - target - key: ${{ matrix.os }}-${{ env.cache-name }}-${{ matrix.rust }}-${{ hashFiles('Cargo.lock') }} - - name: Install Rust toolchain uses: actions-rs/toolchain@v1 with: @@ -69,6 +57,9 @@ jobs: override: true components: clippy + - name: Restore cargo cache + uses: Swatinem/rust-cache@v2 + - name: Run lints uses: actions-rs/cargo@v1 with: From b58494e66391ffb718279214fb8d348d48688222 Mon Sep 17 00:00:00 2001 From: LingMan Date: Wed, 15 Mar 2023 16:34:10 +0100 Subject: [PATCH 3/7] Switch from `actions-rs/cargo` to plain cargo commands The entire `actions-rs` organization is unmaintained and the actions are starting to show their age. Fixes a few warnings about Node.js 12 and the `set-output` command being deprecated and scheduled for removal. While at it, use `--all-targets` instead of specifying each example to test individually. --- .github/workflows/ci.yml | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 322ac71..df24da1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -30,10 +30,7 @@ jobs: components: rustfmt - name: Check formatting - uses: actions-rs/cargo@v1 - with: - command: fmt - args: -- --check + run: cargo fmt --check build: name: Lint and test check @@ -61,13 +58,7 @@ jobs: uses: Swatinem/rust-cache@v2 - name: Run lints - uses: actions-rs/cargo@v1 - with: - command: clippy - args: -- -D warnings + run: cargo clippy -- -D warnings - name: Run tests - uses: actions-rs/cargo@v1 - with: - command: test - args: --all-features --example all_xterm_colors --example colors --example dyn_colors --example override --example custom_colors --example extra_colors --example supports_color + run: cargo test --all-features --all-targets From eb6f5fa9068322607e22da8c323dae3abf33b435 Mon Sep 17 00:00:00 2001 From: LingMan Date: Wed, 15 Mar 2023 16:35:18 +0100 Subject: [PATCH 4/7] Switch from `actions-rs/toolchain` to `dtolnay/rust-toolchain` The entire `actions-rs` organization is unmaintained and the actions are starting to show their age. Fixes the remaining warnings about Node.js 12 and the `set-output` command being deprecated and scheduled for removal. While at it, check the formatting with Rust stable instead of Rust nightly. --- .github/workflows/ci.yml | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index df24da1..563156d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,11 +22,8 @@ jobs: uses: actions/checkout@v3 - name: Install Rust toolchain - uses: actions-rs/toolchain@v1 + uses: dtolnay/rust-toolchain@stable with: - profile: minimal - toolchain: nightly - override: true components: rustfmt - name: Check formatting @@ -47,11 +44,9 @@ jobs: uses: actions/checkout@v3 - name: Install Rust toolchain - uses: actions-rs/toolchain@v1 + uses: dtolnay/rust-toolchain@master with: - profile: minimal toolchain: ${{ matrix.rust }} - override: true components: clippy - name: Restore cargo cache From ddf47f342f5eb95565f0514b8891ab610101ae47 Mon Sep 17 00:00:00 2001 From: LingMan Date: Wed, 15 Mar 2023 16:43:36 +0100 Subject: [PATCH 5/7] Run CI on macOS and Windows in addition to Ubuntu --- .github/workflows/ci.yml | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 563156d..895fb19 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -31,14 +31,12 @@ jobs: build: name: Lint and test check - runs-on: ubuntu-latest strategy: fail-fast: false matrix: - rust: - - 1.51.0 - - stable - - nightly + rust: ["1.51.0", "stable", "nightly"] + os: ["ubuntu-latest", "windows-latest", "macos-latest"] + runs-on: ${{ matrix.os }} steps: - name: Checkout sources uses: actions/checkout@v3 From dc9281e69ddacf1d19b531f8cece8f3ce8576188 Mon Sep 17 00:00:00 2001 From: LingMan Date: Wed, 15 Mar 2023 17:03:30 +0100 Subject: [PATCH 6/7] Add a test with `--no-default-features` Ensures everything still compiles even with all features disabled. --- .github/workflows/ci.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 895fb19..03be9ee 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -54,4 +54,6 @@ jobs: run: cargo clippy -- -D warnings - name: Run tests - run: cargo test --all-features --all-targets + run: | + cargo test --all-targets --all-features + cargo test --all-targets --no-default-features From 8d3bdf6e386ad7879c1a16932ca64ca6985fa6e7 Mon Sep 17 00:00:00 2001 From: LingMan Date: Wed, 15 Mar 2023 17:08:46 +0100 Subject: [PATCH 7/7] Run CI on changes to any file except for the readme Currently CI is only run on changes to specific files. While the list is currently complete, it is prone to get outdated. Turn this whitelist into a blacklist that only excluded `README.md` from CI. --- .github/workflows/ci.yml | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 03be9ee..4d6c926 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,11 +7,8 @@ on: pull_request: branches: - master - paths: - - "**.rs" - - "Cargo.toml" - - "Cargo.lock" - - ".github/workflows/*" + paths-ignore: + - "README.md" jobs: fmt: