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 1/3] 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 2/3] 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 962ed5edf06081797ba8b276d7fa8851e3802e5e Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Thu, 11 Jan 2024 02:20:44 +0000 Subject: [PATCH 3/3] 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