10 Commits

Author SHA1 Message Date
Dave Rolsky
e10d0dcde7 Add release date for v1.0.1
Some checks failed
Lint / Check that code is lint clean using precious (push) Failing after 0s
Self-test / Test action (map[cache-cross-binary:false can-execute:true cross-version:19be834 expect-cross:--expect-cross expect-cross-version:19be834 expect-file-re:aarch64 expect-stripped: platform_name:Linux-aarch64 with cross 19be834 runs-on:ubuntu-22.04 target… (push) Failing after 0s
Self-test / Test action (map[cache-cross-binary:false can-execute:true cross-version:v0.2.3 expect-cross:--expect-cross expect-cross-version:0.2.3 expect-file-re:aarch64 expect-stripped: platform_name:Linux-aarch64 with cross v0.2.3 (no cache) runs-on:ubuntu-22.04… (push) Failing after 0s
Self-test / Test action (map[cache-cross-binary:false can-execute:true expect-cross:--expect-cross expect-file-re:aarch64 expect-stripped: platform_name:Linux-aarch64 (no cache) runs-on:ubuntu-22.04 target:aarch64-unknown-linux-musl]) (push) Failing after 0s
Self-test / Test action (map[cache-cross-binary:true can-execute:false expect-cross:--expect-cross expect-file-re:x86-64.+FreeBSD expect-stripped: platform_name:FreeBSD-x86_64 runs-on:ubuntu-22.04 target:x86_64-unknown-freebsd]) (push) Failing after 0s
Self-test / Test action (map[cache-cross-binary:true can-execute:false expect-cross:--expect-cross expect-file-re:x86-64.+NetBSD expect-stripped: platform_name:NetBSD-x86_64 runs-on:ubuntu-22.04 target:x86_64-unknown-netbsd]) (push) Failing after 0s
Self-test / Test action (map[cache-cross-binary:true can-execute:true cross-version:19be834 expect-cross:--expect-cross expect-cross-version:19be834 expect-file-re:aarch64 expect-stripped: platform_name:Linux-aarch64 with cross 19be834 runs-on:ubuntu-22.04 target:… (push) Failing after 0s
Self-test / Test action (map[cache-cross-binary:true can-execute:true cross-version:v0.2.3 expect-cross:--expect-cross expect-cross-version:0.2.3 expect-file-re:aarch64 expect-stripped: platform_name:Linux-aarch64 with cross v0.2.3 runs-on:ubuntu-22.04 target:aarc… (push) Failing after 0s
Self-test / Test action (map[cache-cross-binary:true can-execute:true expect-cross: expect-file-re:ELF.+x86-64 expect-stripped:--expect-stripped platform_name:Linux-x86_64 runs-on:ubuntu-22.04 target:x86_64-unknown-linux-musl]) (push) Failing after 0s
Self-test / Test action (map[cache-cross-binary:true can-execute:true expect-cross:--expect-cross expect-file-re:32.+ARM expect-stripped: platform_name:Linux-arm runs-on:ubuntu-22.04 target:arm-unknown-linux-musleabi]) (push) Failing after 0s
Self-test / Test action (map[cache-cross-binary:true can-execute:true expect-cross:--expect-cross expect-file-re:32.+PowerPC expect-stripped: platform_name:Linux-powerpc runs-on:ubuntu-22.04 target:powerpc-unknown-linux-gnu]) (push) Failing after 0s
Self-test / Test action (map[cache-cross-binary:true can-execute:true expect-cross:--expect-cross expect-file-re:64.+PowerPC expect-stripped: platform_name:Linux-powerpc64 runs-on:ubuntu-22.04 target:powerpc64-unknown-linux-gnu]) (push) Failing after 0s
Self-test / Test action (map[cache-cross-binary:true can-execute:true expect-cross:--expect-cross expect-file-re:64.+PowerPC expect-stripped: platform_name:Linux-powerpc64le runs-on:ubuntu-22.04 target:powerpc64le-unknown-linux-gnu]) (push) Failing after 0s
Self-test / Test action (map[cache-cross-binary:true can-execute:true expect-cross:--expect-cross expect-file-re:64.+RISC-V expect-stripped: platform_name:Linux-riscv64 runs-on:ubuntu-22.04 target:riscv64gc-unknown-linux-gnu]) (push) Failing after 0s
Self-test / Test action (map[cache-cross-binary:true can-execute:true expect-cross:--expect-cross expect-file-re:64.+S/390 expect-stripped: platform_name:Linux-s390x runs-on:ubuntu-22.04 target:s390x-unknown-linux-gnu]) (push) Failing after 0s
Self-test / Test action (map[cache-cross-binary:true can-execute:true expect-cross:--expect-cross expect-file-re:ELF.+80386 expect-stripped: platform_name:Linux-i586 runs-on:ubuntu-22.04 target:i586-unknown-linux-musl]) (push) Failing after 0s
Self-test / Test action (map[cache-cross-binary:true can-execute:true expect-cross:--expect-cross expect-file-re:ELF.+80386 expect-stripped: platform_name:Linux-i686 runs-on:ubuntu-22.04 target:i686-unknown-linux-musl]) (push) Failing after 0s
Self-test / Test action (map[cache-cross-binary:true can-execute:true expect-cross:--expect-cross expect-file-re:aarch64 expect-stripped: platform_name:Linux-aarch64 runs-on:ubuntu-22.04 target:aarch64-unknown-linux-musl]) (push) Failing after 0s
Self-test / Test validate-inputs (push) Failing after 0s
Self-test / Test action (map[cache-cross-binary:true can-execute:false expect-cross: expect-file-re:Aarch64.+Windows expect-stripped: platform_name:Windows-aarch64 runs-on:windows-latest target:aarch64-pc-windows-msvc]) (push) Has been cancelled
Self-test / Test action (map[cache-cross-binary:true can-execute:false expect-cross: expect-file-re:Mach-O.+arm64 expect-stripped:--expect-stripped platform_name:macOS-aarch64 runs-on:macOS-latest target:aarch64-apple-darwin]) (push) Has been cancelled
Self-test / Test action (map[cache-cross-binary:true can-execute:true expect-cross: expect-file-re:80386.+Windows expect-stripped:--expect-stripped platform_name:Windows-i686 runs-on:windows-latest target:i686-pc-windows-msvc]) (push) Has been cancelled
Self-test / Test action (map[cache-cross-binary:true can-execute:true expect-cross: expect-file-re:Mach-O.+x86_64 expect-stripped:--expect-stripped platform_name:macOS-x86_64 runs-on:macOS-latest target:x86_64-apple-darwin]) (push) Has been cancelled
Self-test / Test action (map[cache-cross-binary:true can-execute:true expect-file-re:x86-64.+Windows expect-stripped:--expect-stripped platform_name:Windows-x86_64 runs-on:windows-latest target:x86_64-pc-windows-msvc]) (push) Has been cancelled
2025-01-20 22:25:51 -06:00
Dave Rolsky
52839d91bd Fix bug where we would try to use cross on ARM hosts for all targets
If the target is ARM and the host is ARM, this should work with just `cargo`. I'm not sure if this
works for all ARM host/target combos, or if the CPU architecture must be an exact match.

But it doesn't really matter too much, since at least for now there's no ARM builds for
`cross` (https://github.com/cross-rs/cross/issues/1612). So even if cross-compilation doesn't work
natively, we couldn't use `cross` in this case either.

I also rewrote the `set-cross-compile.sh` in Python. By "I", I mean I had Claude do it and then I
tweaked it.
2025-01-20 20:47:52 -06:00
莯凛
5b5d0b578b Add some more details to the docs about environment variables 2025-01-20 14:26:41 -06:00
Dave Rolsky
02bec77bb9 Remove pointless skip_tests key in README.md example 2025-01-20 11:54:32 -06:00
Dave Rolsky
67b2637704 Document setting the env key when using this action
This addresses #36.
2025-01-20 11:53:51 -06:00
Dave Rolsky
cd04d1a926 Update README.md to talk about weird issue I saw with caching multiple crates 2025-01-11 13:01:14 -06:00
Dave Rolsky
242cf4bba9 Rename all matrix keys to use dashes instead of underscores 2025-01-11 12:55:43 -06:00
Dave Rolsky
8a64ff717c Run tests twice, one for main crate and once for subcrate
It seems like restoring the cache for subcrate deletes sometimes removes the compiled binaries for
the parent crate. I'm not sure what's going on here, as it doesn't happen every time.
2025-01-11 12:55:43 -06:00
Dave Rolsky
a8c1049914 Fix version for shellcheck 2025-01-11 12:55:43 -06:00
Dave Rolsky
c76d836532 Fix url to download files for NetBSD issue workaround 2025-01-11 12:55:43 -06:00
10 changed files with 296 additions and 158 deletions

View File

@@ -15,206 +15,206 @@ jobs:
runs-on: ubuntu-22.04 runs-on: ubuntu-22.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"
expect_cross: "--expect-cross" expect-cross: "--expect-cross"
expect_stripped: "" expect-stripped: ""
can_execute: false can-execute: false
- platform_name: Linux-x86_64 - platform_name: Linux-x86_64
runs-on: ubuntu-22.04 runs-on: ubuntu-22.04
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"
expect_cross: "" expect-cross: ""
expect_stripped: "--expect-stripped" expect-stripped: "--expect-stripped"
can_execute: true can-execute: true
- platform_name: Linux-aarch64 - platform_name: Linux-aarch64
runs-on: ubuntu-22.04 runs-on: ubuntu-22.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"
expect_cross: "--expect-cross" expect-cross: "--expect-cross"
expect_stripped: "" expect-stripped: ""
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-22.04
target: aarch64-unknown-linux-musl target: aarch64-unknown-linux-musl
cache-cross-binary: false cache-cross-binary: false
expect_file_re: "aarch64" expect-file-re: "aarch64"
expect_cross: "--expect-cross" expect-cross: "--expect-cross"
expect_stripped: "" expect-stripped: ""
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-22.04
target: aarch64-unknown-linux-musl target: aarch64-unknown-linux-musl
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"
expect_cross: "--expect-cross" expect-cross: "--expect-cross"
expect_cross_version: "0.2.3" expect-cross-version: "0.2.3"
expect_stripped: "" expect-stripped: ""
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-22.04
target: aarch64-unknown-linux-musl target: aarch64-unknown-linux-musl
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"
expect_cross: "--expect-cross" expect-cross: "--expect-cross"
expect_cross_version: "0.2.3" expect-cross-version: "0.2.3"
expect_stripped: "" expect-stripped: ""
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-22.04
target: aarch64-unknown-linux-musl target: aarch64-unknown-linux-musl
cross-version: "19be834" cross-version: "19be834"
cache-cross-binary: true cache-cross-binary: true
expect_file_re: "aarch64" expect-file-re: "aarch64"
expect_cross: "--expect-cross" expect-cross: "--expect-cross"
expect_cross_version: "19be834" expect-cross-version: "19be834"
expect_stripped: "" expect-stripped: ""
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-22.04
target: aarch64-unknown-linux-musl target: aarch64-unknown-linux-musl
cross-version: "19be834" cross-version: "19be834"
cache-cross-binary: false cache-cross-binary: false
expect_file_re: "aarch64" expect-file-re: "aarch64"
expect_cross: "--expect-cross" expect-cross: "--expect-cross"
expect_cross_version: "19be834" expect-cross-version: "19be834"
expect_stripped: "" expect-stripped: ""
can_execute: true can-execute: true
- platform_name: Linux-arm - platform_name: Linux-arm
runs-on: ubuntu-22.04 runs-on: ubuntu-22.04
target: arm-unknown-linux-musleabi target: arm-unknown-linux-musleabi
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"
expect_stripped: "" expect-stripped: ""
can_execute: true can-execute: true
- platform_name: Linux-i586 - platform_name: Linux-i586
runs-on: ubuntu-22.04 runs-on: ubuntu-22.04
target: i586-unknown-linux-musl target: i586-unknown-linux-musl
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"
expect_stripped: "" expect-stripped: ""
can_execute: true can-execute: true
- platform_name: Linux-i686 - platform_name: Linux-i686
runs-on: ubuntu-22.04 runs-on: ubuntu-22.04
target: i686-unknown-linux-musl target: i686-unknown-linux-musl
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"
expect_stripped: "" expect-stripped: ""
can_execute: true can-execute: true
- platform_name: Linux-powerpc - platform_name: Linux-powerpc
runs-on: ubuntu-22.04 runs-on: ubuntu-22.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"
expect_cross: "--expect-cross" expect-cross: "--expect-cross"
expect_stripped: "" expect-stripped: ""
can_execute: true can-execute: true
- platform_name: Linux-powerpc64 - platform_name: Linux-powerpc64
runs-on: ubuntu-22.04 runs-on: ubuntu-22.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"
expect_cross: "--expect-cross" expect-cross: "--expect-cross"
expect_stripped: "" expect-stripped: ""
can_execute: true can-execute: true
- platform_name: Linux-powerpc64le - platform_name: Linux-powerpc64le
runs-on: ubuntu-22.04 runs-on: ubuntu-22.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"
expect_cross: "--expect-cross" expect-cross: "--expect-cross"
expect_stripped: "" expect-stripped: ""
can_execute: true can-execute: true
- platform_name: Linux-riscv64 - platform_name: Linux-riscv64
runs-on: ubuntu-22.04 runs-on: ubuntu-22.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"
expect_cross: "--expect-cross" expect-cross: "--expect-cross"
expect_stripped: "" expect-stripped: ""
can_execute: true can-execute: true
- platform_name: Linux-s390x - platform_name: Linux-s390x
runs-on: ubuntu-22.04 runs-on: ubuntu-22.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"
expect_cross: "--expect-cross" expect-cross: "--expect-cross"
expect_stripped: "" expect-stripped: ""
can_execute: true can-execute: true
- platform_name: NetBSD-x86_64 - platform_name: NetBSD-x86_64
runs-on: ubuntu-22.04 runs-on: ubuntu-22.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"
expect_cross: "--expect-cross" expect-cross: "--expect-cross"
expect_stripped: "" expect-stripped: ""
can_execute: false can-execute: false
- platform_name: Windows-aarch64 - platform_name: Windows-aarch64
runs-on: windows-latest runs-on: windows-latest
target: aarch64-pc-windows-msvc target: aarch64-pc-windows-msvc
cache-cross-binary: true cache-cross-binary: true
expect_file_re: "Aarch64.+Windows" expect-file-re: "Aarch64.+Windows"
expect_cross: "" expect-cross: ""
expect_stripped: "" expect-stripped: ""
can_execute: false can-execute: false
- platform_name: Windows-i686 - platform_name: Windows-i686
runs-on: windows-latest runs-on: windows-latest
target: i686-pc-windows-msvc target: i686-pc-windows-msvc
cache-cross-binary: true cache-cross-binary: true
expect_file_re: "80386.+Windows" expect-file-re: "80386.+Windows"
expect_cross: "" expect-cross: ""
expect_stripped: "--expect-stripped" expect-stripped: "--expect-stripped"
can_execute: true can-execute: true
- platform_name: Windows-x86_64 - platform_name: Windows-x86_64
runs-on: windows-latest runs-on: windows-latest
target: x86_64-pc-windows-msvc target: x86_64-pc-windows-msvc
cache-cross-binary: true cache-cross-binary: true
expect_file_re: "x86-64.+Windows" expect-file-re: "x86-64.+Windows"
expect_stripped: "--expect-stripped" expect-stripped: "--expect-stripped"
can_execute: true can-execute: true
- platform_name: macOS-x86_64 - platform_name: macOS-x86_64
runs-on: macOS-latest runs-on: macOS-latest
target: x86_64-apple-darwin target: x86_64-apple-darwin
cache-cross-binary: true cache-cross-binary: true
expect_file_re: "Mach-O.+x86_64" expect-file-re: "Mach-O.+x86_64"
expect_cross: "" expect-cross: ""
expect_stripped: "--expect-stripped" expect-stripped: "--expect-stripped"
can_execute: true can-execute: true
- platform_name: macOS-aarch64 - platform_name: macOS-aarch64
runs-on: macOS-latest runs-on: macOS-latest
target: aarch64-apple-darwin target: aarch64-apple-darwin
cache-cross-binary: true cache-cross-binary: true
expect_file_re: "Mach-O.+arm64" expect-file-re: "Mach-O.+arm64"
expect_cross: "" expect-cross: ""
expect_stripped: "--expect-stripped" expect-stripped: "--expect-stripped"
can_execute: false can-execute: false
runs-on: ${{ matrix.platform.runs-on }} runs-on: ${{ matrix.platform.runs-on }}
steps: steps:
@@ -233,7 +233,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 }}
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
uses: ./ uses: ./
with: with:
@@ -242,7 +242,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 }}
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
uses: ./ uses: ./
with: with:
@@ -252,7 +252,7 @@ jobs:
target: ${{ matrix.platform.target }} target: ${{ matrix.platform.target }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
args: "-- --ignored" args: "-- --ignored"
if: ${{ matrix.platform.can_execute }} if: ${{ matrix.platform.can-execute }}
- name: Run build command - name: Run build command
uses: ./ uses: ./
with: with:
@@ -262,6 +262,18 @@ jobs:
target: ${{ matrix.platform.target }} target: ${{ matrix.platform.target }}
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 }}
shell: bash
run: |
set -e
set -x
cargo run --manifest-path ./run-tests/Cargo.toml -- \
--checkout-root "$PWD" \
--target "${{ matrix.platform.target }}" \
--expect-file-re "${{ matrix.platform.expect-file-re }}" \
--expect-cross-version "${{ matrix.platform.expect-cross-version }}" \
${{ matrix.platform.expect-cross }} \
${{ matrix.platform.expect-stripped }}
- name: Run build command for subdir - name: Run build command for subdir
uses: ./ uses: ./
with: with:
@@ -272,6 +284,19 @@ jobs:
target: ${{ matrix.platform.target }} target: ${{ matrix.platform.target }}
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 }}
shell: bash
run: |
set -e
set -x
cargo run --manifest-path ./run-tests/Cargo.toml -- \
--checkout-root "$PWD" \
--target "${{ matrix.platform.target }}" \
--expect-file-re "${{ matrix.platform.expect-file-re }}" \
--expect-cross-version "${{ matrix.platform.expect-cross-version }}" \
${{ matrix.platform.expect-cross }} \
${{ matrix.platform.expect-stripped }} \
--is-subcrate
- name: Run bench command - name: Run bench command
uses: ./ uses: ./
with: with:
@@ -281,19 +306,7 @@ jobs:
target: ${{ matrix.platform.target }} target: ${{ matrix.platform.target }}
working-directory: bench working-directory: bench
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
if: ${{ matrix.platform.can_execute }} if: ${{ matrix.platform.can-execute }}
- name: Check binary and cross on ${{ matrix.platform.platform_name }}
shell: bash
run: |
set -e
set -x
cargo run --manifest-path ./run-tests/Cargo.toml -- \
--checkout-root "$PWD" \
--target "${{ matrix.platform.target }}" \
--expect-file-re "${{ matrix.platform.expect_file_re }}" \
--expect-cross-version "${{ matrix.platform.expect_cross_version }}" \
${{ matrix.platform.expect_cross }} \
${{ matrix.platform.expect_stripped }}
test-validate-inputs: test-validate-inputs:
name: Test validate-inputs name: Test validate-inputs

View File

@@ -1,3 +1,8 @@
## 1.0.1 - 2025-01-20
- Fixed a bug where this action would attempt to use `cross` when compiling for an ARM Linux target
on an ARM Linux host.
## 1.0.0 - 2025-01-11 ## 1.0.0 - 2025-01-11
The addition of caching is a significant behavior change for this action, so the version has been The addition of caching is a significant behavior change for this action, so the version has been

View File

@@ -16,7 +16,6 @@ jobs:
- os-name: FreeBSD-x86_64 - os-name: FreeBSD-x86_64
runs-on: ubuntu-20.04 runs-on: ubuntu-20.04
target: x86_64-unknown-freebsd target: x86_64-unknown-freebsd
skip_tests: true
- os-name: Linux-x86_64 - os-name: Linux-x86_64
runs-on: ubuntu-20.04 runs-on: ubuntu-20.04
@@ -83,6 +82,26 @@ This action takes the following parameters:
| `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). |
### Setting Environment Variables
By default, `cross` passes most rust-related environment variables through when it runs `cargo` in a
Docker image. This means you can simply set an `env` key in the workflow step that uses this action.
```
- name: Run build command
uses: houseabsolute/actions-rust-cross@v1
env:
CARGO_LOG: debug
RUSTFLAGS: "-g"
with:
command: build
```
If you want to pass other environment variables through, you will need to configure `cross` to do
see. See the
[`cross` docs](https://github.com/cross-rs/cross/blob/main/docs/environment_variables.md#environment-variable-passthrough)
for more details.
## How it Works ## How it Works
Under the hood, this action will compile your binaries with either `cargo` or `cross`, depending on Under the hood, this action will compile your binaries with either `cargo` or `cross`, depending on
@@ -99,13 +118,6 @@ build `cross`.
When compiling on Windows, it will do so in a Powershell environment, which can matter in some When compiling on Windows, it will do so in a Powershell environment, which can matter in some
corner cases, like compiling the `openssl` crate with the `vendored` feature. corner cases, like compiling the `openssl` crate with the `vendored` feature.
By default, it will use
[the `Swatinem/rust-cache@v2` action](https://github.com/Swatinem/rust-cache) to cache compiled
dependencies for this crate. Note that per the documentation for this action, it has fairly limited
value for crates without a `Cargo.lock` file. The `key` parameter passed to this action will always
include the value of the `target` input. If you specify a `key` parameter in
`rust-cache-parameters`, then the `target` input will be appended to the value you specify.
When running `cargo` on a Linux system, it will also include the output of running When running `cargo` on a Linux system, it will also include the output of running
`lsb_release --short --description` in the cache key. This is important for crates that link against `lsb_release --short --description` in the cache key. This is important for crates that link against
system libraries. If those library versions change across OS versions (e.g. Ubuntu 20.04 to 22.04), system libraries. If those library versions change across OS versions (e.g. Ubuntu 20.04 to 22.04),
@@ -118,3 +130,34 @@ that we do not re-use the cache across changes when these images change.
Finally, it will run `strip` to strip the binaries it builds if the `strip` parameter is true. This Finally, it will run `strip` to strip the binaries it builds if the `strip` parameter is true. This
is only possible for builds that are not done via `cross`. In addition, Windows builds for `aarch64` is only possible for builds that are not done via `cross`. In addition, Windows builds for `aarch64`
cannot be stripped either. cannot be stripped either.
### Caching
By default, this action will use
[the `Swatinem/rust-cache@v2` action](https://github.com/Swatinem/rust-cache) to cache compiled
dependencies for a crate. Note that per the documentation for the `rust-cache` action, it has fairly
limited value for crates without a `Cargo.lock` file. The `key` parameter passed to this action will
always include the value of the `target` input. If you specify a `key` parameter in
`rust-cache-parameters`, then the `target` input will be appended to the value you specify.
#### Weird Caching Issue with Multiple Crates
In my testing, it seemed like in some cases restoring the cache would delete existing files in a
`target` directory. This manifested with this sequence of actions:
1. Run `actions-rust-cross` to compile a crate in a top-level directory.
2. Run `actions-rust-cross` to compile a crate in a subdirectory.
After step 2, the compiled binaries from step 1 were no longer present, _sometimes_. I'm not sure
exactly what's going on here, but my recommendation is to structure your workflows so that this
cannot affect you.
For example, if you have multiple crates, each of which builds a binary you want to release, then
you can avoid this issue by structuring your workflow as follows:
1. Run `actions-rust-cross` to compile crate A.
2. Run the release steps for crate A.
3. Run `actions-rust-cross` to compile 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.

View File

@@ -76,7 +76,7 @@ runs:
- 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.sh ${{ inputs.target }} run: set-cross-compile.py ${{ inputs.target }}
- name: Install toolchain - name: Install toolchain
uses: dtolnay/rust-toolchain@master uses: dtolnay/rust-toolchain@master
with: with:

View File

@@ -2,7 +2,7 @@
node = "22.11.0" node = "22.11.0"
"npm:prettier" = "3.4.1" "npm:prettier" = "3.4.1"
ruff = "0.8.3" ruff = "0.8.3"
shellcheck = "v0.10.0" shellcheck = "0.10.0"
shfmt = "v3.10.0" shfmt = "v3.10.0"
taplo = "0.9.3" taplo = "0.9.3"
typos = "1.28.1" typos = "1.28.1"

View File

@@ -24,6 +24,8 @@ struct Args {
expect_cross_version: Option<String>, expect_cross_version: Option<String>,
#[arg(long)] #[arg(long)]
expect_stripped: bool, expect_stripped: bool,
#[arg(long)]
is_subcrate: bool,
} }
fn main() { fn main() {
@@ -39,24 +41,27 @@ fn main() {
); );
let checkout_root_path = PathBuf::from(args.checkout_root); let checkout_root_path = PathBuf::from(args.checkout_root);
let bin_paths = vec![ let bin_paths = if args.is_subcrate {
checkout_root_path vec![checkout_root_path
.join("target")
.join(&args.target)
.join("debug")
.join("bin1"),
checkout_root_path
.join("target")
.join(&args.target)
.join("debug")
.join("bin2"),
checkout_root_path
.join("subcrate") .join("subcrate")
.join("target") .join("target")
.join(&args.target) .join(&args.target)
.join("debug") .join("debug")
.join("subcrate"), .join("subcrate")]
]; } else {
vec![
checkout_root_path
.join("target")
.join(&args.target)
.join("debug")
.join("bin1"),
checkout_root_path
.join("target")
.join(&args.target)
.join("debug")
.join("bin2"),
]
};
for mut bin_path in bin_paths { for mut bin_path in bin_paths {
if cfg!(windows) { if cfg!(windows) {

97
set-cross-compile.py Executable file
View File

@@ -0,0 +1,97 @@
#!/usr/bin/env python3
# Written mostly by Claude.ai based on my original bash script.
import sys
import platform
import re
import os
from subprocess import run, PIPE, CalledProcessError
def main() -> int:
"""
Main function to determine cross-compilation requirements.
Returns:
Exit code (0 for success)
"""
if len(sys.argv) < 2:
print("Error: Target architecture argument is required", file=sys.stderr)
return 1
target = sys.argv[1]
needs_cross = check_needs_cross(target)
write_github_output(needs_cross)
return 0
def check_needs_cross(target: str) -> bool:
"""
Determine if cross-compilation is needed based on system and target.
Args:
target: Target architecture string
Returns:
Boolean indicating if cross-compilation is needed
"""
system_info = get_uname_info().lower()
# Check if we're on macOS or Windows
if any(os in system_info for os in ["darwin", "msys", "windows"]):
return False
target = target.lower()
# Check for x86_64 Linux targets on x86_64 Linux host
if (
re.search(r"x86_64.+linux-(?:gnu|musl)", target)
and "x86_64" in system_info
and "linux" in system_info
):
return False
# 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.
if (
re.search(r"(?:aarch64|arm).+linux-(?:gnu|musl)", target)
and ("arm" in system_info or "aarch64" in system_info)
and "linux" in system_info
):
return False
return True
def get_uname_info() -> str:
"""
Get system information using uname command.
Returns:
String containing system information
"""
try:
result = run(["uname", "-a"], check=True, text=True, stdout=PIPE)
return result.stdout
except (CalledProcessError, FileNotFoundError):
# Fallback to platform.platform() if uname is not available
return platform.platform()
def write_github_output(needs_cross: bool) -> None:
"""
Write the needs-cross output to GITHUB_OUTPUT environment variable file.
Args:
needs_cross: Boolean indicating if cross-compilation is needed
"""
github_output = os.getenv("GITHUB_OUTPUT")
if github_output:
with open(github_output, "a") as f:
f.write(f"needs-cross={str(needs_cross).lower()}\n")
if __name__ == "__main__":
sys.exit(main())

View File

@@ -1,25 +0,0 @@
#!/bin/bash
set -e
set -x
set -o pipefail
TARGET="$1"
# On macOS and Windows, we can cross-compile to all possible targets without
# using cross.
if uname -a | grep --quiet --extended-regexp -i "darwin|msys|windows"; then
echo "needs-cross=false" >>"$GITHUB_OUTPUT"
exit 0
fi
# On Linux, we should be able to cross-compile to i586 and i686, but in
# practice this fails with some crates, notably openssl with the "vendored"
# feature. This feature makes it compile openssl itself, which fails without
# cross.
if echo "$TARGET" | grep --quiet --extended-regexp -i 'x86_64.+linux-(gnu|musl)'; then
echo "needs-cross=false" >>"$GITHUB_OUTPUT"
exit 0
fi
echo "needs-cross=true" >>"$GITHUB_OUTPUT"

View File

@@ -19,7 +19,7 @@ path = "src/bin2.rs"
[package.metadata.cross.target.x86_64-unknown-netbsd] [package.metadata.cross.target.x86_64-unknown-netbsd]
pre-build = [ pre-build = [
"mkdir -p /tmp/netbsd", "mkdir -p /tmp/netbsd",
"curl https://cdn.netbsd.org/pub/NetBSD/NetBSD-9.2/amd64/binary/sets/base.tar.xz -O", "curl https://archive.netbsd.org/pub/NetBSD-archive/NetBSD-9.2/amd64/binary/sets/base.tar.xz -O",
"tar -C /tmp/netbsd -xJf base.tar.xz", "tar -C /tmp/netbsd -xJf base.tar.xz",
"cp /tmp/netbsd/usr/lib/libexecinfo.so /usr/local/x86_64-unknown-netbsd/lib", "cp /tmp/netbsd/usr/lib/libexecinfo.so /usr/local/x86_64-unknown-netbsd/lib",
"rm base.tar.xz", "rm base.tar.xz",

View File

@@ -7,7 +7,7 @@ edition = "2021"
[package.metadata.cross.target.x86_64-unknown-netbsd] [package.metadata.cross.target.x86_64-unknown-netbsd]
pre-build = [ pre-build = [
"mkdir -p /tmp/netbsd", "mkdir -p /tmp/netbsd",
"curl https://cdn.netbsd.org/pub/NetBSD/NetBSD-9.2/amd64/binary/sets/base.tar.xz -O", "curl https://archive.netbsd.org/pub/NetBSD-archive/NetBSD-9.2/amd64/binary/sets/base.tar.xz -O",
"tar -C /tmp/netbsd -xJf base.tar.xz", "tar -C /tmp/netbsd -xJf base.tar.xz",
"cp /tmp/netbsd/usr/lib/libexecinfo.so /usr/local/x86_64-unknown-netbsd/lib", "cp /tmp/netbsd/usr/lib/libexecinfo.so /usr/local/x86_64-unknown-netbsd/lib",
"rm base.tar.xz", "rm base.tar.xz",