Compare commits
12 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
601d02e82d | ||
|
|
2c7c51e283 | ||
|
|
9a022034a6 | ||
|
|
dc1022bc69 | ||
|
|
b4ab796093 | ||
|
|
b094471e7c | ||
|
|
885ad4bc41 | ||
|
|
c40b27b8f9 | ||
|
|
7619b10b9f | ||
|
|
a72a5f146c | ||
|
|
f0ceffbf58 | ||
|
|
c04b5a0b3e |
2
.github/workflows/lint.yml
vendored
2
.github/workflows/lint.yml
vendored
@@ -8,7 +8,7 @@ env:
|
|||||||
jobs:
|
jobs:
|
||||||
lint:
|
lint:
|
||||||
name: Check that code is lint clean using precious
|
name: Check that code is lint clean using precious
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-24.04
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- name: Install mise
|
- name: Install mise
|
||||||
|
|||||||
72
.github/workflows/test.yml
vendored
72
.github/workflows/test.yml
vendored
@@ -12,7 +12,7 @@ jobs:
|
|||||||
matrix:
|
matrix:
|
||||||
platform:
|
platform:
|
||||||
- platform_name: FreeBSD-x86_64
|
- platform_name: FreeBSD-x86_64
|
||||||
runs-on: ubuntu-22.04
|
runs-on: ubuntu-24.04
|
||||||
target: x86_64-unknown-freebsd
|
target: x86_64-unknown-freebsd
|
||||||
cache-cross-binary: true
|
cache-cross-binary: true
|
||||||
expect-file-re: "x86-64.+FreeBSD"
|
expect-file-re: "x86-64.+FreeBSD"
|
||||||
@@ -21,7 +21,9 @@ jobs:
|
|||||||
can-execute: false
|
can-execute: false
|
||||||
|
|
||||||
- platform_name: Linux-x86_64
|
- platform_name: Linux-x86_64
|
||||||
runs-on: ubuntu-22.04
|
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.
|
||||||
target: x86_64-unknown-linux-musl
|
target: x86_64-unknown-linux-musl
|
||||||
cache-cross-binary: true
|
cache-cross-binary: true
|
||||||
expect-file-re: "ELF.+x86-64"
|
expect-file-re: "ELF.+x86-64"
|
||||||
@@ -29,8 +31,18 @@ jobs:
|
|||||||
expect-stripped: "--expect-stripped"
|
expect-stripped: "--expect-stripped"
|
||||||
can-execute: true
|
can-execute: true
|
||||||
|
|
||||||
|
- platform_name: Linux-x86_64 (force cross)
|
||||||
|
runs-on: ubuntu-24.04
|
||||||
|
target: x86_64-unknown-linux-gnu
|
||||||
|
force-use-cross: true
|
||||||
|
cache-cross-binary: true
|
||||||
|
expect-file-re: "ELF.+x86-64"
|
||||||
|
expect-cross: "--expect-cross"
|
||||||
|
expect-stripped: ""
|
||||||
|
can-execute: true
|
||||||
|
|
||||||
- platform_name: Linux-aarch64
|
- platform_name: Linux-aarch64
|
||||||
runs-on: ubuntu-22.04
|
runs-on: ubuntu-24.04
|
||||||
target: aarch64-unknown-linux-musl
|
target: aarch64-unknown-linux-musl
|
||||||
cache-cross-binary: true
|
cache-cross-binary: true
|
||||||
expect-file-re: "aarch64"
|
expect-file-re: "aarch64"
|
||||||
@@ -39,8 +51,8 @@ jobs:
|
|||||||
can-execute: true
|
can-execute: true
|
||||||
|
|
||||||
- platform_name: Linux-aarch64 (no cache)
|
- platform_name: Linux-aarch64 (no cache)
|
||||||
runs-on: ubuntu-22.04
|
runs-on: ubuntu-24.04
|
||||||
target: aarch64-unknown-linux-musl
|
target: aarch64-unknown-linux-gnu
|
||||||
cache-cross-binary: false
|
cache-cross-binary: false
|
||||||
expect-file-re: "aarch64"
|
expect-file-re: "aarch64"
|
||||||
expect-cross: "--expect-cross"
|
expect-cross: "--expect-cross"
|
||||||
@@ -48,8 +60,8 @@ jobs:
|
|||||||
can-execute: true
|
can-execute: true
|
||||||
|
|
||||||
- platform_name: Linux-aarch64 with cross v0.2.3
|
- platform_name: Linux-aarch64 with cross v0.2.3
|
||||||
runs-on: ubuntu-22.04
|
runs-on: ubuntu-24.04
|
||||||
target: aarch64-unknown-linux-musl
|
target: aarch64-unknown-linux-gnu
|
||||||
cross-version: "v0.2.3"
|
cross-version: "v0.2.3"
|
||||||
cache-cross-binary: true
|
cache-cross-binary: true
|
||||||
expect-file-re: "aarch64"
|
expect-file-re: "aarch64"
|
||||||
@@ -59,8 +71,8 @@ jobs:
|
|||||||
can-execute: true
|
can-execute: true
|
||||||
|
|
||||||
- platform_name: Linux-aarch64 with cross v0.2.3 (no cache)
|
- platform_name: Linux-aarch64 with cross v0.2.3 (no cache)
|
||||||
runs-on: ubuntu-22.04
|
runs-on: ubuntu-24.04
|
||||||
target: aarch64-unknown-linux-musl
|
target: aarch64-unknown-linux-gnu
|
||||||
cross-version: "v0.2.3"
|
cross-version: "v0.2.3"
|
||||||
cache-cross-binary: false
|
cache-cross-binary: false
|
||||||
expect-file-re: "aarch64"
|
expect-file-re: "aarch64"
|
||||||
@@ -70,8 +82,8 @@ jobs:
|
|||||||
can-execute: true
|
can-execute: true
|
||||||
|
|
||||||
- platform_name: Linux-aarch64 with cross 19be834
|
- platform_name: Linux-aarch64 with cross 19be834
|
||||||
runs-on: ubuntu-22.04
|
runs-on: ubuntu-24.04
|
||||||
target: aarch64-unknown-linux-musl
|
target: aarch64-unknown-linux-gnu
|
||||||
cross-version: "19be834"
|
cross-version: "19be834"
|
||||||
cache-cross-binary: true
|
cache-cross-binary: true
|
||||||
expect-file-re: "aarch64"
|
expect-file-re: "aarch64"
|
||||||
@@ -80,9 +92,9 @@ jobs:
|
|||||||
expect-stripped: ""
|
expect-stripped: ""
|
||||||
can-execute: true
|
can-execute: true
|
||||||
|
|
||||||
- platform_name: Linux-aarch64 with cross 19be834
|
- platform_name: Linux-aarch64 with cross 19be834 (no cache)
|
||||||
runs-on: ubuntu-22.04
|
runs-on: ubuntu-24.04
|
||||||
target: aarch64-unknown-linux-musl
|
target: aarch64-unknown-linux-gnu
|
||||||
cross-version: "19be834"
|
cross-version: "19be834"
|
||||||
cache-cross-binary: false
|
cache-cross-binary: false
|
||||||
expect-file-re: "aarch64"
|
expect-file-re: "aarch64"
|
||||||
@@ -92,8 +104,8 @@ jobs:
|
|||||||
can-execute: true
|
can-execute: true
|
||||||
|
|
||||||
- platform_name: Linux-arm
|
- platform_name: Linux-arm
|
||||||
runs-on: ubuntu-22.04
|
runs-on: ubuntu-24.04
|
||||||
target: arm-unknown-linux-musleabi
|
target: arm-unknown-linux-gnueabi
|
||||||
cache-cross-binary: true
|
cache-cross-binary: true
|
||||||
expect-file-re: "32.+ARM"
|
expect-file-re: "32.+ARM"
|
||||||
expect-cross: "--expect-cross"
|
expect-cross: "--expect-cross"
|
||||||
@@ -101,8 +113,8 @@ jobs:
|
|||||||
can-execute: true
|
can-execute: true
|
||||||
|
|
||||||
- platform_name: Linux-i586
|
- platform_name: Linux-i586
|
||||||
runs-on: ubuntu-22.04
|
runs-on: ubuntu-24.04
|
||||||
target: i586-unknown-linux-musl
|
target: i586-unknown-linux-gnu
|
||||||
cache-cross-binary: true
|
cache-cross-binary: true
|
||||||
expect-file-re: "ELF.+80386"
|
expect-file-re: "ELF.+80386"
|
||||||
expect-cross: "--expect-cross"
|
expect-cross: "--expect-cross"
|
||||||
@@ -110,8 +122,8 @@ jobs:
|
|||||||
can-execute: true
|
can-execute: true
|
||||||
|
|
||||||
- platform_name: Linux-i686
|
- platform_name: Linux-i686
|
||||||
runs-on: ubuntu-22.04
|
runs-on: ubuntu-24.04
|
||||||
target: i686-unknown-linux-musl
|
target: i686-unknown-linux-gnu
|
||||||
cache-cross-binary: true
|
cache-cross-binary: true
|
||||||
expect-file-re: "ELF.+80386"
|
expect-file-re: "ELF.+80386"
|
||||||
expect-cross: "--expect-cross"
|
expect-cross: "--expect-cross"
|
||||||
@@ -119,7 +131,7 @@ jobs:
|
|||||||
can-execute: true
|
can-execute: true
|
||||||
|
|
||||||
- platform_name: Linux-powerpc
|
- platform_name: Linux-powerpc
|
||||||
runs-on: ubuntu-22.04
|
runs-on: ubuntu-24.04
|
||||||
target: powerpc-unknown-linux-gnu
|
target: powerpc-unknown-linux-gnu
|
||||||
cache-cross-binary: true
|
cache-cross-binary: true
|
||||||
expect-file-re: "32.+PowerPC"
|
expect-file-re: "32.+PowerPC"
|
||||||
@@ -128,7 +140,7 @@ jobs:
|
|||||||
can-execute: true
|
can-execute: true
|
||||||
|
|
||||||
- platform_name: Linux-powerpc64
|
- platform_name: Linux-powerpc64
|
||||||
runs-on: ubuntu-22.04
|
runs-on: ubuntu-24.04
|
||||||
target: powerpc64-unknown-linux-gnu
|
target: powerpc64-unknown-linux-gnu
|
||||||
cache-cross-binary: true
|
cache-cross-binary: true
|
||||||
expect-file-re: "64.+PowerPC"
|
expect-file-re: "64.+PowerPC"
|
||||||
@@ -137,7 +149,7 @@ jobs:
|
|||||||
can-execute: true
|
can-execute: true
|
||||||
|
|
||||||
- platform_name: Linux-powerpc64le
|
- platform_name: Linux-powerpc64le
|
||||||
runs-on: ubuntu-22.04
|
runs-on: ubuntu-24.04
|
||||||
target: powerpc64le-unknown-linux-gnu
|
target: powerpc64le-unknown-linux-gnu
|
||||||
cache-cross-binary: true
|
cache-cross-binary: true
|
||||||
expect-file-re: "64.+PowerPC"
|
expect-file-re: "64.+PowerPC"
|
||||||
@@ -146,7 +158,7 @@ jobs:
|
|||||||
can-execute: true
|
can-execute: true
|
||||||
|
|
||||||
- platform_name: Linux-riscv64
|
- platform_name: Linux-riscv64
|
||||||
runs-on: ubuntu-22.04
|
runs-on: ubuntu-24.04
|
||||||
target: riscv64gc-unknown-linux-gnu
|
target: riscv64gc-unknown-linux-gnu
|
||||||
cache-cross-binary: true
|
cache-cross-binary: true
|
||||||
expect-file-re: "64.+RISC-V"
|
expect-file-re: "64.+RISC-V"
|
||||||
@@ -155,7 +167,7 @@ jobs:
|
|||||||
can-execute: true
|
can-execute: true
|
||||||
|
|
||||||
- platform_name: Linux-s390x
|
- platform_name: Linux-s390x
|
||||||
runs-on: ubuntu-22.04
|
runs-on: ubuntu-24.04
|
||||||
target: s390x-unknown-linux-gnu
|
target: s390x-unknown-linux-gnu
|
||||||
cache-cross-binary: true
|
cache-cross-binary: true
|
||||||
expect-file-re: "64.+S/390"
|
expect-file-re: "64.+S/390"
|
||||||
@@ -164,7 +176,7 @@ jobs:
|
|||||||
can-execute: true
|
can-execute: true
|
||||||
|
|
||||||
- platform_name: NetBSD-x86_64
|
- platform_name: NetBSD-x86_64
|
||||||
runs-on: ubuntu-22.04
|
runs-on: ubuntu-24.04
|
||||||
target: x86_64-unknown-netbsd
|
target: x86_64-unknown-netbsd
|
||||||
cache-cross-binary: true
|
cache-cross-binary: true
|
||||||
expect-file-re: "x86-64.+NetBSD"
|
expect-file-re: "x86-64.+NetBSD"
|
||||||
@@ -229,6 +241,7 @@ jobs:
|
|||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
command: both
|
command: both
|
||||||
|
force-use-cross: ${{ matrix.platform.force-use-cross || false }}
|
||||||
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 }}
|
||||||
@@ -238,6 +251,7 @@ jobs:
|
|||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
command: test
|
command: test
|
||||||
|
force-use-cross: ${{ matrix.platform.force-use-cross || false }}
|
||||||
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 }}
|
||||||
@@ -247,6 +261,7 @@ jobs:
|
|||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
command: test
|
command: test
|
||||||
|
force-use-cross: ${{ matrix.platform.force-use-cross || false }}
|
||||||
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 }}
|
||||||
@@ -257,6 +272,7 @@ jobs:
|
|||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
command: build
|
command: build
|
||||||
|
force-use-cross: ${{ matrix.platform.force-use-cross || false }}
|
||||||
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 }}
|
||||||
@@ -278,6 +294,7 @@ jobs:
|
|||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
command: build
|
command: build
|
||||||
|
force-use-cross: ${{ matrix.platform.force-use-cross || false }}
|
||||||
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 }}
|
||||||
working-directory: subcrate
|
working-directory: subcrate
|
||||||
@@ -301,6 +318,7 @@ jobs:
|
|||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
command: bench
|
command: bench
|
||||||
|
force-use-cross: ${{ matrix.platform.force-use-cross || false }}
|
||||||
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 }}
|
||||||
@@ -310,7 +328,7 @@ jobs:
|
|||||||
|
|
||||||
test-validate-inputs:
|
test-validate-inputs:
|
||||||
name: Test validate-inputs
|
name: Test validate-inputs
|
||||||
runs-on: ubuntu-22.04
|
runs-on: ubuntu-24.04
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|||||||
@@ -1,3 +1,9 @@
|
|||||||
|
## 1.0.2 - 2025-02-16
|
||||||
|
|
||||||
|
- Added a new `force-use-cross` input, which does what it says. It will force the use of `cross`
|
||||||
|
even when it is not required for given platform/target combination. Note that this only works on
|
||||||
|
Linux hosts.
|
||||||
|
|
||||||
## 1.0.1 - 2025-01-20
|
## 1.0.1 - 2025-01-20
|
||||||
|
|
||||||
- Fixed a bug where this action would attempt to use `cross` when compiling for an ARM Linux target
|
- Fixed a bug where this action would attempt to use `cross` when compiling for an ARM Linux target
|
||||||
@@ -32,7 +38,7 @@ bumped to v1.0.0 because of this change.
|
|||||||
- This action will now configure and use `Swatinem/rust-cache` by default for you. It will include
|
- This action will now configure and use `Swatinem/rust-cache` by default for you. It will include
|
||||||
the `target` parameter as part of the cache key automatically. Suggested by @jennydaman (Jennings
|
the `target` parameter as part of the cache key automatically. Suggested by @jennydaman (Jennings
|
||||||
Zhang). GH #23.
|
Zhang). GH #23.
|
||||||
- This action now validates its input and will exit early if they are not valid. GH #35.
|
- This action now validates its inputs and will exit early if they are not valid. GH #35.
|
||||||
|
|
||||||
## 0.0.17 - 2024-11-23
|
## 0.0.17 - 2024-11-23
|
||||||
|
|
||||||
|
|||||||
37
README.md
37
README.md
@@ -14,19 +14,19 @@ jobs:
|
|||||||
matrix:
|
matrix:
|
||||||
platform:
|
platform:
|
||||||
- os-name: FreeBSD-x86_64
|
- os-name: FreeBSD-x86_64
|
||||||
runs-on: ubuntu-20.04
|
runs-on: ubuntu-24.04
|
||||||
target: x86_64-unknown-freebsd
|
target: x86_64-unknown-freebsd
|
||||||
|
|
||||||
- os-name: Linux-x86_64
|
- os-name: Linux-x86_64
|
||||||
runs-on: ubuntu-20.04
|
runs-on: ubuntu-24.04
|
||||||
target: x86_64-unknown-linux-musl
|
target: x86_64-unknown-linux-musl
|
||||||
|
|
||||||
- os-name: Linux-aarch64
|
- os-name: Linux-aarch64
|
||||||
runs-on: ubuntu-20.04
|
runs-on: ubuntu-24.04
|
||||||
target: aarch64-unknown-linux-musl
|
target: aarch64-unknown-linux-musl
|
||||||
|
|
||||||
- os-name: Linux-riscv64
|
- os-name: Linux-riscv64
|
||||||
runs-on: ubuntu-20.04
|
runs-on: ubuntu-24.04
|
||||||
target: riscv64gc-unknown-linux-gnu
|
target: riscv64gc-unknown-linux-gnu
|
||||||
|
|
||||||
- os-name: Windows-x86_64
|
- os-name: Windows-x86_64
|
||||||
@@ -60,7 +60,7 @@ jobs:
|
|||||||
Note that for Linux or BSD targets, you should always set the `runs-on` key to a Linux x86-64
|
Note that for Linux or BSD targets, you should always set the `runs-on` key to a Linux x86-64
|
||||||
architecture runner.
|
architecture runner.
|
||||||
|
|
||||||
If you _only_ want to do native ARM compilation, for example using the `ubuntu-latest-arm` runner,
|
If you _only_ want to do native ARM compilation, for example using the `ubuntu-24.04-arm` runner,
|
||||||
then there's no need to use this action. However, if you want to compile for _many_ platforms,
|
then there's no need to use this action. However, if you want to compile for _many_ platforms,
|
||||||
including Linux ARM, using this action will simplify your config. This action is only tested on
|
including Linux ARM, using this action will simplify your config. This action is only tested on
|
||||||
Ubuntu x86-64, Windows, and macOS runners.
|
Ubuntu x86-64, Windows, and macOS runners.
|
||||||
@@ -79,6 +79,7 @@ This action takes the following parameters:
|
|||||||
| `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. |
|
||||||
| `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. |
|
| `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. |
|
| `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). |
|
| `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). |
|
||||||
|
|
||||||
@@ -161,3 +162,29 @@ you can avoid this issue by structuring your workflow as follows:
|
|||||||
4. Run the release steps for crate B.
|
4. Run the release steps for crate B.
|
||||||
|
|
||||||
When structured this way, it does not matter if the output of crate A is deleted in step 3.
|
When structured this way, it does not matter if the output of crate A is deleted in step 3.
|
||||||
|
|
||||||
|
## Linting and Tidying this Code
|
||||||
|
|
||||||
|
The code in this repo is linted and tidied with
|
||||||
|
[`precious`](https://github.com/houseabsolute/precious). This repo contains a `mise.toml` file.
|
||||||
|
[Mise](https://mise.jdx.dev/) is a tool for managing dev tools with per-repo configuration. You can
|
||||||
|
install `mise` and use it to run `precious` as follows:
|
||||||
|
|
||||||
|
```
|
||||||
|
# Installs mise
|
||||||
|
curl https://mise.run | sh
|
||||||
|
# Installs precious and other dev tools
|
||||||
|
mise install
|
||||||
|
```
|
||||||
|
|
||||||
|
Once this is done, you can run `precious` via `mise`:
|
||||||
|
|
||||||
|
```
|
||||||
|
# Lints all code
|
||||||
|
mise exec -- precious lint -a
|
||||||
|
# Tidies all code
|
||||||
|
mise exec -- precious tidy -a
|
||||||
|
```
|
||||||
|
|
||||||
|
If you want to use `mise` for other projects, see [its documentation](https://mise.jdx.dev/) for
|
||||||
|
more details on how you can configure your shell to always activate `mise`.
|
||||||
|
|||||||
42
action.yml
42
action.yml
@@ -1,55 +1,74 @@
|
|||||||
name: "Build Rust Projects with Cross"
|
name: "Build Rust Projects with Cross"
|
||||||
author: "Dave Rolsky <autarch@urth.org>"
|
author: "Dave Rolsky <autarch@urth.org>"
|
||||||
|
|
||||||
branding:
|
branding:
|
||||||
icon: home
|
icon: home
|
||||||
color: gray-dark
|
color: gray-dark
|
||||||
|
|
||||||
description: |
|
description: |
|
||||||
Cross compile your Rust projects with cross (https://github.com/cross-rs/cross).
|
Cross compile your Rust projects with cross (https://github.com/cross-rs/cross).
|
||||||
|
|
||||||
inputs:
|
inputs:
|
||||||
target:
|
target:
|
||||||
description: The target platform
|
description: The target platform
|
||||||
required: true
|
required: true
|
||||||
|
|
||||||
command:
|
command:
|
||||||
description: |
|
description: |
|
||||||
The commands to run. This must be one of "build", "test", "both" (build and test), or "bench".
|
The commands to run. This must be one of "build", "test", "both" (build and test), or "bench".
|
||||||
default: build
|
default: build
|
||||||
|
|
||||||
toolchain:
|
toolchain:
|
||||||
description: |
|
description: |
|
||||||
The target toolchain to use (one of "stable", "beta", or "nightly").
|
The target toolchain to use (one of "stable", "beta", or "nightly").
|
||||||
default: stable
|
default: stable
|
||||||
|
|
||||||
working-directory:
|
working-directory:
|
||||||
description: The working directory for each step
|
description: The working directory for each step
|
||||||
default: "."
|
default: "."
|
||||||
|
|
||||||
GITHUB_TOKEN:
|
GITHUB_TOKEN:
|
||||||
description: |
|
description: |
|
||||||
A GitHub token, available in the secrets.GITHUB_TOKEN working-directory variable.
|
A GitHub token, available in the secrets.GITHUB_TOKEN working-directory variable.
|
||||||
default: ${{ github.token }}
|
default: ${{ github.token }}
|
||||||
|
|
||||||
args:
|
args:
|
||||||
description: |
|
description: |
|
||||||
The arguments to be passed to cross or cargo when building, as a
|
The arguments to be passed to cross or cargo when building, as a
|
||||||
space-separated string.
|
space-separated string.
|
||||||
default: ""
|
default: ""
|
||||||
|
|
||||||
strip:
|
strip:
|
||||||
description: Strip the compiled binary
|
description: Strip the compiled binary
|
||||||
default: false
|
default: false
|
||||||
|
|
||||||
cross-version:
|
cross-version:
|
||||||
description: |
|
description: |
|
||||||
The version of cross to use. If not specified, then the latest version
|
The version of cross to use. If not specified, then the latest version
|
||||||
will be used.
|
will be used.
|
||||||
|
|
||||||
cache-cross-binary:
|
cache-cross-binary:
|
||||||
description: |
|
description: |
|
||||||
Cache the cross binary if one is installed. This is primarily for use in
|
Cache the cross binary if one is installed. This is primarily for use in
|
||||||
tests of this action.
|
tests of this action.
|
||||||
default: true
|
default: true
|
||||||
|
|
||||||
|
force-use-cross:
|
||||||
|
description: |
|
||||||
|
If this is true, the action will use cross even for targets where it is not needed.
|
||||||
|
default: false
|
||||||
|
|
||||||
use-rust-cache:
|
use-rust-cache:
|
||||||
description: |
|
description: |
|
||||||
Use `Swatinem/rust-cache@v2`. Defaults to true.
|
Use `Swatinem/rust-cache@v2`. Defaults to true.
|
||||||
default: true
|
default: true
|
||||||
|
|
||||||
rust-cache-parameters:
|
rust-cache-parameters:
|
||||||
description: |
|
description: |
|
||||||
A JSON string containing parameters to pass to `Swatinem/rust-cache@v2`. You can use the
|
A JSON string containing parameters to pass to `Swatinem/rust-cache@v2`. You can use the
|
||||||
`toJSON()` function in your action to make passing this easier.
|
`toJSON()` function in your action to make passing this easier.
|
||||||
default: "{}"
|
default: "{}"
|
||||||
|
|
||||||
runs:
|
runs:
|
||||||
using: composite
|
using: composite
|
||||||
steps:
|
steps:
|
||||||
@@ -57,9 +76,11 @@ runs:
|
|||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
echo '${{ toJSON(inputs) }}'
|
echo '${{ toJSON(inputs) }}'
|
||||||
|
|
||||||
- name: Add this action's path to PATH
|
- name: Add this action's path to PATH
|
||||||
shell: bash
|
shell: bash
|
||||||
run: echo "${{ github.action_path }}" >> $GITHUB_PATH
|
run: echo "${{ github.action_path }}" >> $GITHUB_PATH
|
||||||
|
|
||||||
- name: Validate inputs
|
- name: Validate inputs
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
@@ -71,17 +92,21 @@ runs:
|
|||||||
INPUTS_working_directory: ${{ inputs.working-directory }}
|
INPUTS_working_directory: ${{ inputs.working-directory }}
|
||||||
INPUTS_strip: ${{ inputs.strip }}
|
INPUTS_strip: ${{ inputs.strip }}
|
||||||
INPUTS_cache_cross_binary: ${{ inputs.cache-cross-binary }}
|
INPUTS_cache_cross_binary: ${{ inputs.cache-cross-binary }}
|
||||||
|
INPUTS_force_use_cross: ${{ inputs.force-use-cross }}
|
||||||
INPUTS_use_rust_cache: ${{ inputs.use-rust-cache }}
|
INPUTS_use_rust_cache: ${{ inputs.use-rust-cache }}
|
||||||
INPUTS_rust_cache_parameters: ${{ inputs.rust-cache-parameters }}
|
INPUTS_rust_cache_parameters: ${{ inputs.rust-cache-parameters }}
|
||||||
|
|
||||||
- name: Determine whether we need to cross-compile
|
- name: Determine whether we need to cross-compile
|
||||||
id: determine-cross-compile
|
id: determine-cross-compile
|
||||||
shell: bash
|
shell: bash
|
||||||
run: set-cross-compile.py ${{ inputs.target }}
|
run: set-cross-compile.py ${{ inputs.target }} ${{ inputs.force-use-cross }}
|
||||||
|
|
||||||
- name: Install toolchain
|
- name: Install toolchain
|
||||||
uses: dtolnay/rust-toolchain@master
|
uses: dtolnay/rust-toolchain@master
|
||||||
with:
|
with:
|
||||||
targets: ${{ inputs.target }}
|
targets: ${{ inputs.target }}
|
||||||
toolchain: ${{ inputs.toolchain }}
|
toolchain: ${{ inputs.toolchain }}
|
||||||
|
|
||||||
- name: Determine cross version
|
- name: Determine cross version
|
||||||
id: determine-cross-version
|
id: determine-cross-version
|
||||||
shell: bash
|
shell: bash
|
||||||
@@ -89,6 +114,7 @@ runs:
|
|||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ inputs.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ inputs.GITHUB_TOKEN }}
|
||||||
if: steps.determine-cross-compile.outputs.needs-cross == 'true'
|
if: steps.determine-cross-compile.outputs.needs-cross == 'true'
|
||||||
|
|
||||||
# We need to access this in both this YAML config and shell scripts. It
|
# We need to access this in both this YAML config and shell scripts. It
|
||||||
# doesn't seem like using ${{ env.RUNNER_TEMP }} works in the YAML config.
|
# doesn't seem like using ${{ env.RUNNER_TEMP }} works in the YAML config.
|
||||||
- name: Set directory for installing cross
|
- name: Set directory for installing cross
|
||||||
@@ -96,6 +122,7 @@ runs:
|
|||||||
shell: bash
|
shell: bash
|
||||||
run: set-cross-dir.sh
|
run: set-cross-dir.sh
|
||||||
if: steps.determine-cross-compile.outputs.needs-cross == 'true'
|
if: steps.determine-cross-compile.outputs.needs-cross == 'true'
|
||||||
|
|
||||||
- name: Cache cross
|
- name: Cache cross
|
||||||
id: cache-cross
|
id: cache-cross
|
||||||
uses: actions/cache@v4
|
uses: actions/cache@v4
|
||||||
@@ -103,12 +130,14 @@ runs:
|
|||||||
path: ${{ steps.set-cross-dir.outputs.cross-dir }}/cross
|
path: ${{ steps.set-cross-dir.outputs.cross-dir }}/cross
|
||||||
key: ${{ runner.os }}-${{ steps.determine-cross-version.outputs.cross-version }}
|
key: ${{ runner.os }}-${{ steps.determine-cross-version.outputs.cross-version }}
|
||||||
if: steps.determine-cross-compile.outputs.needs-cross == 'true' && inputs.cache-cross-binary == 'true'
|
if: steps.determine-cross-compile.outputs.needs-cross == 'true' && inputs.cache-cross-binary == 'true'
|
||||||
|
|
||||||
- name: Install cross if cross-compiling (*nix)
|
- name: Install cross if cross-compiling (*nix)
|
||||||
shell: bash
|
shell: bash
|
||||||
run: install-cross-nix.sh ${{ steps.set-cross-dir.outputs.cross-dir }} ${{ steps.determine-cross-version.outputs.cross-version }}
|
run: install-cross-nix.sh ${{ steps.set-cross-dir.outputs.cross-dir }} ${{ steps.determine-cross-version.outputs.cross-version }}
|
||||||
if: steps.determine-cross-compile.outputs.needs-cross == 'true' && steps.cache-cross.outputs.cache-hit != 'true'
|
if: steps.determine-cross-compile.outputs.needs-cross == 'true' && steps.cache-cross.outputs.cache-hit != 'true'
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ inputs.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ inputs.GITHUB_TOKEN }}
|
||||||
|
|
||||||
- name: Install musl-tools on Linux if target includes "musl"
|
- name: Install musl-tools on Linux if target includes "musl"
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
@@ -118,14 +147,17 @@ runs:
|
|||||||
sudo apt-get update --yes && \
|
sudo apt-get update --yes && \
|
||||||
sudo apt-get install --yes musl-tools
|
sudo apt-get install --yes musl-tools
|
||||||
if: steps.determine-cross-compile.outputs.needs-cross != 'true' && contains(inputs.target, 'musl')
|
if: steps.determine-cross-compile.outputs.needs-cross != 'true' && contains(inputs.target, 'musl')
|
||||||
|
|
||||||
- name: Set build command
|
- name: Set build command
|
||||||
id: set-build-command
|
id: set-build-command
|
||||||
shell: bash
|
shell: bash
|
||||||
run: set-build-command.sh ${{ steps.set-cross-dir.outputs.cross-dir }}
|
run: set-build-command.sh ${{ steps.set-cross-dir.outputs.cross-dir }}
|
||||||
|
|
||||||
- name: Determine which cargo commands to run
|
- name: Determine which cargo commands to run
|
||||||
id: determine-cargo-commands
|
id: determine-cargo-commands
|
||||||
shell: bash
|
shell: bash
|
||||||
run: determine-cargo-commands.sh ${{ inputs.command }}
|
run: determine-cargo-commands.sh ${{ inputs.command }}
|
||||||
|
|
||||||
- name: Parse `rust-cache-parameters` and set inputs for `Swatinem/rust-cache@v2`
|
- name: Parse `rust-cache-parameters` and set inputs for `Swatinem/rust-cache@v2`
|
||||||
id: parse-rust-cache-parameters
|
id: parse-rust-cache-parameters
|
||||||
shell: bash
|
shell: bash
|
||||||
@@ -144,16 +176,19 @@ runs:
|
|||||||
env:
|
env:
|
||||||
RUST_CACHE_PARAMETERS: ${{ inputs.rust-cache-parameters }}
|
RUST_CACHE_PARAMETERS: ${{ inputs.rust-cache-parameters }}
|
||||||
if: inputs.use-rust-cache == 'true'
|
if: inputs.use-rust-cache == 'true'
|
||||||
|
|
||||||
- name: Cache cargo & target directories
|
- name: Cache cargo & target directories
|
||||||
uses: Swatinem/rust-cache@v2
|
uses: Swatinem/rust-cache@v2
|
||||||
with: ${{ steps.parse-rust-cache-parameters.outputs }}
|
with: ${{ steps.parse-rust-cache-parameters.outputs }}
|
||||||
if: inputs.use-rust-cache == 'true'
|
if: inputs.use-rust-cache == 'true'
|
||||||
|
|
||||||
- name: Run tests (*nix)
|
- name: Run tests (*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}} test --target ${{ inputs.target }} ${{ inputs.args }}
|
${{ 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'
|
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
|
||||||
# native Windows environment. Some things won't compile properly under
|
# native Windows environment. Some things won't compile properly under
|
||||||
# msys, notably OpenSSL, which is compiled locally when using the
|
# msys, notably OpenSSL, which is compiled locally when using the
|
||||||
@@ -164,30 +199,35 @@ runs:
|
|||||||
run: |
|
run: |
|
||||||
& ${{ steps.set-build-command.outputs.build-command }} +${{inputs.toolchain}} test --target ${{ inputs.target }} ${{ inputs.args }}
|
& ${{ 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'
|
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 }} +${{inputs.toolchain}} 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 }} +${{inputs.toolchain}} 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 }} +${{inputs.toolchain}} 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 }} +${{inputs.toolchain}} 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
|
||||||
working-directory: ${{ inputs.working-directory }}
|
working-directory: ${{ inputs.working-directory }}
|
||||||
shell: bash
|
shell: bash
|
||||||
|
|||||||
@@ -79,7 +79,11 @@ fn check_cross(bin_dir: &Path, expect_cross: bool, expect_cross_version: Option<
|
|||||||
let cross_path = bin_dir.join("cross");
|
let cross_path = bin_dir.join("cross");
|
||||||
|
|
||||||
if expect_cross {
|
if expect_cross {
|
||||||
assert!(cross_path.is_file(), "`cross` exists");
|
assert!(
|
||||||
|
cross_path.is_file(),
|
||||||
|
"`cross` exists at {}",
|
||||||
|
cross_path.display()
|
||||||
|
);
|
||||||
|
|
||||||
if let Some(expected_version) = expect_cross_version {
|
if let Some(expected_version) = expect_cross_version {
|
||||||
let output = Command::new(&cross_path)
|
let output = Command::new(&cross_path)
|
||||||
@@ -90,7 +94,7 @@ fn check_cross(bin_dir: &Path, expect_cross: bool, expect_cross_version: Option<
|
|||||||
.expect("`cross --version` stdout was not valid UTF-8");
|
.expect("`cross --version` stdout was not valid UTF-8");
|
||||||
assert!(
|
assert!(
|
||||||
version.contains(expected_version),
|
version.contains(expected_version),
|
||||||
"`cross` version matches expected version"
|
"`cross` version matches expected version: {expected_version}",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -136,25 +140,29 @@ fn check_binary(bin_path: &PathBuf, expect_file_re: Option<&str>, expect_strippe
|
|||||||
if expect_stripped {
|
if expect_stripped {
|
||||||
assert!(
|
assert!(
|
||||||
!file_output.contains("not stripped"),
|
!file_output.contains("not stripped"),
|
||||||
"`file` does not report {} as not stripped",
|
"`file` does not report {} as 'not stripped': `{}`",
|
||||||
bin_path.display(),
|
bin_path.display(),
|
||||||
|
file_output,
|
||||||
);
|
);
|
||||||
assert!(
|
assert!(
|
||||||
file_output.contains("stripped"),
|
file_output.contains("stripped"),
|
||||||
"`file` reports {} as stripped",
|
"`file` reports {} as 'stripped': `{}`",
|
||||||
bin_path.display(),
|
bin_path.display(),
|
||||||
|
file_output,
|
||||||
);
|
);
|
||||||
} else if cfg!(windows) {
|
} else if cfg!(windows) {
|
||||||
assert!(
|
assert!(
|
||||||
!file_output.contains("stripped"),
|
!file_output.contains("stripped"),
|
||||||
"`file` does not report {} as stripped",
|
"`file` does not report {} as 'stripped': `{}`",
|
||||||
bin_path.display(),
|
bin_path.display(),
|
||||||
|
file_output,
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
assert!(
|
assert!(
|
||||||
file_output.contains("not stripped"),
|
file_output.contains("not stripped"),
|
||||||
"`file` reports {} as not stripped",
|
"`file` reports {} as 'not stripped': `{}`",
|
||||||
bin_path.display(),
|
bin_path.display(),
|
||||||
|
file_output,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,12 +16,20 @@ def main() -> int:
|
|||||||
Returns:
|
Returns:
|
||||||
Exit code (0 for success)
|
Exit code (0 for success)
|
||||||
"""
|
"""
|
||||||
if len(sys.argv) < 2:
|
if len(sys.argv) < 3:
|
||||||
print("Error: Target architecture argument is required", file=sys.stderr)
|
print(
|
||||||
|
"Error: Target architecture and force cross arguments are required",
|
||||||
|
file=sys.stderr,
|
||||||
|
)
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
target = sys.argv[1]
|
target = sys.argv[1]
|
||||||
needs_cross = check_needs_cross(target)
|
force_use_cross = sys.argv[2]
|
||||||
|
if force_use_cross == "true":
|
||||||
|
needs_cross = True
|
||||||
|
else:
|
||||||
|
needs_cross = check_needs_cross(target)
|
||||||
|
|
||||||
write_github_output(needs_cross)
|
write_github_output(needs_cross)
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
@@ -53,6 +61,10 @@ def check_needs_cross(target: str) -> bool:
|
|||||||
):
|
):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
# It's tempting to not use cross when the host is Linux x86-64 and we're compiling for Linux
|
||||||
|
# i586 or i686. This sort of works, but if there's any C being compiled, things get weird,
|
||||||
|
# because then we need 32-bit C headers, 32-bit C libs to link to, etc.
|
||||||
|
|
||||||
# Check if both host and target are ARM Linux. I'm assuming here that for things like
|
# Check if both host and target are ARM Linux. I'm assuming here that for things like
|
||||||
# "arm-linux-androideabi" or "armv7-unknown-linux-ohos" we'd still need cross.
|
# "arm-linux-androideabi" or "armv7-unknown-linux-ohos" we'd still need cross.
|
||||||
if (
|
if (
|
||||||
|
|||||||
@@ -9,6 +9,8 @@ from typing import Dict, List, Union
|
|||||||
import tempfile
|
import tempfile
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
|
boolean_flags = {"cache_cross_binary", "force_use_cross", "strip", "use_rust_cache"}
|
||||||
|
|
||||||
|
|
||||||
class InputValidator:
|
class InputValidator:
|
||||||
"""Validate inputs for a GitHub Action."""
|
"""Validate inputs for a GitHub Action."""
|
||||||
@@ -72,10 +74,11 @@ class InputValidator:
|
|||||||
)
|
)
|
||||||
|
|
||||||
# Validate boolean flags
|
# Validate boolean flags
|
||||||
boolean_flags = {"cache_cross_binary", "strip", "use_rust_cache"}
|
|
||||||
for flag in boolean_flags:
|
for flag in boolean_flags:
|
||||||
if flag in self.inputs and self.inputs[flag] not in {"true", "false"}:
|
if flag in self.inputs and self.inputs[flag] not in {"true", "false"}:
|
||||||
validation_errors.append(f"'{flag}' must be either 'true' or 'false'")
|
# Turn the underscores into dashes
|
||||||
|
dashes = flag.replace("_", "-")
|
||||||
|
validation_errors.append(f"'{dashes}' must be either 'true' or 'false'")
|
||||||
|
|
||||||
# Validate rust-cache-parameters JSON if present
|
# Validate rust-cache-parameters JSON if present
|
||||||
if "rust_cache_parameters" in self.inputs:
|
if "rust_cache_parameters" in self.inputs:
|
||||||
@@ -212,7 +215,6 @@ class TestInputValidator(unittest.TestCase):
|
|||||||
|
|
||||||
def test_validate_boolean_flags(self) -> None:
|
def test_validate_boolean_flags(self) -> None:
|
||||||
"""Test validation of boolean flags."""
|
"""Test validation of boolean flags."""
|
||||||
boolean_flags = ["cache-cross-binary", "strip", "use-rust-cache"]
|
|
||||||
|
|
||||||
# Test valid boolean values
|
# Test valid boolean values
|
||||||
for flag in boolean_flags:
|
for flag in boolean_flags:
|
||||||
|
|||||||
Reference in New Issue
Block a user