From 1f541c5b0511767c1f4e99e94906a0b0f6da1000 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 1 Oct 2023 07:14:31 +0000 Subject: [PATCH 01/38] Bump actions/checkout from 3 to 4 Bumps [actions/checkout](https://github.com/actions/checkout) from 3 to 4. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/v3...v4) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/autotag-releases.yml | 2 +- .github/workflows/ci.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/autotag-releases.yml b/.github/workflows/autotag-releases.yml index 44fbd19..4ca4ad5 100644 --- a/.github/workflows/autotag-releases.yml +++ b/.github/workflows/autotag-releases.yml @@ -15,7 +15,7 @@ jobs: permissions: contents: write steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Get version from tag id: tag_name run: | diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ee6fda8..0686e3f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -29,7 +29,7 @@ jobs: "macos-latest", ] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 # Test toolchain file support - name: Write rust-toolchain.toml run: | From 317ed623239815a7546843702818759c90ad2cf9 Mon Sep 17 00:00:00 2001 From: Jonas Bushart Date: Tue, 3 Oct 2023 18:55:16 +0200 Subject: [PATCH 02/38] Update example workflow in readme --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 517e0d4..0f0b076 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ jobs: name: cargo test runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: actions-rust-lang/setup-rust-toolchain@v1 - run: cargo test --all-features @@ -30,7 +30,7 @@ jobs: name: cargo fmt runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 # Ensure rustfmt is installed and setup problem matcher - uses: actions-rust-lang/setup-rust-toolchain@v1 with: From 33678a48c023ee5045cc1fc63ed0b9552de0c8f8 Mon Sep 17 00:00:00 2001 From: Predrag Gruevski <2348618+obi1kenobi@users.noreply.github.com> Date: Tue, 17 Oct 2023 22:01:06 -0400 Subject: [PATCH 03/38] Add docs for the `cachekey` output to the README It seems like it's being output, just wasn't documented: https://github.com/actions-rust-lang/setup-rust-toolchain/blob/main/action.yml#L144 --- README.md | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 0f0b076..e9f8ae3 100644 --- a/README.md +++ b/README.md @@ -71,11 +71,12 @@ You can read more rustflags, and their load order, in the [Cargo reference]. ## Outputs -| Name | Description | -| ---------------- | ----------------------------------------- | -| `rustc-version` | Version as reported by `rustc --version` | -| `cargo-version` | Version as reported by `cargo --version` | -| `rustup-version` | Version as reported by `rustup --version` | +| Name | Description | +| ---------------- | ------------------------------------------- | +| `rustc-version` | Version as reported by `rustc --version` | +| `cargo-version` | Version as reported by `cargo --version` | +| `rustup-version` | Version as reported by `rustup --version` | +| `cachekey` | A short hash of the installed rustc version | ## License From 5ea736b97fc063cda4289a5e2683b75dbffa51ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?James=20=E2=80=98Twey=E2=80=99=20Kay?= Date: Tue, 31 Oct 2023 12:58:53 +0000 Subject: [PATCH 04/38] Allow overriding the toolchain file --- README.md | 6 ++++-- action.yml | 14 +++++++++----- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 0f0b076..a8b9362 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions-rust-lang/setup-rust-toolchain@v1 - run: cargo test --all-features - + # Check formatting with rustfmt formatting: name: cargo fmt @@ -42,7 +42,9 @@ jobs: ## Inputs All inputs are optional. -If a [toolchain file](https://rust-lang.github.io/rustup/overrides.html#the-toolchain-file) (i.e., `rust-toolchain` or `rust-toolchain.toml`) is found in the root of the repository, its `toolchain` value takes precedence. +If a [toolchain file](https://rust-lang.github.io/rustup/overrides.html#the-toolchain-file) (i.e., `rust-toolchain` or `rust-toolchain.toml`) is found in the root of the repository and no `toolchain` value is provided, all items specified in the toolchain file will be installed. +If a `toolchain` value is provided, the toolchain file will be ignored. +If no `toolchain` value or toolchain file is present, it will default to `stable`. First, all items specified in the toolchain file are installed. Afterward, the `components` and `target` specified via inputs are installed in addition to the items from the toolchain file. diff --git a/action.yml b/action.yml index 5f0639e..4d1b869 100644 --- a/action.yml +++ b/action.yml @@ -15,7 +15,6 @@ inputs: toolchain: description: "Rust toolchain specification -- see https://rust-lang.github.io/rustup/concepts/toolchains.html#toolchain-specification" required: false - default: "stable" target: description: "Target triple to install for this toolchain" required: false @@ -107,9 +106,9 @@ runs: fi if: runner.os != 'Windows' shell: bash - - name: rustup toolchain install ${{inputs.toolchain}} + - name: rustup toolchain install ${{inputs.toolchain || 'stable'}} run: | - if [[ -f "rust-toolchain" || -f "rust-toolchain.toml" ]] + if [[ -z "$toolchain" && ( -f "rust-toolchain" || -f "rust-toolchain.toml" ) ]] then # Install the toolchain as specified in the file # Might break at some point: https://github.com/rust-lang/rustup/issues/1397 @@ -121,10 +120,15 @@ runs: rustup target add ${targets//,/ } fi else - rustup toolchain install ${{inputs.toolchain}}${{steps.flags.outputs.targets}}${{steps.flags.outputs.components}} --profile minimal${{steps.flags.outputs.downgrade}} --no-self-update - rustup default ${{inputs.toolchain}} + if [[ -z "$toolchain" ]] + then + toolchain=stable + fi + rustup toolchain install $toolchain${{steps.flags.outputs.targets}}${{steps.flags.outputs.components}} --profile minimal${{steps.flags.outputs.downgrade}} --no-self-update + rustup default $toolchain fi env: + toolchain: ${{inputs.toolchain}} targets: ${{inputs.target}} components: ${{inputs.components}} shell: bash From 6ed642995199ca03998311122b0eb2782eb30e1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?James=20=E2=80=98Twey=E2=80=99=20Kay?= Date: Wed, 1 Nov 2023 09:44:05 +0000 Subject: [PATCH 05/38] Use the empty string to trigger toolchain file check instead of an old version --- .github/workflows/ci.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0686e3f..72c5e88 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,4 +1,3 @@ - name: CI on: @@ -15,7 +14,7 @@ jobs: matrix: rust: [ # Test with toolchain file override - "1.60", + "", # Test that the sparse registry check works. # 1.66 and 1.67 don't support stable sparse registry. "1.66", @@ -41,10 +40,10 @@ jobs: profile = "minimal" EOF shell: bash - if: matrix.rust == '1.60' + if: matrix.rust == '' - uses: ./ - name: Run actions-rust-lang/setup-rust-toolchain ${{matrix.rust}} + name: Run actions-rust-lang/setup-rust-toolchain ${{matrix.rust || 'on toolchain file'}} id: toolchain with: toolchain: ${{matrix.rust}} From 51173b3da485cd71e24a9acbcbe2549aa16fa0b6 Mon Sep 17 00:00:00 2001 From: dcvz Date: Thu, 30 Nov 2023 11:42:45 +0100 Subject: [PATCH 06/38] feature(matcher): allow disabling problem matcher --- action.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/action.yml b/action.yml index 5f0639e..500341b 100644 --- a/action.yml +++ b/action.yml @@ -26,6 +26,10 @@ inputs: description: "Automatically configure Rust cache" required: false default: "true" + matcher: + description: "Enable the Rust problem matcher" + required: false + default: "true" rustflags: description: "set RUSTFLAGS environment variable, set to empty string to avoid overwriting build.rustflags" required: false @@ -96,6 +100,7 @@ runs: env: NEW_RUSTFLAGS: ${{inputs.rustflags}} - name: "Install Rust Problem Matcher" + if: inputs.matcher == 'true' run: echo "::add-matcher::${{ github.action_path }}/rust.json" shell: bash From 84ba0c9d1bc8c24a783b6fd3fd94b68b3d3e9909 Mon Sep 17 00:00:00 2001 From: dcvz Date: Thu, 30 Nov 2023 11:45:35 +0100 Subject: [PATCH 07/38] Update README --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 0f0b076..3254707 100644 --- a/README.md +++ b/README.md @@ -52,6 +52,7 @@ Afterward, the `components` and `target` specified via inputs are installed in a | `target` | Additional target support to install e.g. `wasm32-unknown-unknown` | | | `components` | Comma-separated string of additional components to install e.g. `clippy, rustfmt` | | | `cache` | Automatically configure Rust cache (using `Swatinem/rust-cache`) | true | +| `matcher` | Enable problem matcher to surface build messages and formatting issues | true | | `rustflags` | Set the value of `RUSTFLAGS` (set to empty string to avoid overwriting existing flags) | "-D warnings" | ### RUSTFLAGS From c7e1de28469b16b21a170a200a7a9e810bb5cdff Mon Sep 17 00:00:00 2001 From: Jonas Bushart Date: Mon, 4 Dec 2023 00:16:34 +0100 Subject: [PATCH 08/38] Update CHANGELOG.md --- CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0375f7e..5e580c5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [1.6.0] - 2023-12-04 + +### Added + +* Allow disabling problem matchers (#27) + This can be useful when having a matrix of jobs, that produce the same errors. + ## [1.5.0] - 2023-05-29 ### Added From 962ed5edf06081797ba8b276d7fa8851e3802e5e Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Thu, 11 Jan 2024 02:20:44 +0000 Subject: [PATCH 09/38] ci: add indicate toolchain file in job name --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 72c5e88..cfe06b1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,7 +7,7 @@ on: jobs: install: - name: Rust ${{matrix.rust}} ${{matrix.os}} + name: Rust ${{matrix.rust || '(toolchain file)'}} ${{matrix.os}} runs-on: ${{matrix.os}} strategy: fail-fast: false From af702488e5188dac18561996f3c92e522ac3c286 Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Thu, 11 Jan 2024 03:01:31 +0000 Subject: [PATCH 10/38] ci: update checked rust-toolchain version --- .github/workflows/ci.yml | 47 +++++++++++++++++++++++----------------- CHANGELOG.md | 2 ++ action.yml | 47 +++++++++++++++++++++------------------- 3 files changed, 54 insertions(+), 42 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cfe06b1..521e3f6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,7 +1,7 @@ name: CI on: - push: + push: { branches: [main] } pull_request: schedule: [cron: "40 1 * * *"] @@ -12,54 +12,61 @@ jobs: strategy: fail-fast: false matrix: - rust: [ + rust: # Test with toolchain file override - "", + - null + # Test that the sparse registry check works. # 1.66 and 1.67 don't support stable sparse registry. - "1.66", - "nightly", - "beta", - "stable", - ] - os: [ - "ubuntu-latest", - "windows-latest", - "macos-latest", - ] + - "1.66" + + - "nightly" + - "beta" + - "stable" + os: + - ubuntu-latest + - windows-latest + - macos-latest steps: - uses: actions/checkout@v4 + # Test toolchain file support - name: Write rust-toolchain.toml + if: matrix.rust == null + shell: bash run: | cat <>rust-toolchain.toml [toolchain] - channel = "nightly-2022-09-10" + channel = "nightly-2024-01-11" components = [ "rustfmt", "rustc-dev" ] targets = [ "wasm32-unknown-unknown", "thumbv7m-none-eabi" ] profile = "minimal" EOF - shell: bash - if: matrix.rust == '' - - uses: ./ + - id: toolchain name: Run actions-rust-lang/setup-rust-toolchain ${{matrix.rust || 'on toolchain file'}} - id: toolchain + uses: ./ with: toolchain: ${{matrix.rust}} components: clippy + - name: Check ${{'${{steps.toolchain.outputs.rustc-version}}'}} run: echo '${{steps.toolchain.outputs.rustc-version}}' + - name: Check ${{'${{steps.toolchain.outputs.cargo-version}}'}} run: echo '${{steps.toolchain.outputs.cargo-version}}' + - name: Check ${{'${{steps.toolchain.outputs.rustup-version}}'}} run: echo '${{steps.toolchain.outputs.rustup-version}}' - - run: rustc --version && cargo --version - shell: bash + + - shell: bash + run: rustc --version && cargo --version # Test with creating a small project - run: cargo init . --bin --name ci + # Add tiny empty crate. # This checks that registry access works. - run: cargo add serde_as + - run: cargo clippy diff --git a/CHANGELOG.md b/CHANGELOG.md index 5e580c5..7a49699 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +* Allow overriding the toolchain file with explicit `toolchain` input. (#26) + ## [1.6.0] - 2023-12-04 ### Added diff --git a/action.yml b/action.yml index 2331188..45eda54 100644 --- a/action.yml +++ b/action.yml @@ -59,17 +59,21 @@ runs: shell: bash - id: flags + env: + targets: ${{inputs.target}} + components: ${{inputs.components}} + shell: bash run: | : construct rustup command line echo "targets=$(for t in ${targets//,/ }; do echo -n ' --target' $t; done)" >> $GITHUB_OUTPUT echo "components=$(for c in ${components//,/ }; do echo -n ' --component' $c; done)" >> $GITHUB_OUTPUT echo "downgrade=${{inputs.toolchain == 'nightly' && inputs.components && ' --allow-downgrade' || ''}}" >> $GITHUB_OUTPUT + + # The environment variables always need to be set before the caching action + - name: Setting Environment Variables env: - targets: ${{inputs.target}} - components: ${{inputs.components}} + NEW_RUSTFLAGS: ${{inputs.rustflags}} shell: bash - # The environment variables always need to be set before the caching action - - name: "Setting Environment Variables" run: | if [[ ! -v CARGO_INCREMENTAL ]]; then echo "CARGO_INCREMENTAL=0" >> $GITHUB_ENV @@ -95,23 +99,27 @@ runs: if [[ ! -v CARGO_REGISTRIES_CRATES_IO_PROTOCOL ]]; then echo "CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse" >> $GITHUB_ENV fi - shell: bash - env: - NEW_RUSTFLAGS: ${{inputs.rustflags}} - - name: "Install Rust Problem Matcher" + + - name: Install Rust Problem Matcher if: inputs.matcher == 'true' - run: echo "::add-matcher::${{ github.action_path }}/rust.json" shell: bash + run: echo "::add-matcher::${{ github.action_path }}/rust.json" - name: Install rustup, if needed + if: runner.os != 'Windows' + shell: bash run: | if ! command -v rustup &> /dev/null ; then curl --proto '=https' --tlsv1.2 --retry 10 --retry-connrefused -fsSL "https://sh.rustup.rs" | sh -s -- --default-toolchain none -y echo "${CARGO_HOME:-$HOME/.cargo}/bin" >> $GITHUB_PATH fi - if: runner.os != 'Windows' - shell: bash + - name: rustup toolchain install ${{inputs.toolchain || 'stable'}} + env: + toolchain: ${{inputs.toolchain}} + targets: ${{inputs.target}} + components: ${{inputs.components}} + shell: bash run: | if [[ -z "$toolchain" && ( -f "rust-toolchain" || -f "rust-toolchain.toml" ) ]] then @@ -132,14 +140,10 @@ runs: rustup toolchain install $toolchain${{steps.flags.outputs.targets}}${{steps.flags.outputs.components}} --profile minimal${{steps.flags.outputs.downgrade}} --no-self-update rustup default $toolchain fi - env: - toolchain: ${{inputs.toolchain}} - targets: ${{inputs.target}} - components: ${{inputs.components}} - shell: bash - - name: Print installed versions - id: versions + - id: versions + name: Print installed versions + shell: bash run: | echo "rustc-version=$(rustc --version)" >> $GITHUB_OUTPUT rustc --version --verbose @@ -151,9 +155,9 @@ runs: DATE=$(rustc --version --verbose | sed -ne 's/^commit-date: \(20[0-9][0-9]\)-\([01][0-9]\)-\([0-3][0-9]\)$/\1\2\3/p') HASH=$(rustc --version --verbose | sed -ne 's/^commit-hash: //p') echo "cachekey=$(echo $DATE$HASH | head -c12)" >> $GITHUB_OUTPUT - shell: bash - - name: "Downgrade registry access protocol when needed" + - name: Downgrade registry access protocol when needed + shell: bash run: | # Not all versions support setting CARGO_REGISTRIES_CRATES_IO_PROTOCOL # On versions 1.66, 1.67, and 1.68.0-nightly the value "sparse" is still unstable. @@ -163,8 +167,7 @@ runs: echo "Downgrade cargo registry protocol to git" echo "CARGO_REGISTRIES_CRATES_IO_PROTOCOL=git" >> $GITHUB_ENV fi - shell: bash - - name: "Setup Rust Caching" + - name: Setup Rust Caching if: inputs.cache == 'true' uses: Swatinem/rust-cache@v2 From c4ac4d95de39cd1fda6c48a99fc67e8ce13613e9 Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Thu, 11 Jan 2024 03:20:22 +0000 Subject: [PATCH 11/38] Prepare 1.7.0 release --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7a49699..45172b3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [1.7.0] - 2024-01-11 + * Allow overriding the toolchain file with explicit `toolchain` input. (#26) ## [1.6.0] - 2023-12-04 From f2e9ed58bdbfcd620ddbb1bdb2af5e676e9a17fd Mon Sep 17 00:00:00 2001 From: gruebel Date: Fri, 12 Jan 2024 18:41:01 +0100 Subject: [PATCH 12/38] add workspaces input field to support non-root projects --- README.md | 17 +++++++++-------- action.yml | 5 +++++ 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 03677a4..c87afef 100644 --- a/README.md +++ b/README.md @@ -48,14 +48,15 @@ If no `toolchain` value or toolchain file is present, it will default to `stable First, all items specified in the toolchain file are installed. Afterward, the `components` and `target` specified via inputs are installed in addition to the items from the toolchain file. -| Name | Description | Default | -| ------------ | -------------------------------------------------------------------------------------- | ------------- | -| `toolchain` | Rustup toolchain specifier e.g. `stable`, `nightly`, `1.42.0`. | stable | -| `target` | Additional target support to install e.g. `wasm32-unknown-unknown` | | -| `components` | Comma-separated string of additional components to install e.g. `clippy, rustfmt` | | -| `cache` | Automatically configure Rust cache (using `Swatinem/rust-cache`) | true | -| `matcher` | Enable problem matcher to surface build messages and formatting issues | true | -| `rustflags` | Set the value of `RUSTFLAGS` (set to empty string to avoid overwriting existing flags) | "-D warnings" | +| Name | Description | Default | +|--------------------|----------------------------------------------------------------------------------------|---------------| +| `toolchain` | Rustup toolchain specifier e.g. `stable`, `nightly`, `1.42.0`. | stable | +| `target` | Additional target support to install e.g. `wasm32-unknown-unknown` | | +| `components` | Comma-separated string of additional components to install e.g. `clippy, rustfmt` | | +| `cache` | Automatically configure Rust cache (using `Swatinem/rust-cache`) | true | +| `cache-workspaces` | Propagates the value to `Swatinem/rust-cache` | | +| `matcher` | Enable problem matcher to surface build messages and formatting issues | true | +| `rustflags` | Set the value of `RUSTFLAGS` (set to empty string to avoid overwriting existing flags) | "-D warnings" | ### RUSTFLAGS diff --git a/action.yml b/action.yml index 45eda54..c5b5e5c 100644 --- a/action.yml +++ b/action.yml @@ -25,6 +25,9 @@ inputs: description: "Automatically configure Rust cache" required: false default: "true" + cache-workspaces: + description: "Paths to multiple Cargo workspaces and their target directories, separated by newlines." + required: false matcher: description: "Enable the Rust problem matcher" required: false @@ -171,3 +174,5 @@ runs: - name: Setup Rust Caching if: inputs.cache == 'true' uses: Swatinem/rust-cache@v2 + with: + workspaces: ${{inputs.cache-workspaces}} From d473183fe9998a8cc8675f8f421fd2ab7044b784 Mon Sep 17 00:00:00 2001 From: Felix Prasanna Date: Fri, 12 Jan 2024 17:14:34 -0500 Subject: [PATCH 13/38] use rustup override set to select toolchain Using rustup override set will override a local rust-toolchain.toml file while rustup default will not. --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index 45eda54..997b954 100644 --- a/action.yml +++ b/action.yml @@ -138,7 +138,7 @@ runs: toolchain=stable fi rustup toolchain install $toolchain${{steps.flags.outputs.targets}}${{steps.flags.outputs.components}} --profile minimal${{steps.flags.outputs.downgrade}} --no-self-update - rustup default $toolchain + rustup override set $toolchain fi - id: versions From c6086ae6e539b9cca10fba3642fe77e559ba5705 Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Sat, 13 Jan 2024 15:54:38 +0000 Subject: [PATCH 14/38] test: add toolchain file override test --- .github/workflows/ci.yml | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 521e3f6..5fc202d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,8 +12,15 @@ jobs: strategy: fail-fast: false matrix: + os: + - ubuntu-latest + - windows-latest + - macos-latest + write-toolchain-file: + - false + - true rust: - # Test with toolchain file override + # use stable toolchain as default - null # Test that the sparse registry check works. @@ -23,21 +30,17 @@ jobs: - "nightly" - "beta" - "stable" - os: - - ubuntu-latest - - windows-latest - - macos-latest steps: - uses: actions/checkout@v4 # Test toolchain file support - name: Write rust-toolchain.toml - if: matrix.rust == null + if: matrix.write-toolchain-file shell: bash run: | cat <>rust-toolchain.toml [toolchain] - channel = "nightly-2024-01-11" + channel = "nightly-2024-01-10" components = [ "rustfmt", "rustc-dev" ] targets = [ "wasm32-unknown-unknown", "thumbv7m-none-eabi" ] profile = "minimal" @@ -59,6 +62,20 @@ jobs: - name: Check ${{'${{steps.toolchain.outputs.rustup-version}}'}} run: echo '${{steps.toolchain.outputs.rustup-version}}' + - name: Check lack of toolchain input or file results in stable + if: !matrix.write-toolchain-file && matrix.rust == null + shell: bash + run: |- + rustcv="$(rustc --version)" + [[ "$rustcv" != *"nightly"* && "$rustcv" != *"beta"* ]] + + - name: Check toolchain file is being overridden + if: matrix.write-toolchain-file + shell: bash + run: |- + rustcv="$(rustc --version)" + [[ ! ( "$rustcv" == *"nightly"* && "$rustcv" == *"2024-01-10"* ) ]] + - shell: bash run: rustc --version && cargo --version From aa089182f268c0255577cdc57a82a9b0819d59c3 Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Sat, 13 Jan 2024 15:57:48 +0000 Subject: [PATCH 15/38] ci: fix conditional --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5fc202d..c9120aa 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -63,7 +63,7 @@ jobs: run: echo '${{steps.toolchain.outputs.rustup-version}}' - name: Check lack of toolchain input or file results in stable - if: !matrix.write-toolchain-file && matrix.rust == null + if: matrix.write-toolchain-file == false && matrix.rust == null shell: bash run: |- rustcv="$(rustc --version)" From ba41ca6f71dca3d3a627600631fedb7f260d083e Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Sat, 13 Jan 2024 16:03:46 +0000 Subject: [PATCH 16/38] ci: clearer test names --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c9120aa..8f3020a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,7 +7,7 @@ on: jobs: install: - name: Rust ${{matrix.rust || '(toolchain file)'}} ${{matrix.os}} + name: Rust ${{matrix.rust || '(default)'}} (toolchain-file=${{matrix.write-toolchain-file}}) (${{matrix.os}}) runs-on: ${{matrix.os}} strategy: fail-fast: false From 922cc935eba0313aadf10debf4b777609f674024 Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Sat, 13 Jan 2024 17:25:41 +0000 Subject: [PATCH 17/38] ci: add cache-workspaces test --- .github/workflows/ci.yml | 17 +++++++++++++++++ test-workspace/Cargo.lock | 16 ++++++++++++++++ test-workspace/Cargo.toml | 9 +++++++++ test-workspace/src/main.rs | 3 +++ 4 files changed, 45 insertions(+) create mode 100644 test-workspace/Cargo.lock create mode 100644 test-workspace/Cargo.toml create mode 100644 test-workspace/src/main.rs diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 521e3f6..96ea814 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -70,3 +70,20 @@ jobs: - run: cargo add serde_as - run: cargo clippy + + cache: + name: Cache + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - id: toolchain + name: Install Rust + uses: ./ + with: + components: clippy + cache: true + cache-workspaces: |- + ./test-workspace + + - run: cargo clippy diff --git a/test-workspace/Cargo.lock b/test-workspace/Cargo.lock new file mode 100644 index 0000000..f0ff31f --- /dev/null +++ b/test-workspace/Cargo.lock @@ -0,0 +1,16 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "ci" +version = "0.1.0" +dependencies = [ + "serde_as", +] + +[[package]] +name = "serde_as" +version = "0.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ee4afe4c5c3b69699c4267ae42b838e911466d7ca0005046adc93ac95bb16dd" diff --git a/test-workspace/Cargo.toml b/test-workspace/Cargo.toml new file mode 100644 index 0000000..431b03d --- /dev/null +++ b/test-workspace/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "ci" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +serde_as = "0.0.1" diff --git a/test-workspace/src/main.rs b/test-workspace/src/main.rs new file mode 100644 index 0000000..e7a11a9 --- /dev/null +++ b/test-workspace/src/main.rs @@ -0,0 +1,3 @@ +fn main() { + println!("Hello, world!"); +} From 15d0afaad9a057d55c8c95034bfb3aacb990a6b0 Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Sat, 13 Jan 2024 17:36:31 +0000 Subject: [PATCH 18/38] ci: fix cache test --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 96ea814..2300322 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -86,4 +86,4 @@ jobs: cache-workspaces: |- ./test-workspace - - run: cargo clippy + - run: cargo clippy --manifest-path=./test-workspace/Cargo.toml From 039765bd186526e4d2e1b2f3ec14f5216b4d92bc Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Sat, 13 Jan 2024 17:44:20 +0000 Subject: [PATCH 19/38] chore: prepare release 1.8.0 --- .github/workflows/ci.yml | 4 ++-- CHANGELOG.md | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index db77662..a2d5ed9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,6 +11,7 @@ jobs: runs-on: ${{matrix.os}} strategy: fail-fast: false + max-parallel: 5 matrix: os: - ubuntu-latest @@ -94,8 +95,7 @@ jobs: steps: - uses: actions/checkout@v4 - - id: toolchain - name: Install Rust + - name: Install Rust uses: ./ with: components: clippy diff --git a/CHANGELOG.md b/CHANGELOG.md index 45172b3..a61be21 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [1.8.0] - 2024-01-13 + +* Allow specifying subdirectories for cache. +* Fix toolchain file overriding. + ## [1.7.0] - 2024-01-11 * Allow overriding the toolchain file with explicit `toolchain` input. (#26) From d60b90debe0d884519d77df9573f555908335cbe Mon Sep 17 00:00:00 2001 From: Samuel Henrique Date: Sat, 25 May 2024 08:26:47 +0000 Subject: [PATCH 20/38] feat: adds cache-on-failure propagation --- README.md | 1 + action.yml | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/README.md b/README.md index c87afef..223ab23 100644 --- a/README.md +++ b/README.md @@ -55,6 +55,7 @@ Afterward, the `components` and `target` specified via inputs are installed in a | `components` | Comma-separated string of additional components to install e.g. `clippy, rustfmt` | | | `cache` | Automatically configure Rust cache (using `Swatinem/rust-cache`) | true | | `cache-workspaces` | Propagates the value to `Swatinem/rust-cache` | | +| `cache-on-failure` | Propagates the value to `Swatinem/rust-cache` | | | `matcher` | Enable problem matcher to surface build messages and formatting issues | true | | `rustflags` | Set the value of `RUSTFLAGS` (set to empty string to avoid overwriting existing flags) | "-D warnings" | diff --git a/action.yml b/action.yml index aa618b2..f0ea3d2 100644 --- a/action.yml +++ b/action.yml @@ -28,6 +28,10 @@ inputs: cache-workspaces: description: "Paths to multiple Cargo workspaces and their target directories, separated by newlines." required: false + cache-on-failure: + description: "Also cache on workflow failures" + default: "false" + required: false matcher: description: "Enable the Rust problem matcher" required: false @@ -176,3 +180,4 @@ runs: uses: Swatinem/rust-cache@v2 with: workspaces: ${{inputs.cache-workspaces}} + cache-on-failure: ${{inputs.cache-on-failure}} From 1734e14b0b36c9e543b432eae0fd17976456a737 Mon Sep 17 00:00:00 2001 From: Jonas Bushart Date: Sat, 8 Jun 2024 12:33:50 +0200 Subject: [PATCH 21/38] Switch default of `cache-on-failure` to true --- README.md | 8 +++++--- action.yml | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 223ab23..5899df0 100644 --- a/README.md +++ b/README.md @@ -53,12 +53,14 @@ Afterward, the `components` and `target` specified via inputs are installed in a | `toolchain` | Rustup toolchain specifier e.g. `stable`, `nightly`, `1.42.0`. | stable | | `target` | Additional target support to install e.g. `wasm32-unknown-unknown` | | | `components` | Comma-separated string of additional components to install e.g. `clippy, rustfmt` | | -| `cache` | Automatically configure Rust cache (using `Swatinem/rust-cache`) | true | -| `cache-workspaces` | Propagates the value to `Swatinem/rust-cache` | | -| `cache-on-failure` | Propagates the value to `Swatinem/rust-cache` | | +| `cache` | Automatically configure Rust cache (using [`Swatinem/rust-cache`]) | true | +| `cache-workspaces` | Propagates the value to [`Swatinem/rust-cache`] | | +| `cache-on-failure` | Propagates the value to [`Swatinem/rust-cache`] | true | | `matcher` | Enable problem matcher to surface build messages and formatting issues | true | | `rustflags` | Set the value of `RUSTFLAGS` (set to empty string to avoid overwriting existing flags) | "-D warnings" | +[`Swatinem/rust-cache`]: https://github.com/Swatinem/rust-cache + ### RUSTFLAGS By default, this action sets the `RUSTFLAGS` environment variable to `-D warnings`. diff --git a/action.yml b/action.yml index f0ea3d2..fa6bd89 100644 --- a/action.yml +++ b/action.yml @@ -30,7 +30,7 @@ inputs: required: false cache-on-failure: description: "Also cache on workflow failures" - default: "false" + default: "true" required: false matcher: description: "Enable the Rust problem matcher" From 46dca5d12051bf38a65278fe635ccfc2d03c66b3 Mon Sep 17 00:00:00 2001 From: Jonas Bushart Date: Sat, 8 Jun 2024 12:40:20 +0200 Subject: [PATCH 22/38] Add changelog entry --- CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a61be21..acd52af 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [1.9.0] - 2024-06-08 + +* Add extra argument `cache-on-failure` and forward it to `Swatinem/rust-cache`. (#39 by @samuelhnrq) + Set the default the value to true. + This will result in more caching than previously. + This helps when large dependencies are compiled only for testing to fail. + ## [1.8.0] - 2024-01-13 * Allow specifying subdirectories for cache. From b01657d9bb1c81c4e7a46604980d19112a4034f0 Mon Sep 17 00:00:00 2001 From: Iain Lane Date: Fri, 12 Jul 2024 08:28:17 +0100 Subject: [PATCH 23/38] Add support for adding to cache key When using this action in multiple matrix jobs in the same workflow, the generated cache key is the same for all of them, because they all get the same job ID. This means that all apart from the first job are unable to save the cache, and subsequent runs might restore the wrong cache. The `Swatinem/rust-cache` action which we use for caching has a `key` input which it puts in its cache key. (It doesn't override the key, just adds to it.) Providing this as an input here will allow us to generate a unique cache key for each job in the matrix. --- README.md | 1 + action.yml | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/README.md b/README.md index 5899df0..9298545 100644 --- a/README.md +++ b/README.md @@ -56,6 +56,7 @@ Afterward, the `components` and `target` specified via inputs are installed in a | `cache` | Automatically configure Rust cache (using [`Swatinem/rust-cache`]) | true | | `cache-workspaces` | Propagates the value to [`Swatinem/rust-cache`] | | | `cache-on-failure` | Propagates the value to [`Swatinem/rust-cache`] | true | +| `key` | Propagates the value to [`Swatinem/rust-cache`] | | | `matcher` | Enable problem matcher to surface build messages and formatting issues | true | | `rustflags` | Set the value of `RUSTFLAGS` (set to empty string to avoid overwriting existing flags) | "-D warnings" | diff --git a/action.yml b/action.yml index fa6bd89..c9a28b4 100644 --- a/action.yml +++ b/action.yml @@ -32,6 +32,9 @@ inputs: description: "Also cache on workflow failures" default: "true" required: false + cache-key: + description: "An additional cache key that is added alongside the automatic `job`-based cache key and can be used to further differentiate jobs." + required: false matcher: description: "Enable the Rust problem matcher" required: false @@ -181,3 +184,4 @@ runs: with: workspaces: ${{inputs.cache-workspaces}} cache-on-failure: ${{inputs.cache-on-failure}} + key: ${{inputs.cache-key}} From 5d6934e965a5457a045bd6a3327b3ce9dd0c6cbf Mon Sep 17 00:00:00 2001 From: Fukaya Temma <23367170+pranc1ngpegasus@users.noreply.github.com> Date: Sun, 18 Aug 2024 01:34:59 +0900 Subject: [PATCH 24/38] Able to cache additional directories --- action.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/action.yml b/action.yml index fa6bd89..8ad465f 100644 --- a/action.yml +++ b/action.yml @@ -28,6 +28,9 @@ inputs: cache-workspaces: description: "Paths to multiple Cargo workspaces and their target directories, separated by newlines." required: false + cache-directories: + description: "Additional non workspace directories to be cached, separated by newlines." + required: false cache-on-failure: description: "Also cache on workflow failures" default: "true" @@ -180,4 +183,5 @@ runs: uses: Swatinem/rust-cache@v2 with: workspaces: ${{inputs.cache-workspaces}} + cache-directories: ${{inputs.cache-directories}} cache-on-failure: ${{inputs.cache-on-failure}} From 597574aacb4ee305cfa0c6a3ba38e8be6f9a2eb6 Mon Sep 17 00:00:00 2001 From: Jonas Bushart Date: Fri, 20 Sep 2024 00:23:09 +0200 Subject: [PATCH 25/38] Update key name in README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9298545..7b24bc7 100644 --- a/README.md +++ b/README.md @@ -56,7 +56,7 @@ Afterward, the `components` and `target` specified via inputs are installed in a | `cache` | Automatically configure Rust cache (using [`Swatinem/rust-cache`]) | true | | `cache-workspaces` | Propagates the value to [`Swatinem/rust-cache`] | | | `cache-on-failure` | Propagates the value to [`Swatinem/rust-cache`] | true | -| `key` | Propagates the value to [`Swatinem/rust-cache`] | | +| `cache-key` | Propagates the value to [`Swatinem/rust-cache`] as `key` | | | `matcher` | Enable problem matcher to surface build messages and formatting issues | true | | `rustflags` | Set the value of `RUSTFLAGS` (set to empty string to avoid overwriting existing flags) | "-D warnings" | From eb4a655afde124c3ebbd7ddebd7ef287d56ac4d6 Mon Sep 17 00:00:00 2001 From: Jonas Bushart Date: Fri, 20 Sep 2024 00:27:10 +0200 Subject: [PATCH 26/38] Document new keys and add changelog --- CHANGELOG.md | 3 +++ README.md | 23 ++++++++++++----------- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index acd52af..4e3c466 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +* Add new parameter `cache-directories` that is propagated to `Swatinem/rust-cache` (#44 by @pranc1ngpegasus) +* Add new parameter `cache-key` that is propagated to `Swatinem/rust-cache` as `key` (#41 by @iainlane) + ## [1.9.0] - 2024-06-08 * Add extra argument `cache-on-failure` and forward it to `Swatinem/rust-cache`. (#39 by @samuelhnrq) diff --git a/README.md b/README.md index 7b24bc7..3cbc487 100644 --- a/README.md +++ b/README.md @@ -48,17 +48,18 @@ If no `toolchain` value or toolchain file is present, it will default to `stable First, all items specified in the toolchain file are installed. Afterward, the `components` and `target` specified via inputs are installed in addition to the items from the toolchain file. -| Name | Description | Default | -|--------------------|----------------------------------------------------------------------------------------|---------------| -| `toolchain` | Rustup toolchain specifier e.g. `stable`, `nightly`, `1.42.0`. | stable | -| `target` | Additional target support to install e.g. `wasm32-unknown-unknown` | | -| `components` | Comma-separated string of additional components to install e.g. `clippy, rustfmt` | | -| `cache` | Automatically configure Rust cache (using [`Swatinem/rust-cache`]) | true | -| `cache-workspaces` | Propagates the value to [`Swatinem/rust-cache`] | | -| `cache-on-failure` | Propagates the value to [`Swatinem/rust-cache`] | true | -| `cache-key` | Propagates the value to [`Swatinem/rust-cache`] as `key` | | -| `matcher` | Enable problem matcher to surface build messages and formatting issues | true | -| `rustflags` | Set the value of `RUSTFLAGS` (set to empty string to avoid overwriting existing flags) | "-D warnings" | +| Name | Description | Default | +| ------------------- | -------------------------------------------------------------------------------------- | ------------- | +| `toolchain` | Rustup toolchain specifier e.g. `stable`, `nightly`, `1.42.0`. | stable | +| `target` | Additional target support to install e.g. `wasm32-unknown-unknown` | | +| `components` | Comma-separated string of additional components to install e.g. `clippy, rustfmt` | | +| `cache` | Automatically configure Rust cache (using [`Swatinem/rust-cache`]) | true | +| `cache-directories` | Propagates the value to [`Swatinem/rust-cache`] | | +| `cache-workspaces` | Propagates the value to [`Swatinem/rust-cache`] | | +| `cache-on-failure` | Propagates the value to [`Swatinem/rust-cache`] | true | +| `cache-key` | Propagates the value to [`Swatinem/rust-cache`] as `key` | | +| `matcher` | Enable problem matcher to surface build messages and formatting issues | true | +| `rustflags` | Set the value of `RUSTFLAGS` (set to empty string to avoid overwriting existing flags) | "-D warnings" | [`Swatinem/rust-cache`]: https://github.com/Swatinem/rust-cache From 86a2ce66737229469494d3779ce1c99c3b5b351d Mon Sep 17 00:00:00 2001 From: Jonas Bushart Date: Fri, 20 Sep 2024 00:39:06 +0200 Subject: [PATCH 27/38] Make toolchain install more robust --- CHANGELOG.md | 1 + action.yml | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4e3c466..5091e71 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * Add new parameter `cache-directories` that is propagated to `Swatinem/rust-cache` (#44 by @pranc1ngpegasus) * Add new parameter `cache-key` that is propagated to `Swatinem/rust-cache` as `key` (#41 by @iainlane) +* Make rustup toolchain installation more robust in light of planned changes https://github.com/rust-lang/rustup/issues/3635 and https://github.com/rust-lang/rustup/pull/3985 ## [1.9.0] - 2024-06-08 diff --git a/action.yml b/action.yml index d842f6e..f6929f3 100644 --- a/action.yml +++ b/action.yml @@ -137,8 +137,10 @@ runs: if [[ -z "$toolchain" && ( -f "rust-toolchain" || -f "rust-toolchain.toml" ) ]] then # Install the toolchain as specified in the file - # Might break at some point: https://github.com/rust-lang/rustup/issues/1397 - rustup show + # rustup show is the old way that implicitly installed a toolchain + # rustup toolchain install is the new explicit way + # https://github.com/rust-lang/rustup/issues/3635#issuecomment-2343511297 + rustup show active-toolchain || rustup toolchain install if [[ -n $components ]]; then rustup component add ${components//,/ } fi From 9f99923fade1f569928b687ccc2858a192effa02 Mon Sep 17 00:00:00 2001 From: Jonas Bushart Date: Fri, 20 Sep 2024 00:46:09 +0200 Subject: [PATCH 28/38] Add pre-commit for basic checks --- .pre-commit-config.yaml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 .pre-commit-config.yaml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..ba2a6f4 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,18 @@ +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.6.0 + hooks: + - id: check-case-conflict + - id: check-executables-have-shebangs + - id: check-merge-conflict + - id: check-json + - id: check-yaml + - id: end-of-file-fixer + - id: trailing-whitespace + args: [--markdown-linebreak-ext=md] + - repo: https://github.com/python-jsonschema/check-jsonschema + rev: 0.29.2 + hooks: + - id: check-dependabot + - id: check-github-actions + - id: check-github-workflows From b31b1317f290cc8743fce262ee98435b8c2a3c5a Mon Sep 17 00:00:00 2001 From: Jonas Bushart Date: Sun, 22 Sep 2024 15:28:43 +0200 Subject: [PATCH 29/38] Allow installing multiple Rust toolchains at once. --- CHANGELOG.md | 1 + README.md | 24 ++++++++++++------------ action.yml | 9 +++++---- 3 files changed, 18 insertions(+), 16 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5091e71..997762c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * Add new parameter `cache-directories` that is propagated to `Swatinem/rust-cache` (#44 by @pranc1ngpegasus) * Add new parameter `cache-key` that is propagated to `Swatinem/rust-cache` as `key` (#41 by @iainlane) * Make rustup toolchain installation more robust in light of planned changes https://github.com/rust-lang/rustup/issues/3635 and https://github.com/rust-lang/rustup/pull/3985 +* Allow installing multiple Rust toolchains by specifying multiple versions in the `toolchain` input parameter. ## [1.9.0] - 2024-06-08 diff --git a/README.md b/README.md index 3cbc487..6cacb74 100644 --- a/README.md +++ b/README.md @@ -48,18 +48,18 @@ If no `toolchain` value or toolchain file is present, it will default to `stable First, all items specified in the toolchain file are installed. Afterward, the `components` and `target` specified via inputs are installed in addition to the items from the toolchain file. -| Name | Description | Default | -| ------------------- | -------------------------------------------------------------------------------------- | ------------- | -| `toolchain` | Rustup toolchain specifier e.g. `stable`, `nightly`, `1.42.0`. | stable | -| `target` | Additional target support to install e.g. `wasm32-unknown-unknown` | | -| `components` | Comma-separated string of additional components to install e.g. `clippy, rustfmt` | | -| `cache` | Automatically configure Rust cache (using [`Swatinem/rust-cache`]) | true | -| `cache-directories` | Propagates the value to [`Swatinem/rust-cache`] | | -| `cache-workspaces` | Propagates the value to [`Swatinem/rust-cache`] | | -| `cache-on-failure` | Propagates the value to [`Swatinem/rust-cache`] | true | -| `cache-key` | Propagates the value to [`Swatinem/rust-cache`] as `key` | | -| `matcher` | Enable problem matcher to surface build messages and formatting issues | true | -| `rustflags` | Set the value of `RUSTFLAGS` (set to empty string to avoid overwriting existing flags) | "-D warnings" | +| Name | Description | Default | +| ------------------- | ------------------------------------------------------------------------------------------------------------------------ | ------------- | +| `toolchain` | Comma-separated list of Rustup toolchain specifier e.g. `stable`, `nightly`, `1.42.0`. The last version is the default. | stable | +| `target` | Additional target support to install e.g. `wasm32-unknown-unknown` | | +| `components` | Comma-separated string of additional components to install e.g. `clippy, rustfmt` | | +| `cache` | Automatically configure Rust cache (using [`Swatinem/rust-cache`]) | true | +| `cache-directories` | Propagates the value to [`Swatinem/rust-cache`] | | +| `cache-workspaces` | Propagates the value to [`Swatinem/rust-cache`] | | +| `cache-on-failure` | Propagates the value to [`Swatinem/rust-cache`] | true | +| `cache-key` | Propagates the value to [`Swatinem/rust-cache`] as `key` | | +| `matcher` | Enable problem matcher to surface build messages and formatting issues | true | +| `rustflags` | Set the value of `RUSTFLAGS` (set to empty string to avoid overwriting existing flags) | "-D warnings" | [`Swatinem/rust-cache`]: https://github.com/Swatinem/rust-cache diff --git a/action.yml b/action.yml index f6929f3..240e88a 100644 --- a/action.yml +++ b/action.yml @@ -13,7 +13,7 @@ branding: # The action is heavily inspired by https://github.com/dtolnay/rust-toolchain inputs: toolchain: - description: "Rust toolchain specification -- see https://rust-lang.github.io/rustup/concepts/toolchains.html#toolchain-specification" + description: "Comma-separated list of Rust toolchain specifications. Last version becomes the default. -- see https://rust-lang.github.io/rustup/concepts/toolchains.html#toolchain-specification" required: false target: description: "Target triple to install for this toolchain" @@ -80,7 +80,7 @@ runs: : construct rustup command line echo "targets=$(for t in ${targets//,/ }; do echo -n ' --target' $t; done)" >> $GITHUB_OUTPUT echo "components=$(for c in ${components//,/ }; do echo -n ' --component' $c; done)" >> $GITHUB_OUTPUT - echo "downgrade=${{inputs.toolchain == 'nightly' && inputs.components && ' --allow-downgrade' || ''}}" >> $GITHUB_OUTPUT + echo "downgrade=${{contains(inputs.toolchain, 'nightly') && inputs.components && ' --allow-downgrade' || ''}}" >> $GITHUB_OUTPUT # The environment variables always need to be set before the caching action - name: Setting Environment Variables @@ -152,8 +152,9 @@ runs: then toolchain=stable fi - rustup toolchain install $toolchain${{steps.flags.outputs.targets}}${{steps.flags.outputs.components}} --profile minimal${{steps.flags.outputs.downgrade}} --no-self-update - rustup override set $toolchain + rustup toolchain install ${toolchain//,/ } ${{steps.flags.outputs.targets}}${{steps.flags.outputs.components}} --profile minimal${{steps.flags.outputs.downgrade}} --no-self-update + # Take the last element from the list + rustup override set ${toolchain//*,/ } fi - id: versions From 4d1965c9142484e48d40c19de54b5cba84953a06 Mon Sep 17 00:00:00 2001 From: Jonas Bushart Date: Sun, 22 Sep 2024 16:04:02 +0200 Subject: [PATCH 30/38] Add override input parameter that controls the `rustup override` behavior --- CHANGELOG.md | 1 + README.md | 1 + action.yml | 10 +++++++++- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 997762c..3903da1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * Add new parameter `cache-key` that is propagated to `Swatinem/rust-cache` as `key` (#41 by @iainlane) * Make rustup toolchain installation more robust in light of planned changes https://github.com/rust-lang/rustup/issues/3635 and https://github.com/rust-lang/rustup/pull/3985 * Allow installing multiple Rust toolchains by specifying multiple versions in the `toolchain` input parameter. +* Configure the `rustup override` behavior via the new `override` input. (#38) ## [1.9.0] - 2024-06-08 diff --git a/README.md b/README.md index 6cacb74..12aca64 100644 --- a/README.md +++ b/README.md @@ -60,6 +60,7 @@ Afterward, the `components` and `target` specified via inputs are installed in a | `cache-key` | Propagates the value to [`Swatinem/rust-cache`] as `key` | | | `matcher` | Enable problem matcher to surface build messages and formatting issues | true | | `rustflags` | Set the value of `RUSTFLAGS` (set to empty string to avoid overwriting existing flags) | "-D warnings" | +| `override` | Setup the last installed toolchain as the default via `rustup override` | true | [`Swatinem/rust-cache`]: https://github.com/Swatinem/rust-cache diff --git a/action.yml b/action.yml index 240e88a..21ef752 100644 --- a/action.yml +++ b/action.yml @@ -46,6 +46,10 @@ inputs: description: "set RUSTFLAGS environment variable, set to empty string to avoid overwriting build.rustflags" required: false default: "-D warnings" + override: + description: "Setup the last installed toolchain as the default via `rustup override`" + required: false + default: "true" outputs: rustc-version: @@ -132,6 +136,7 @@ runs: toolchain: ${{inputs.toolchain}} targets: ${{inputs.target}} components: ${{inputs.components}} + override: ${{inputs.override}} shell: bash run: | if [[ -z "$toolchain" && ( -f "rust-toolchain" || -f "rust-toolchain.toml" ) ]] @@ -154,7 +159,10 @@ runs: fi rustup toolchain install ${toolchain//,/ } ${{steps.flags.outputs.targets}}${{steps.flags.outputs.components}} --profile minimal${{steps.flags.outputs.downgrade}} --no-self-update # Take the last element from the list - rustup override set ${toolchain//*,/ } + if [[ "$override" == "true" ]] + then + rustup override set ${toolchain//*,/ } + fi fi - id: versions From 11df97af8e8102fd60b60a77dfbf58d40cd843b8 Mon Sep 17 00:00:00 2001 From: Jonas Bushart Date: Tue, 1 Oct 2024 23:06:20 +0200 Subject: [PATCH 31/38] Update the rustfmt problem matcher https://github.com/rust-lang/rustfmt/pull/5971 https://github.com/actions-rust-lang/rustfmt/issues/5 --- CHANGELOG.md | 8 ++++++++ rust.json | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3903da1..9ac8d9f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [1.10.1] - 2024-10-01 + +* Fix problem matcher for rustfmt output. + The format has changed since https://github.com/rust-lang/rustfmt/pull/5971 and now follows the form "filename:line". + Thanks to @0xcypher02 for pointing out the problem. + +## [1.10.0] - 2024-09-23 + * Add new parameter `cache-directories` that is propagated to `Swatinem/rust-cache` (#44 by @pranc1ngpegasus) * Add new parameter `cache-key` that is propagated to `Swatinem/rust-cache` as `key` (#41 by @iainlane) * Make rustup toolchain installation more robust in light of planned changes https://github.com/rust-lang/rustup/issues/3635 and https://github.com/rust-lang/rustup/pull/3985 diff --git a/rust.json b/rust.json index ddaa1b0..c407391 100644 --- a/rust.json +++ b/rust.json @@ -5,7 +5,7 @@ "severity": "warning", "pattern": [ { - "regexp": "^(Diff in (.+)) at line (\\d+):$", + "regexp": "^(Diff in (.+))(?: at line |:)(\\d+):$", "message": 1, "file": 2, "line": 3 From 97db979bf844c838b06022f305ca480d01b4d5fe Mon Sep 17 00:00:00 2001 From: Jonas Bushart Date: Mon, 21 Oct 2024 23:54:51 +0200 Subject: [PATCH 32/38] Specify dependencies in README --- README.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/README.md b/README.md index 12aca64..605859d 100644 --- a/README.md +++ b/README.md @@ -88,6 +88,16 @@ You can read more rustflags, and their load order, in the [Cargo reference]. | `rustup-version` | Version as reported by `rustup --version` | | `cachekey` | A short hash of the installed rustc version | +## Dependencies + +The action works best on the GitHub-hosted runners, but can work on self-hosted ones too, provided the necessary dependencies are available. +PRs to add support for more environments are welcome. + +* bash 5 +* brew (macOS only) +* rustup or curl (Linux and macOS) +* using other node actions + ## License The scripts and documentation in this project are released under the [MIT From f8efd60d2dea71cf378cafb3f494ecf103ae1179 Mon Sep 17 00:00:00 2001 From: skanehira Date: Sat, 8 Feb 2025 01:22:20 +0900 Subject: [PATCH 33/38] feat: add shared-cache-key to inputs --- README.md | 1 + action.yml | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/README.md b/README.md index 605859d..209e5d3 100644 --- a/README.md +++ b/README.md @@ -58,6 +58,7 @@ Afterward, the `components` and `target` specified via inputs are installed in a | `cache-workspaces` | Propagates the value to [`Swatinem/rust-cache`] | | | `cache-on-failure` | Propagates the value to [`Swatinem/rust-cache`] | true | | `cache-key` | Propagates the value to [`Swatinem/rust-cache`] as `key` | | +| `shared-cache-key` | Propagates the value to [`Swatinem/rust-cache`] as `shared-key` | | | `matcher` | Enable problem matcher to surface build messages and formatting issues | true | | `rustflags` | Set the value of `RUSTFLAGS` (set to empty string to avoid overwriting existing flags) | "-D warnings" | | `override` | Setup the last installed toolchain as the default via `rustup override` | true | diff --git a/action.yml b/action.yml index 21ef752..df6946e 100644 --- a/action.yml +++ b/action.yml @@ -38,6 +38,9 @@ inputs: cache-key: description: "An additional cache key that is added alongside the automatic `job`-based cache key and can be used to further differentiate jobs." required: false + shared-cache-key: + description: "A cache key that is used instead of the automatic `job`-based key, and is stable over multiple jobs." + required: false matcher: description: "Enable the Rust problem matcher" required: false @@ -200,3 +203,4 @@ runs: cache-directories: ${{inputs.cache-directories}} cache-on-failure: ${{inputs.cache-on-failure}} key: ${{inputs.cache-key}} + shared-key: ${{inputs.shared-cache-key}} From 30081c4da55e5f2a707c228afc2c7d6f422a676c Mon Sep 17 00:00:00 2001 From: Enkhjil Enkhbaatar Date: Tue, 4 Feb 2025 15:13:57 +0900 Subject: [PATCH 34/38] fix: add cache-bin input with true as default value --- README.md | 1 + action.yml | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/README.md b/README.md index 605859d..60f0b0d 100644 --- a/README.md +++ b/README.md @@ -58,6 +58,7 @@ Afterward, the `components` and `target` specified via inputs are installed in a | `cache-workspaces` | Propagates the value to [`Swatinem/rust-cache`] | | | `cache-on-failure` | Propagates the value to [`Swatinem/rust-cache`] | true | | `cache-key` | Propagates the value to [`Swatinem/rust-cache`] as `key` | | +| `cache-bin` | Propagates the value to [`Swatinem/rust-cache`] | | | `matcher` | Enable problem matcher to surface build messages and formatting issues | true | | `rustflags` | Set the value of `RUSTFLAGS` (set to empty string to avoid overwriting existing flags) | "-D warnings" | | `override` | Setup the last installed toolchain as the default via `rustup override` | true | diff --git a/action.yml b/action.yml index 21ef752..1befac2 100644 --- a/action.yml +++ b/action.yml @@ -38,6 +38,10 @@ inputs: cache-key: description: "An additional cache key that is added alongside the automatic `job`-based cache key and can be used to further differentiate jobs." required: false + cache-bin: + description: "Determines whether to cache ${CARGO_HOME}/bin." + required: false + default: "true" matcher: description: "Enable the Rust problem matcher" required: false @@ -199,4 +203,5 @@ runs: workspaces: ${{inputs.cache-workspaces}} cache-directories: ${{inputs.cache-directories}} cache-on-failure: ${{inputs.cache-on-failure}} + cache-bin: ${{inputs.cache-bin}} key: ${{inputs.cache-key}} From 6cbea1a7947962ed471795015128faa83769af2d Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Mon, 24 Feb 2025 02:18:45 +0000 Subject: [PATCH 35/38] chore: prepare release 1.11.0 --- CHANGELOG.md | 5 +++++ README.md | 2 +- action.yml | 4 ++-- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9ac8d9f..25142be 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [1.11.0] - 2025-02-24 + +* Add new parameter `cache-bin` that is propagated to `Swatinem/rust-cache` as `cache-bin` (#51 by @enkhjile) +* Add new parameter `cache-shared-key` that is propagated to `Swatinem/rust-cache` as `shared-key` (#52 by @skanehira) + ## [1.10.1] - 2024-10-01 * Fix problem matcher for rustfmt output. diff --git a/README.md b/README.md index 209e5d3..10e7bb2 100644 --- a/README.md +++ b/README.md @@ -58,7 +58,7 @@ Afterward, the `components` and `target` specified via inputs are installed in a | `cache-workspaces` | Propagates the value to [`Swatinem/rust-cache`] | | | `cache-on-failure` | Propagates the value to [`Swatinem/rust-cache`] | true | | `cache-key` | Propagates the value to [`Swatinem/rust-cache`] as `key` | | -| `shared-cache-key` | Propagates the value to [`Swatinem/rust-cache`] as `shared-key` | | +| `cache-shared-key` | Propagates the value to [`Swatinem/rust-cache`] as `shared-key` | | | `matcher` | Enable problem matcher to surface build messages and formatting issues | true | | `rustflags` | Set the value of `RUSTFLAGS` (set to empty string to avoid overwriting existing flags) | "-D warnings" | | `override` | Setup the last installed toolchain as the default via `rustup override` | true | diff --git a/action.yml b/action.yml index df6946e..f829e66 100644 --- a/action.yml +++ b/action.yml @@ -38,7 +38,7 @@ inputs: cache-key: description: "An additional cache key that is added alongside the automatic `job`-based cache key and can be used to further differentiate jobs." required: false - shared-cache-key: + cache-shared-key: description: "A cache key that is used instead of the automatic `job`-based key, and is stable over multiple jobs." required: false matcher: @@ -203,4 +203,4 @@ runs: cache-directories: ${{inputs.cache-directories}} cache-on-failure: ${{inputs.cache-on-failure}} key: ${{inputs.cache-key}} - shared-key: ${{inputs.shared-cache-key}} + shared-key: ${{inputs.cache-shared-key}} From d9c91b20fd575d8e7998826de9744357e3a7a903 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonatan=20M=C3=A4nnchen?= Date: Wed, 23 Apr 2025 16:16:31 +0200 Subject: [PATCH 36/38] Support rustup installation for Windows --- action.yml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/action.yml b/action.yml index d3aecfe..ca44c3d 100644 --- a/action.yml +++ b/action.yml @@ -130,13 +130,20 @@ runs: run: echo "::add-matcher::${{ github.action_path }}/rust.json" - name: Install rustup, if needed - if: runner.os != 'Windows' shell: bash run: | if ! command -v rustup &> /dev/null ; then curl --proto '=https' --tlsv1.2 --retry 10 --retry-connrefused -fsSL "https://sh.rustup.rs" | sh -s -- --default-toolchain none -y - echo "${CARGO_HOME:-$HOME/.cargo}/bin" >> $GITHUB_PATH + + # Resolve the correct CARGO_HOME path depending on OS + if [[ "$RUNNER_OS" == "Windows" ]]; then + echo "${CARGO_HOME:-$USERPROFILE/.cargo}/bin" | sed 's|/|\\|g' >> $GITHUB_PATH + else + echo "${CARGO_HOME:-$HOME/.cargo}/bin" >> $GITHUB_PATH + fi fi + env: + RUNNER_OS: "${{ runner.os }}" - name: rustup toolchain install ${{inputs.toolchain || 'stable'}} env: From 9988a3d74bdbde17eac1e61264c78dea69889540 Mon Sep 17 00:00:00 2001 From: Jonas Bushart Date: Wed, 23 Apr 2025 22:42:15 +0200 Subject: [PATCH 37/38] Update the dependency section to mark the new windows rustup support --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index cfbf823..6f8a15c 100644 --- a/README.md +++ b/README.md @@ -97,7 +97,7 @@ PRs to add support for more environments are welcome. * bash 5 * brew (macOS only) -* rustup or curl (Linux and macOS) +* rustup or curl * using other node actions ## License From 9d7e65c320fdb52dcd45ffaa68deb6c02c8754d9 Mon Sep 17 00:00:00 2001 From: Jonas Bushart Date: Wed, 23 Apr 2025 22:46:51 +0200 Subject: [PATCH 38/38] Update changelog for windows support --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 25142be..a637784 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [1.12.0] - 2025-04-23 + +* Add support for installing rustup on Windows (#58 by @maennchen) + This adds support for using Rust on the GitHub provided Windows ARM runners. + ## [1.11.0] - 2025-02-24 * Add new parameter `cache-bin` that is propagated to `Swatinem/rust-cache` as `cache-bin` (#51 by @enkhjile)