Compare commits
10 Commits
d2db46a173
...
a448c4b137
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a448c4b137 | ||
|
|
f7da401093 | ||
|
|
ea9defd544 | ||
|
|
7cb7930e5c | ||
|
|
f6a193191b | ||
|
|
91c5b34b70 | ||
|
|
ddb18cfff9 | ||
|
|
329eb5fa43 | ||
|
|
56f0ba980e | ||
|
|
e2ab1c3836 |
137
.github/workflows/test.yml
vendored
137
.github/workflows/test.yml
vendored
@ -11,7 +11,7 @@ jobs:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
platform:
|
||||
- platform_name: FreeBSD-x86_64
|
||||
- name: FreeBSD-x86_64
|
||||
runs-on: ubuntu-24.04
|
||||
target: x86_64-unknown-freebsd
|
||||
cache-cross-binary: true
|
||||
@ -20,7 +20,7 @@ jobs:
|
||||
expect-stripped: ""
|
||||
can-execute: false
|
||||
|
||||
- platform_name: Linux-x86_64
|
||||
- name: Linux-x86_64
|
||||
runs-on: ubuntu-24.04
|
||||
# It's important to use a musl target here to make sure that the step to install
|
||||
# musl-tools works.
|
||||
@ -31,7 +31,27 @@ jobs:
|
||||
expect-stripped: "--expect-stripped"
|
||||
can-execute: true
|
||||
|
||||
- platform_name: Linux-x86_64 (force cross)
|
||||
- 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
|
||||
|
||||
- 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
|
||||
|
||||
- name: Linux-x86_64 (force cross)
|
||||
runs-on: ubuntu-24.04
|
||||
target: x86_64-unknown-linux-gnu
|
||||
force-use-cross: true
|
||||
@ -41,7 +61,17 @@ jobs:
|
||||
expect-stripped: ""
|
||||
can-execute: true
|
||||
|
||||
- platform_name: Linux-aarch64
|
||||
- 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
|
||||
|
||||
- name: Linux-aarch64
|
||||
runs-on: ubuntu-24.04
|
||||
target: aarch64-unknown-linux-musl
|
||||
cache-cross-binary: true
|
||||
@ -50,7 +80,7 @@ jobs:
|
||||
expect-stripped: ""
|
||||
can-execute: true
|
||||
|
||||
- platform_name: Linux-aarch64 (no cache)
|
||||
- name: Linux-aarch64 (no cache)
|
||||
runs-on: ubuntu-24.04
|
||||
target: aarch64-unknown-linux-gnu
|
||||
cache-cross-binary: false
|
||||
@ -59,7 +89,7 @@ jobs:
|
||||
expect-stripped: ""
|
||||
can-execute: true
|
||||
|
||||
- platform_name: Linux-aarch64 with cross v0.2.3
|
||||
- name: Linux-aarch64 with cross v0.2.3
|
||||
runs-on: ubuntu-24.04
|
||||
target: aarch64-unknown-linux-gnu
|
||||
cross-version: "v0.2.3"
|
||||
@ -70,7 +100,7 @@ jobs:
|
||||
expect-stripped: ""
|
||||
can-execute: true
|
||||
|
||||
- platform_name: Linux-aarch64 with cross v0.2.3 (no cache)
|
||||
- name: Linux-aarch64 with cross v0.2.3 (no cache)
|
||||
runs-on: ubuntu-24.04
|
||||
target: aarch64-unknown-linux-gnu
|
||||
cross-version: "v0.2.3"
|
||||
@ -81,7 +111,7 @@ jobs:
|
||||
expect-stripped: ""
|
||||
can-execute: true
|
||||
|
||||
- platform_name: Linux-aarch64 with cross 19be834
|
||||
- name: Linux-aarch64 with cross 19be834
|
||||
runs-on: ubuntu-24.04
|
||||
target: aarch64-unknown-linux-gnu
|
||||
cross-version: "19be834"
|
||||
@ -92,7 +122,7 @@ jobs:
|
||||
expect-stripped: ""
|
||||
can-execute: true
|
||||
|
||||
- platform_name: Linux-aarch64 with cross 19be834 (no cache)
|
||||
- name: Linux-aarch64 with cross 19be834 (no cache)
|
||||
runs-on: ubuntu-24.04
|
||||
target: aarch64-unknown-linux-gnu
|
||||
cross-version: "19be834"
|
||||
@ -103,7 +133,7 @@ jobs:
|
||||
expect-stripped: ""
|
||||
can-execute: true
|
||||
|
||||
- platform_name: Linux-aarch64 with arm64 host
|
||||
- name: Linux-aarch64 with arm64 host
|
||||
runs-on: ubuntu-24.04-arm
|
||||
target: aarch64-unknown-linux-gnu
|
||||
cache-cross-binary: true
|
||||
@ -117,7 +147,7 @@ jobs:
|
||||
# cross-compiling on Linux ARM won't work without a custom Docker image, which I don't
|
||||
# want to do just for the sake of testing this.
|
||||
#
|
||||
# - platform_name: Linux-aarch64 with arm64 host compile to x86-64
|
||||
# - name: Linux-aarch64 with arm64 host compile to x86-64
|
||||
# runs-on: ubuntu-24.04-arm
|
||||
# target: x86_64-unknown-linux-gnu
|
||||
# # Until cross produces arm64 binary releases we _have_ to set this when running on
|
||||
@ -129,7 +159,7 @@ jobs:
|
||||
# expect-stripped: ""
|
||||
# can-execute: true
|
||||
|
||||
- platform_name: Linux-arm
|
||||
- name: Linux-arm
|
||||
runs-on: ubuntu-24.04
|
||||
target: arm-unknown-linux-gnueabi
|
||||
cache-cross-binary: true
|
||||
@ -138,7 +168,7 @@ jobs:
|
||||
expect-stripped: ""
|
||||
can-execute: true
|
||||
|
||||
- platform_name: Linux-i586
|
||||
- name: Linux-i586
|
||||
runs-on: ubuntu-24.04
|
||||
target: i586-unknown-linux-gnu
|
||||
cache-cross-binary: true
|
||||
@ -147,7 +177,7 @@ jobs:
|
||||
expect-stripped: ""
|
||||
can-execute: true
|
||||
|
||||
- platform_name: Linux-i686
|
||||
- name: Linux-i686
|
||||
runs-on: ubuntu-24.04
|
||||
target: i686-unknown-linux-gnu
|
||||
cache-cross-binary: true
|
||||
@ -156,7 +186,7 @@ jobs:
|
||||
expect-stripped: ""
|
||||
can-execute: true
|
||||
|
||||
- platform_name: Linux-powerpc
|
||||
- name: Linux-powerpc
|
||||
runs-on: ubuntu-24.04
|
||||
target: powerpc-unknown-linux-gnu
|
||||
cache-cross-binary: true
|
||||
@ -165,7 +195,7 @@ jobs:
|
||||
expect-stripped: ""
|
||||
can-execute: true
|
||||
|
||||
- platform_name: Linux-powerpc64
|
||||
- name: Linux-powerpc64
|
||||
runs-on: ubuntu-24.04
|
||||
target: powerpc64-unknown-linux-gnu
|
||||
cache-cross-binary: true
|
||||
@ -174,7 +204,7 @@ jobs:
|
||||
expect-stripped: ""
|
||||
can-execute: true
|
||||
|
||||
- platform_name: Linux-powerpc64le
|
||||
- name: Linux-powerpc64le
|
||||
runs-on: ubuntu-24.04
|
||||
target: powerpc64le-unknown-linux-gnu
|
||||
cache-cross-binary: true
|
||||
@ -183,7 +213,7 @@ jobs:
|
||||
expect-stripped: ""
|
||||
can-execute: true
|
||||
|
||||
- platform_name: Linux-riscv64
|
||||
- name: Linux-riscv64
|
||||
runs-on: ubuntu-24.04
|
||||
target: riscv64gc-unknown-linux-gnu
|
||||
cache-cross-binary: true
|
||||
@ -192,7 +222,7 @@ jobs:
|
||||
expect-stripped: ""
|
||||
can-execute: true
|
||||
|
||||
- platform_name: Linux-s390x
|
||||
- name: Linux-s390x
|
||||
runs-on: ubuntu-24.04
|
||||
target: s390x-unknown-linux-gnu
|
||||
cache-cross-binary: true
|
||||
@ -201,7 +231,7 @@ jobs:
|
||||
expect-stripped: ""
|
||||
can-execute: true
|
||||
|
||||
- platform_name: NetBSD-x86_64
|
||||
- name: NetBSD-x86_64
|
||||
runs-on: ubuntu-24.04
|
||||
target: x86_64-unknown-netbsd
|
||||
cache-cross-binary: true
|
||||
@ -210,33 +240,33 @@ jobs:
|
||||
expect-stripped: ""
|
||||
can-execute: false
|
||||
|
||||
- platform_name: Windows-aarch64
|
||||
- name: Windows-aarch64
|
||||
runs-on: windows-latest
|
||||
target: aarch64-pc-windows-msvc
|
||||
cache-cross-binary: true
|
||||
expect-file-re: "Aarch64.+Windows"
|
||||
expect-file-re: "Windows.+ARM64"
|
||||
expect-cross: ""
|
||||
expect-stripped: ""
|
||||
can-execute: false
|
||||
|
||||
- platform_name: Windows-i686
|
||||
- name: Windows-i686
|
||||
runs-on: windows-latest
|
||||
target: i686-pc-windows-msvc
|
||||
cache-cross-binary: true
|
||||
expect-file-re: "80386.+Windows"
|
||||
expect-file-re: "Windows.+Intel i386"
|
||||
expect-cross: ""
|
||||
expect-stripped: "--expect-stripped"
|
||||
can-execute: true
|
||||
|
||||
- platform_name: Windows-x86_64
|
||||
- name: Windows-x86_64
|
||||
runs-on: windows-latest
|
||||
target: x86_64-pc-windows-msvc
|
||||
cache-cross-binary: true
|
||||
expect-file-re: "x86-64.+Windows"
|
||||
expect-file-re: "Windows.+x86-64"
|
||||
expect-stripped: "--expect-stripped"
|
||||
can-execute: true
|
||||
|
||||
- platform_name: macOS-x86_64
|
||||
- name: macOS-x86_64
|
||||
runs-on: macOS-latest
|
||||
target: x86_64-apple-darwin
|
||||
cache-cross-binary: true
|
||||
@ -245,7 +275,7 @@ jobs:
|
||||
expect-stripped: "--expect-stripped"
|
||||
can-execute: true
|
||||
|
||||
- platform_name: macOS-aarch64
|
||||
- name: macOS-aarch64
|
||||
runs-on: macOS-latest
|
||||
target: aarch64-apple-darwin
|
||||
cache-cross-binary: true
|
||||
@ -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,9 +335,10 @@ 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 }}
|
||||
- name: Check binary and cross for main crate on ${{ matrix.platform.name }}
|
||||
shell: bash
|
||||
run: |
|
||||
set -e
|
||||
@ -325,9 +359,10 @@ 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 }}
|
||||
- name: Check binary and cross for subcrate on ${{ matrix.platform.name }}
|
||||
shell: bash
|
||||
run: |
|
||||
set -e
|
||||
@ -349,8 +384,16 @@ 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 }}
|
||||
- name: Upload build artifacts
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: build-artifacts-${{ matrix.platform.name }}
|
||||
path: |
|
||||
target/${{ matrix.platform.target }}/debug/bin*
|
||||
subcrate/target/${{ matrix.platform.target }}/debug/subcrate
|
||||
|
||||
test-validate-inputs:
|
||||
name: Test validate-inputs
|
||||
@ -361,3 +404,37 @@ jobs:
|
||||
- name: Run tests
|
||||
shell: bash
|
||||
run: ./validate-inputs.py --test
|
||||
|
||||
test-other-cargo-commands:
|
||||
name: Test a "cargo foo" command
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
- name: Copy test project to root
|
||||
shell: bash
|
||||
run: |
|
||||
cp -a test-project/* .
|
||||
rm -fr test-project
|
||||
- name: Create cargo-foo command
|
||||
shell: bash
|
||||
run: |
|
||||
set -e
|
||||
set -x
|
||||
|
||||
dir="${{ github.workspace }}/bin"
|
||||
mkdir -p "$dir"
|
||||
|
||||
bin="$dir/cargo-foo"
|
||||
|
||||
echo "#!/bin/bash" >> "$bin"
|
||||
echo "echo 'This is cargo-foo!'" >> "$bin"
|
||||
echo "exit 0" >> "$bin"
|
||||
chmod 0755 "$bin"
|
||||
|
||||
echo "PATH=$dir:$PATH" >> "$GITHUB_ENV"
|
||||
- name: Run cargo-foo command
|
||||
uses: ./
|
||||
with:
|
||||
command: foo
|
||||
target: x86_64-unknown-linux-gnu
|
||||
|
||||
14
Changes.md
14
Changes.md
@ -1,8 +1,20 @@
|
||||
## 1.0.4 - 2025-04-12
|
||||
|
||||
- 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.
|
||||
- Removed validation for the `command` input. This allows you to use this action with any `cargo`
|
||||
extension command, like `cargo-deb`. Setting `command` to `both` is still supported and will run
|
||||
the `build` and `test` commands. Requested by @bvaisvil (Benjamin Vaisvil). GH #43.
|
||||
|
||||
## 1.0.3 - 2025-02-17
|
||||
|
||||
- Fixed a bug when running with an ARM Linux 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`
|
||||
download for x86-64 Linux (or vice versa). Now the cache key for the `cross` binary includes both
|
||||
the runner's architecture in addition to its OS.
|
||||
- This release partially support running on Linxu ARM, but see the `README.md` file for details on
|
||||
this.
|
||||
|
||||
## 1.0.2 - 2025-02-16
|
||||
|
||||
|
||||
28
README.md
28
README.md
@ -46,7 +46,7 @@ jobs:
|
||||
- name: Build binary
|
||||
uses: houseabsolute/actions-rust-cross@v1
|
||||
with:
|
||||
command: ${{ matrix.platform.command }}
|
||||
command: build
|
||||
target: ${{ matrix.platform.target }}
|
||||
args: "--locked --release"
|
||||
strip: true
|
||||
@ -69,19 +69,19 @@ Ubuntu x86-64, Windows, and macOS runners.
|
||||
|
||||
This action takes the following parameters:
|
||||
|
||||
| Key | Type | Required? | Description |
|
||||
| ----------------------- | -------------------------------------------------------------------- | --------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| `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`. |
|
||||
| `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. |
|
||||
| `cross-version` | string | no | This can be used to set the version of `cross` to use. If specified, it should be a specific `cross` release tag (like `v0.2.3`) or a git ref (commit hash, `HEAD`, etc.). If this is not set then the latest released version will always be used. If this is set to a git ref then the version corresponding to that ref will be installed. |
|
||||
| `force-use-cross` | boolean (`true` or `false`) | no | If this is true, then the action will use `cross` even if it is not needed for the given target. If this is set to `true`, then the resulting binary will not be stripped, regardless of whether `strip` is `true` or not. This only works on Linux hosts. Forcing the use of `cross` on other hosts is not supported. |
|
||||
| `use-rust-cache` | boolean | no | Whether or not to use [the `Swatinem/rust-cache@v2` action](https://github.com/Swatinem/rust-cache). This defaults to true. |
|
||||
| `rust-cache-parameters` | string (containing JSON) | no | This must be a string containing valid JSON. The JSON should be an object where the keys are the parameters for [the `Swatinem/rust-cache@v2` action](https://github.com/Swatinem/rust-cache). |
|
||||
| Key | Type | Required? | Description |
|
||||
| ----------------------- | --------------------------- | --------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| `command` | string | no | The command(s) to run. The default is `build`. Running the `test` command will fail with \*BSD targets and non-x86 Windows. You can use any command supported by `cargo` and/or `cross`. For example, if you install `cargo-deb`, the command can be `deb`. Use the special string "both" to run both `build` and `test. |
|
||||
| `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) | 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. |
|
||||
| `cross-version` | string | no | This can be used to set the version of `cross` to use. If specified, it should be a specific `cross` release tag (like `v0.2.3`) or a git ref (commit hash, `HEAD`, etc.). If this is not set then the latest released version will always be used. If this is set to a git ref then the version corresponding to that ref will be installed. |
|
||||
| `force-use-cross` | boolean (`true` or `false`) | no | If this is true, then the action will use `cross` even if it is not needed for the given target. If this is set to `true`, then the resulting binary will not be stripped, regardless of whether `strip` is `true` or not. This only works on Linux hosts. Forcing the use of `cross` on other hosts is not supported. |
|
||||
| `use-rust-cache` | boolean | no | Whether or not to use [the `Swatinem/rust-cache@v2` action](https://github.com/Swatinem/rust-cache). This defaults to true. |
|
||||
| `rust-cache-parameters` | string (containing JSON) | no | This must be a string containing valid JSON. The JSON should be an object where the keys are the parameters for [the `Swatinem/rust-cache@v2` action](https://github.com/Swatinem/rust-cache). |
|
||||
|
||||
### Setting Environment Variables
|
||||
|
||||
|
||||
62
action.yml
62
action.yml
@ -15,12 +15,12 @@ inputs:
|
||||
|
||||
command:
|
||||
description: |
|
||||
The commands to run. This must be one of "build", "test", "both" (build and test), or "bench".
|
||||
The commands to run. Use "both" to run both "build" and "test".
|
||||
default: build
|
||||
|
||||
toolchain:
|
||||
description: |
|
||||
The target toolchain to use (one of "stable", "beta", or "nightly").
|
||||
The target toolchain to use.
|
||||
default: stable
|
||||
|
||||
working-directory:
|
||||
@ -191,51 +191,35 @@ runs:
|
||||
with: ${{ steps.parse-rust-cache-parameters.outputs }}
|
||||
if: inputs.use-rust-cache == 'true'
|
||||
|
||||
- name: Run tests (*nix)
|
||||
- name: Run cargo test
|
||||
working-directory: ${{ inputs.working-directory }}
|
||||
shell: bash
|
||||
# We want to run in Powershell on Windows to make sure we compile in a native Windows
|
||||
# environment. Some things won't compile properly under msys, notably OpenSSL, which is
|
||||
# compiled locally when using the `openssl` crate with the `vendored` feature.
|
||||
shell: ${{ runner.os == 'Windows' && 'powershell' || 'bash' }}
|
||||
run: |
|
||||
${{ steps.set-build-command.outputs.build-command }} +${{inputs.toolchain}} test --target ${{ inputs.target }} ${{ inputs.args }}
|
||||
if: steps.determine-cargo-commands.outputs.test == 'true' && runner.os != 'Windows'
|
||||
${{ steps.set-build-command.outputs.build-command }} test --target ${{ inputs.target }} ${{ inputs.args }}
|
||||
if: steps.determine-cargo-commands.outputs.test == 'true'
|
||||
|
||||
# We want to run in Powershell on Windows to make sure we compile in a
|
||||
# native Windows environment. Some things won't compile properly under
|
||||
# msys, notably OpenSSL, which is compiled locally when using the
|
||||
# `openssl` crate with the `vendored` feature.
|
||||
- name: Run tests (Windows)
|
||||
- name: Run cargo build
|
||||
working-directory: ${{ inputs.working-directory }}
|
||||
shell: powershell
|
||||
# We want to run in Powershell on Windows to make sure we compile in a native Windows
|
||||
# environment. Some things won't compile properly under msys, notably OpenSSL, which is
|
||||
# compiled locally when using the `openssl` crate with the `vendored` feature.
|
||||
shell: ${{ runner.os == 'Windows' && 'powershell' || 'bash' }}
|
||||
run: |
|
||||
& ${{ steps.set-build-command.outputs.build-command }} +${{inputs.toolchain}} test --target ${{ inputs.target }} ${{ inputs.args }}
|
||||
if: steps.determine-cargo-commands.outputs.test == 'true' && runner.os == 'Windows'
|
||||
${{ steps.set-build-command.outputs.build-command }} build --target ${{ inputs.target }} ${{ inputs.args }}
|
||||
if: steps.determine-cargo-commands.outputs.build == 'true'
|
||||
|
||||
- name: Run benchmarks (*nix)
|
||||
- name: Run cargo ${{ steps.determine-cargo-commands.outputs.command }}
|
||||
working-directory: ${{ inputs.working-directory }}
|
||||
shell: bash
|
||||
# We want to run in Powershell on Windows to make sure we compile in a native Windows
|
||||
# environment. Some things won't compile properly under msys, notably OpenSSL, which is
|
||||
# compiled locally when using the `openssl` crate with the `vendored` feature.
|
||||
shell: ${{ runner.os == 'Windows' && 'powershell' || 'bash' }}
|
||||
run: |
|
||||
${{ steps.set-build-command.outputs.build-command }} +${{inputs.toolchain}} 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 }}
|
||||
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 }}
|
||||
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 }}
|
||||
if: steps.determine-cargo-commands.outputs.build == 'true' && runner.os == 'Windows'
|
||||
${{ steps.set-build-command.outputs.build-command }} ${{ steps.determine-cargo-commands.outputs.command }} --target ${{ inputs.target }} ${{ inputs.args }}
|
||||
if: steps.determine-cargo-commands.outputs.command != ''
|
||||
|
||||
- name: Strip binary
|
||||
working-directory: ${{ inputs.working-directory }}
|
||||
|
||||
@ -9,5 +9,5 @@ if [ "$COMMAND" == 'both' ]; then
|
||||
echo "build=true" >>"$GITHUB_OUTPUT"
|
||||
echo "test=true" >>"$GITHUB_OUTPUT"
|
||||
else
|
||||
echo "$COMMAND=true" >>"$GITHUB_OUTPUT"
|
||||
echo "command=$COMMAND" >>"$GITHUB_OUTPUT"
|
||||
fi
|
||||
|
||||
@ -122,12 +122,16 @@ fn check_binary(bin_path: &PathBuf, expect_file_re: Option<&str>, expect_strippe
|
||||
.output()
|
||||
.expect("Failed to execute `file` command");
|
||||
let file_output = String::from_utf8_lossy(&output.stdout);
|
||||
println!(
|
||||
"output from `file` for {}: {file_output}",
|
||||
bin_path.display(),
|
||||
);
|
||||
|
||||
if let Some(file_re) = expect_file_re {
|
||||
let re = Regex::new(file_re).expect("Invalid regex");
|
||||
assert!(
|
||||
re.is_match(&file_output),
|
||||
"`file` output for {} matches expected output",
|
||||
"`file` output for {} matches `{file_re}`: `{file_output}`",
|
||||
bin_path.display(),
|
||||
);
|
||||
}
|
||||
@ -140,29 +144,25 @@ fn check_binary(bin_path: &PathBuf, expect_file_re: Option<&str>, expect_strippe
|
||||
if expect_stripped {
|
||||
assert!(
|
||||
!file_output.contains("not stripped"),
|
||||
"`file` does not report {} as 'not stripped': `{}`",
|
||||
"`file` does not report {} as 'not stripped': `{file_output}`",
|
||||
bin_path.display(),
|
||||
file_output,
|
||||
);
|
||||
assert!(
|
||||
file_output.contains("stripped"),
|
||||
"`file` reports {} as 'stripped': `{}`",
|
||||
"`file` reports {} as 'stripped': `{file_output}`",
|
||||
bin_path.display(),
|
||||
file_output,
|
||||
);
|
||||
} else if cfg!(windows) {
|
||||
assert!(
|
||||
!file_output.contains("stripped"),
|
||||
"`file` does not report {} as 'stripped': `{}`",
|
||||
"`file` does not report {} as 'stripped': `{file_output}`",
|
||||
bin_path.display(),
|
||||
file_output,
|
||||
);
|
||||
} else {
|
||||
assert!(
|
||||
file_output.contains("not stripped"),
|
||||
"`file` reports {} as 'not stripped': `{}`",
|
||||
"`file` reports {} as 'not stripped': `{file_output}`",
|
||||
bin_path.display(),
|
||||
file_output,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -42,22 +42,6 @@ class InputValidator:
|
||||
if "target" not in self.inputs:
|
||||
validation_errors.append("'target' is a required parameter")
|
||||
|
||||
# Validate command if present
|
||||
if "command" in self.inputs:
|
||||
valid_commands = {"build", "test", "both", "bench"}
|
||||
if self.inputs["command"] not in valid_commands:
|
||||
validation_errors.append(
|
||||
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"])
|
||||
@ -143,26 +127,15 @@ class TestInputValidator(unittest.TestCase):
|
||||
errors = validator.validate()
|
||||
self.assertTrue(errors)
|
||||
|
||||
def test_validate_valid_command(self) -> None:
|
||||
"""Test validation of valid commands."""
|
||||
valid_commands = ["build", "test", "both", "bench"]
|
||||
|
||||
for command in valid_commands:
|
||||
self.setup_env({"target": "x86_64-unknown-linux-gnu", "command": command})
|
||||
validator = InputValidator("/root")
|
||||
errors = validator.validate()
|
||||
self.assertFalse(errors, f"Command '{command}' should be valid")
|
||||
|
||||
def test_validate_invalid_command(self) -> None:
|
||||
"""Test validation of invalid command."""
|
||||
self.setup_env({"target": "x86_64-unknown-linux-gnu", "command": "invalid"})
|
||||
validator = InputValidator("/root")
|
||||
errors = validator.validate()
|
||||
self.assertTrue(errors)
|
||||
|
||||
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 +145,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:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user