Remove validation of the toolchain input
The `dtolnay/rust-toolchain` action accepts a lot of options, including things like "stable 8 weeks ago". Instead of trying to have this action validate the input, we'll leave it to `dtolnay/rust-toolchain`. This also adds tests using non-stable toolchains.
This commit is contained in:
parent
e2ab1c3836
commit
56f0ba980e
36
.github/workflows/test.yml
vendored
36
.github/workflows/test.yml
vendored
@ -31,6 +31,26 @@ jobs:
|
|||||||
expect-stripped: "--expect-stripped"
|
expect-stripped: "--expect-stripped"
|
||||||
can-execute: true
|
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)
|
- platform_name: Linux-x86_64 (force cross)
|
||||||
runs-on: ubuntu-24.04
|
runs-on: ubuntu-24.04
|
||||||
target: x86_64-unknown-linux-gnu
|
target: x86_64-unknown-linux-gnu
|
||||||
@ -41,6 +61,16 @@ jobs:
|
|||||||
expect-stripped: ""
|
expect-stripped: ""
|
||||||
can-execute: true
|
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
|
- platform_name: Linux-aarch64
|
||||||
runs-on: ubuntu-24.04
|
runs-on: ubuntu-24.04
|
||||||
target: aarch64-unknown-linux-musl
|
target: aarch64-unknown-linux-musl
|
||||||
@ -271,6 +301,7 @@ jobs:
|
|||||||
cross-version: ${{ matrix.platform.cross-version }}
|
cross-version: ${{ matrix.platform.cross-version }}
|
||||||
cache-cross-binary: ${{ matrix.platform.cache-cross-binary }}
|
cache-cross-binary: ${{ matrix.platform.cache-cross-binary }}
|
||||||
target: ${{ matrix.platform.target }}
|
target: ${{ matrix.platform.target }}
|
||||||
|
toolchain: ${{ matrix.platform.toolchain || 'stable' }}
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
if: ${{ matrix.platform.can-execute }}
|
if: ${{ matrix.platform.can-execute }}
|
||||||
- name: Run test command
|
- name: Run test command
|
||||||
@ -281,6 +312,7 @@ jobs:
|
|||||||
cross-version: ${{ matrix.platform.cross-version }}
|
cross-version: ${{ matrix.platform.cross-version }}
|
||||||
cache-cross-binary: ${{ matrix.platform.cache-cross-binary }}
|
cache-cross-binary: ${{ matrix.platform.cache-cross-binary }}
|
||||||
target: ${{ matrix.platform.target }}
|
target: ${{ matrix.platform.target }}
|
||||||
|
toolchain: ${{ matrix.platform.toolchain || 'stable' }}
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
if: ${{ matrix.platform.can-execute }}
|
if: ${{ matrix.platform.can-execute }}
|
||||||
- name: Run test command with args
|
- name: Run test command with args
|
||||||
@ -291,6 +323,7 @@ jobs:
|
|||||||
cross-version: ${{ matrix.platform.cross-version }}
|
cross-version: ${{ matrix.platform.cross-version }}
|
||||||
cache-cross-binary: ${{ matrix.platform.cache-cross-binary }}
|
cache-cross-binary: ${{ matrix.platform.cache-cross-binary }}
|
||||||
target: ${{ matrix.platform.target }}
|
target: ${{ matrix.platform.target }}
|
||||||
|
toolchain: ${{ matrix.platform.toolchain || 'stable' }}
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
args: "-- --ignored"
|
args: "-- --ignored"
|
||||||
if: ${{ matrix.platform.can-execute }}
|
if: ${{ matrix.platform.can-execute }}
|
||||||
@ -302,6 +335,7 @@ jobs:
|
|||||||
cross-version: ${{ matrix.platform.cross-version }}
|
cross-version: ${{ matrix.platform.cross-version }}
|
||||||
cache-cross-binary: ${{ matrix.platform.cache-cross-binary }}
|
cache-cross-binary: ${{ matrix.platform.cache-cross-binary }}
|
||||||
target: ${{ matrix.platform.target }}
|
target: ${{ matrix.platform.target }}
|
||||||
|
toolchain: ${{ matrix.platform.toolchain || 'stable' }}
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
strip: true
|
strip: true
|
||||||
- name: Check binary and cross for main crate on ${{ matrix.platform.platform_name }}
|
- 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 }}
|
cache-cross-binary: ${{ matrix.platform.cache-cross-binary }}
|
||||||
working-directory: subcrate
|
working-directory: subcrate
|
||||||
target: ${{ matrix.platform.target }}
|
target: ${{ matrix.platform.target }}
|
||||||
|
toolchain: ${{ matrix.platform.toolchain || 'stable' }}
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
strip: true
|
strip: true
|
||||||
- name: Check binary and cross for subcrate on ${{ matrix.platform.platform_name }}
|
- 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 }}
|
cache-cross-binary: ${{ matrix.platform.cache-cross-binary }}
|
||||||
target: ${{ matrix.platform.target }}
|
target: ${{ matrix.platform.target }}
|
||||||
working-directory: bench
|
working-directory: bench
|
||||||
|
toolchain: ${{ matrix.platform.toolchain || 'stable' }}
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
if: ${{ matrix.platform.can-execute }}
|
if: ${{ matrix.platform.can-execute }}
|
||||||
|
|
||||||
|
|||||||
@ -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
|
## 1.0.3 - 2025-02-17
|
||||||
|
|
||||||
- Fixed a bug when running with a Linux ARM host where the action would use a cached `cross`
|
- Fixed a bug when running with a Linux ARM host where the action would use a cached `cross`
|
||||||
|
|||||||
@ -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. |
|
| `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`. |
|
| `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 (`.`). |
|
| `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 }}`. |
|
| `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`. |
|
| `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. |
|
| `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. |
|
||||||
|
|||||||
14
action.yml
14
action.yml
@ -20,7 +20,7 @@ inputs:
|
|||||||
|
|
||||||
toolchain:
|
toolchain:
|
||||||
description: |
|
description: |
|
||||||
The target toolchain to use (one of "stable", "beta", or "nightly").
|
The target toolchain to use.
|
||||||
default: stable
|
default: stable
|
||||||
|
|
||||||
working-directory:
|
working-directory:
|
||||||
@ -195,7 +195,7 @@ runs:
|
|||||||
working-directory: ${{ inputs.working-directory }}
|
working-directory: ${{ inputs.working-directory }}
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
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'
|
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
|
# 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 }}
|
working-directory: ${{ inputs.working-directory }}
|
||||||
shell: powershell
|
shell: powershell
|
||||||
run: |
|
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'
|
if: steps.determine-cargo-commands.outputs.test == 'true' && runner.os == 'Windows'
|
||||||
|
|
||||||
- name: Run benchmarks (*nix)
|
- name: Run benchmarks (*nix)
|
||||||
working-directory: ${{ inputs.working-directory }}
|
working-directory: ${{ inputs.working-directory }}
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
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'
|
if: steps.determine-cargo-commands.outputs.bench == 'true' && runner.os != 'Windows'
|
||||||
|
|
||||||
- name: Run benchmarks (Windows)
|
- name: Run benchmarks (Windows)
|
||||||
working-directory: ${{ inputs.working-directory }}
|
working-directory: ${{ inputs.working-directory }}
|
||||||
shell: powershell
|
shell: powershell
|
||||||
run: |
|
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'
|
if: steps.determine-cargo-commands.outputs.bench == 'true' && runner.os == 'Windows'
|
||||||
|
|
||||||
- name: Build binary (*nix)
|
- name: Build binary (*nix)
|
||||||
working-directory: ${{ inputs.working-directory }}
|
working-directory: ${{ inputs.working-directory }}
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
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'
|
if: steps.determine-cargo-commands.outputs.build == 'true' && runner.os != 'Windows'
|
||||||
|
|
||||||
- name: Build binary (Windows)
|
- name: Build binary (Windows)
|
||||||
working-directory: ${{ inputs.working-directory }}
|
working-directory: ${{ inputs.working-directory }}
|
||||||
shell: powershell
|
shell: powershell
|
||||||
run: |
|
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'
|
if: steps.determine-cargo-commands.outputs.build == 'true' && runner.os == 'Windows'
|
||||||
|
|
||||||
- name: Strip binary
|
- name: Strip binary
|
||||||
|
|||||||
@ -50,14 +50,6 @@ class InputValidator:
|
|||||||
f"Invalid 'command'. Must be one of {sorted(valid_commands)}"
|
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
|
# Validate working directory if present
|
||||||
if "working_directory" in self.inputs:
|
if "working_directory" in self.inputs:
|
||||||
path = Path(self.inputs["working_directory"])
|
path = Path(self.inputs["working_directory"])
|
||||||
@ -162,7 +154,13 @@ class TestInputValidator(unittest.TestCase):
|
|||||||
|
|
||||||
def test_validate_valid_toolchain(self) -> None:
|
def test_validate_valid_toolchain(self) -> None:
|
||||||
"""Test validation of valid toolchains."""
|
"""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:
|
for toolchain in valid_toolchains:
|
||||||
self.setup_env(
|
self.setup_env(
|
||||||
@ -172,13 +170,6 @@ class TestInputValidator(unittest.TestCase):
|
|||||||
errors = validator.validate()
|
errors = validator.validate()
|
||||||
self.assertFalse(errors, f"Toolchain '{toolchain}' should be valid")
|
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:
|
def test_validate_working_directory(self) -> None:
|
||||||
"""Test validation of working directory."""
|
"""Test validation of working directory."""
|
||||||
with tempfile.TemporaryDirectory() as temp_dir:
|
with tempfile.TemporaryDirectory() as temp_dir:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user