diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index df694af..492df5e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -31,6 +31,26 @@ jobs: expect-stripped: "--expect-stripped" can-execute: true + - platform_name: Linux-x86_64 (beta) + runs-on: ubuntu-24.04 + target: x86_64-unknown-linux-musl + toolchain: beta + cache-cross-binary: true + expect-file-re: "ELF.+x86-64" + expect-cross: "" + expect-stripped: "--expect-stripped" + can-execute: true + + - platform_name: Linux-x86_64 (nightly) + runs-on: ubuntu-24.04 + target: x86_64-unknown-linux-musl + toolchain: nightly + cache-cross-binary: true + expect-file-re: "ELF.+x86-64" + expect-cross: "" + expect-stripped: "--expect-stripped" + can-execute: true + - platform_name: Linux-x86_64 (force cross) runs-on: ubuntu-24.04 target: x86_64-unknown-linux-gnu @@ -41,6 +61,16 @@ jobs: expect-stripped: "" can-execute: true + - platform_name: Linux-x86_64 (stable 8 months ago) + runs-on: ubuntu-24.04 + target: x86_64-unknown-linux-gnu + toolchain: "stable 8 months ago" + cache-cross-binary: true + expect-file-re: "ELF.+x86-64" + expect-cross: "" + expect-stripped: "--expect-stripped" + can-execute: true + - platform_name: Linux-aarch64 runs-on: ubuntu-24.04 target: aarch64-unknown-linux-musl @@ -271,6 +301,7 @@ jobs: cross-version: ${{ matrix.platform.cross-version }} cache-cross-binary: ${{ matrix.platform.cache-cross-binary }} target: ${{ matrix.platform.target }} + toolchain: ${{ matrix.platform.toolchain || 'stable' }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} if: ${{ matrix.platform.can-execute }} - name: Run test command @@ -281,6 +312,7 @@ jobs: cross-version: ${{ matrix.platform.cross-version }} cache-cross-binary: ${{ matrix.platform.cache-cross-binary }} target: ${{ matrix.platform.target }} + toolchain: ${{ matrix.platform.toolchain || 'stable' }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} if: ${{ matrix.platform.can-execute }} - name: Run test command with args @@ -291,6 +323,7 @@ jobs: cross-version: ${{ matrix.platform.cross-version }} cache-cross-binary: ${{ matrix.platform.cache-cross-binary }} target: ${{ matrix.platform.target }} + toolchain: ${{ matrix.platform.toolchain || 'stable' }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} args: "-- --ignored" if: ${{ matrix.platform.can-execute }} @@ -302,6 +335,7 @@ jobs: cross-version: ${{ matrix.platform.cross-version }} cache-cross-binary: ${{ matrix.platform.cache-cross-binary }} target: ${{ matrix.platform.target }} + toolchain: ${{ matrix.platform.toolchain || 'stable' }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} strip: true - name: Check binary and cross for main crate on ${{ matrix.platform.platform_name }} @@ -325,6 +359,7 @@ jobs: cache-cross-binary: ${{ matrix.platform.cache-cross-binary }} working-directory: subcrate target: ${{ matrix.platform.target }} + toolchain: ${{ matrix.platform.toolchain || 'stable' }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} strip: true - name: Check binary and cross for subcrate on ${{ matrix.platform.platform_name }} @@ -349,6 +384,7 @@ jobs: cache-cross-binary: ${{ matrix.platform.cache-cross-binary }} target: ${{ matrix.platform.target }} working-directory: bench + toolchain: ${{ matrix.platform.toolchain || 'stable' }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} if: ${{ matrix.platform.can-execute }} diff --git a/Changes.md b/Changes.md index febe7ff..9c5cfb6 100644 --- a/Changes.md +++ b/Changes.md @@ -1,3 +1,10 @@ +## 1.0.4 + +- Removed validation for the `toolchain` input. The + [dtolnay/rust-toolchain](https://github.com/dtolnay/rust-toolchain) accepts a lot of different + options that this action wasn't allowing. It's simpler and more flexible to just let that action + handle validation. Requested by @axos88 (Akos Vandra-Meyer). GH #42. + ## 1.0.3 - 2025-02-17 - Fixed a bug when running with a Linux ARM host where the action would use a cached `cross` diff --git a/README.md b/README.md index dce0330..340c75f 100644 --- a/README.md +++ b/README.md @@ -74,7 +74,7 @@ This action takes the following parameters: | `command` | string (one of `build`, `test`, `both` (build and test), or `bench`) | no | The command(s) to run. The default is `build`. Running the `test` command will fail with \*BSD targets and non-x86 Windows. | | `target` | string | yes | The target triple to compile for. This should be one of the targets found by running `rustup target list`. | | `working-directory` | string | no | The working directory in which to run the `cargo` or `cross` commands. Defaults to the current directory (`.`). | -| `toolchain` | string (one of `stable`, `beta`, or `nightly`) | no | The Rust toolchain version to install. The default is `stable`. | +| `toolchain` | string) | no | The Rust toolchain version to install. This is passed directly to [dtolnay/rust-toolchain](https://github.com/dtolnay/rust-toolchain), which accepts many different options. See its documentation for more details. The default is `stable`. | | `GITHUB_TOKEN` | string | no | Defaults to the value of `${{ github.token }}`. | | `args` | string | no | A string-separated list of arguments to be passed to `cross build`, like `--release --locked`. | | `strip` | boolean (`true` or `false`) | no | If this is true, then the resulting binaries will be stripped if possible. This is only possible for binaries which weren't cross-compiled. | diff --git a/action.yml b/action.yml index ca42e89..677460f 100644 --- a/action.yml +++ b/action.yml @@ -20,7 +20,7 @@ inputs: toolchain: description: | - The target toolchain to use (one of "stable", "beta", or "nightly"). + The target toolchain to use. default: stable working-directory: @@ -195,7 +195,7 @@ runs: working-directory: ${{ inputs.working-directory }} shell: bash run: | - ${{ steps.set-build-command.outputs.build-command }} +${{inputs.toolchain}} test --target ${{ inputs.target }} ${{ inputs.args }} + ${{ steps.set-build-command.outputs.build-command }} test --target ${{ inputs.target }} ${{ inputs.args }} if: steps.determine-cargo-commands.outputs.test == 'true' && runner.os != 'Windows' # We want to run in Powershell on Windows to make sure we compile in a @@ -206,35 +206,35 @@ runs: working-directory: ${{ inputs.working-directory }} shell: powershell run: | - & ${{ steps.set-build-command.outputs.build-command }} +${{inputs.toolchain}} test --target ${{ inputs.target }} ${{ inputs.args }} + & ${{ steps.set-build-command.outputs.build-command }} test --target ${{ inputs.target }} ${{ inputs.args }} if: steps.determine-cargo-commands.outputs.test == 'true' && runner.os == 'Windows' - name: Run benchmarks (*nix) working-directory: ${{ inputs.working-directory }} shell: bash run: | - ${{ steps.set-build-command.outputs.build-command }} +${{inputs.toolchain}} bench --target ${{ inputs.target }} ${{ inputs.args }} + ${{ steps.set-build-command.outputs.build-command }} bench --target ${{ inputs.target }} ${{ inputs.args }} if: steps.determine-cargo-commands.outputs.bench == 'true' && runner.os != 'Windows' - name: Run benchmarks (Windows) working-directory: ${{ inputs.working-directory }} shell: powershell run: | - & ${{ steps.set-build-command.outputs.build-command }} +${{inputs.toolchain}} bench --target ${{ inputs.target }} ${{ inputs.args }} + & ${{ steps.set-build-command.outputs.build-command }} bench --target ${{ inputs.target }} ${{ inputs.args }} if: steps.determine-cargo-commands.outputs.bench == 'true' && runner.os == 'Windows' - name: Build binary (*nix) working-directory: ${{ inputs.working-directory }} shell: bash run: | - ${{ steps.set-build-command.outputs.build-command }} +${{inputs.toolchain}} build ${{ inputs.args }} --target ${{ inputs.target }} + ${{ steps.set-build-command.outputs.build-command }} build ${{ inputs.args }} --target ${{ inputs.target }} if: steps.determine-cargo-commands.outputs.build == 'true' && runner.os != 'Windows' - name: Build binary (Windows) working-directory: ${{ inputs.working-directory }} shell: powershell run: | - & ${{ steps.set-build-command.outputs.build-command }} +${{inputs.toolchain}} build ${{ inputs.args }} --target ${{ inputs.target }} + & ${{ steps.set-build-command.outputs.build-command }} build ${{ inputs.args }} --target ${{ inputs.target }} if: steps.determine-cargo-commands.outputs.build == 'true' && runner.os == 'Windows' - name: Strip binary diff --git a/validate-inputs.py b/validate-inputs.py index a23e58e..96e7213 100755 --- a/validate-inputs.py +++ b/validate-inputs.py @@ -50,14 +50,6 @@ class InputValidator: f"Invalid 'command'. Must be one of {sorted(valid_commands)}" ) - # Validate toolchain if present - if "toolchain" in self.inputs: - valid_toolchains = {"stable", "beta", "nightly"} - if self.inputs["toolchain"] not in valid_toolchains: - validation_errors.append( - f"Invalid 'toolchain'. Must be one of {sorted(valid_toolchains)}" - ) - # Validate working directory if present if "working_directory" in self.inputs: path = Path(self.inputs["working_directory"]) @@ -162,7 +154,13 @@ class TestInputValidator(unittest.TestCase): def test_validate_valid_toolchain(self) -> None: """Test validation of valid toolchains.""" - valid_toolchains = ["stable", "beta", "nightly"] + valid_toolchains = [ + "stable", + "beta", + "nightly", + "nightly-2025-03-17", + "stable 8 weeks ago", + ] for toolchain in valid_toolchains: self.setup_env( @@ -172,13 +170,6 @@ class TestInputValidator(unittest.TestCase): errors = validator.validate() self.assertFalse(errors, f"Toolchain '{toolchain}' should be valid") - def test_validate_invalid_toolchain(self) -> None: - """Test validation of invalid toolchain.""" - self.setup_env({"target": "x86_64-unknown-linux-gnu", "toolchain": "unknown"}) - validator = InputValidator("/root") - errors = validator.validate() - self.assertTrue(errors) - def test_validate_working_directory(self) -> None: """Test validation of working directory.""" with tempfile.TemporaryDirectory() as temp_dir: