Add support for running test command as well as build
Some checks failed
Self-test / Test (map[can_test:false expect_cross:false expect_file:Aarch64.+Windows os:windows-latest platform_name:Windows-aarch64 target:aarch64-pc-windows-msvc]) (push) Has been cancelled
Self-test / Test (map[can_test:false expect_cross:false expect_file:Mach-O.+arm64 os:macOS-latest platform_name:macOS-aarch64 target:aarch64-apple-darwin]) (push) Has been cancelled
Self-test / Test (map[can_test:false expect_cross:true expect_file:x86-64.+FreeBSD os:ubuntu-20.04 platform_name:FreeBSD-x86_64 target:x86_64-unknown-freebsd]) (push) Has been cancelled
Self-test / Test (map[can_test:false expect_cross:true expect_file:x86-64.+NetBSD os:ubuntu-20.04 platform_name:NetBSD-x86_64 target:x86_64-unknown-netbsd]) (push) Has been cancelled
Self-test / Test (map[can_test:true expect_cross:false expect_file:80386.+Windows os:windows-latest platform_name:Windows-i686 target:i686-pc-windows-msvc]) (push) Has been cancelled
Self-test / Test (map[can_test:true expect_cross:false expect_file:ELF.+80386 os:ubuntu-20.04 platform_name:Linux-i586 target:i586-unknown-linux-musl]) (push) Has been cancelled
Self-test / Test (map[can_test:true expect_cross:false expect_file:ELF.+x86-64 os:ubuntu-20.04 platform_name:Linux-x86_64 target:x86_64-unknown-linux-musl]) (push) Has been cancelled
Self-test / Test (map[can_test:true expect_cross:false expect_file:Mach-O.+x86_64 os:macOS-latest platform_name:macOS-x86_64 target:x86_64-apple-darwin]) (push) Has been cancelled
Self-test / Test (map[can_test:true expect_cross:false expect_file:x86-64.+Windows os:windows-latest platform_name:Windows-x86_64 target:x86_64-pc-windows-msvc]) (push) Has been cancelled
Self-test / Test (map[can_test:true expect_cross:true expect_file:32.+ARM os:ubuntu-20.04 platform_name:Linux-arm target:arm-unknown-linux-musleabi]) (push) Has been cancelled
Self-test / Test (map[can_test:true expect_cross:true expect_file:32.+PowerPC os:ubuntu-20.04 platform_name:Linux-powerpc target:powerpc-unknown-linux-gnu]) (push) Has been cancelled
Self-test / Test (map[can_test:true expect_cross:true expect_file:64.+PowerPC os:ubuntu-20.04 platform_name:Linux-powerpc64 target:powerpc64-unknown-linux-gnu]) (push) Has been cancelled
Self-test / Test (map[can_test:true expect_cross:true expect_file:64.+PowerPC os:ubuntu-20.04 platform_name:Linux-powerpc64le target:powerpc64le-unknown-linux-gnu]) (push) Has been cancelled
Self-test / Test (map[can_test:true expect_cross:true expect_file:64.+RISC-V os:ubuntu-20.04 platform_name:Linux-riscv64 target:riscv64gc-unknown-linux-gnu]) (push) Has been cancelled
Self-test / Test (map[can_test:true expect_cross:true expect_file:64.+S/390 os:ubuntu-20.04 platform_name:Linux-s390x target:s390x-unknown-linux-gnu]) (push) Has been cancelled
Self-test / Test (map[can_test:true expect_cross:true expect_file:MIPS32.+mips- os:ubuntu-20.04 platform_name:Linux-mips target:mips-unknown-linux-musl]) (push) Has been cancelled
Self-test / Test (map[can_test:true expect_cross:true expect_file:MIPS32.+mipsel- os:ubuntu-20.04 platform_name:Linux-mipsel target:mipsel-unknown-linux-musl]) (push) Has been cancelled
Self-test / Test (map[can_test:true expect_cross:true expect_file:MIPS64 os:ubuntu-20.04 platform_name:Linux-mips64 target:mips64-unknown-linux-muslabi64]) (push) Has been cancelled
Self-test / Test (map[can_test:true expect_cross:true expect_file:MIPS64 os:ubuntu-20.04 platform_name:Linux-mips64el target:mips64el-unknown-linux-muslabi64]) (push) Has been cancelled
Self-test / Test (map[can_test:true expect_cross:true expect_file:aarch64 os:ubuntu-20.04 platform_name:Linux-aarch64 target:aarch64-unknown-linux-musl]) (push) Has been cancelled

This commit is contained in:
Dave Rolsky
2023-03-17 10:43:28 -04:00
parent 5bd32448aa
commit 2f68f636e2
5 changed files with 77 additions and 12 deletions

View File

@@ -16,120 +16,140 @@ jobs:
target: x86_64-unknown-freebsd
expect_file: "x86-64.+FreeBSD"
expect_cross: true
can_test: false
- platform_name: Linux-x86_64
os: ubuntu-20.04
target: x86_64-unknown-linux-musl
expect_file: "ELF.+x86-64"
expect_cross: false
can_test: true
- platform_name: Linux-aarch64
os: ubuntu-20.04
target: aarch64-unknown-linux-musl
expect_file: "aarch64"
expect_cross: true
can_test: true
- platform_name: Linux-arm
os: ubuntu-20.04
target: arm-unknown-linux-musleabi
expect_file: "32.+ARM"
expect_cross: true
can_test: true
- platform_name: Linux-i586
os: ubuntu-20.04
target: i586-unknown-linux-musl
expect_file: "ELF.+80386"
expect_cross: false
can_test: true
- platform_name: Linux-mips
os: ubuntu-20.04
target: mips-unknown-linux-musl
expect_file: "MIPS32.+mips-"
expect_cross: true
can_test: true
- platform_name: Linux-mipsel
os: ubuntu-20.04
target: mipsel-unknown-linux-musl
expect_file: "MIPS32.+mipsel-"
expect_cross: true
can_test: true
- platform_name: Linux-mips64
os: ubuntu-20.04
target: mips64-unknown-linux-muslabi64
expect_file: "MIPS64"
expect_cross: true
can_test: true
- platform_name: Linux-mips64el
os: ubuntu-20.04
target: mips64el-unknown-linux-muslabi64
expect_file: "MIPS64"
expect_cross: true
can_test: true
- platform_name: Linux-powerpc
os: ubuntu-20.04
target: powerpc-unknown-linux-gnu
expect_file: "32.+PowerPC"
expect_cross: true
can_test: true
- platform_name: Linux-powerpc64
os: ubuntu-20.04
target: powerpc64-unknown-linux-gnu
expect_file: "64.+PowerPC"
expect_cross: true
can_test: true
- platform_name: Linux-powerpc64le
os: ubuntu-20.04
target: powerpc64le-unknown-linux-gnu
expect_file: "64.+PowerPC"
expect_cross: true
can_test: true
- platform_name: Linux-riscv64
os: ubuntu-20.04
target: riscv64gc-unknown-linux-gnu
expect_file: "64.+RISC-V"
expect_cross: true
can_test: true
- platform_name: Linux-s390x
os: ubuntu-20.04
target: s390x-unknown-linux-gnu
expect_file: "64.+S/390"
expect_cross: true
can_test: true
- platform_name: NetBSD-x86_64
os: ubuntu-20.04
target: x86_64-unknown-netbsd
expect_file: "x86-64.+NetBSD"
expect_cross: true
can_test: false
- platform_name: Windows-aarch64
os: windows-latest
target: aarch64-pc-windows-msvc
expect_file: "Aarch64.+Windows"
expect_cross: false
can_test: false
- platform_name: Windows-i686
os: windows-latest
target: i686-pc-windows-msvc
expect_file: "80386.+Windows"
expect_cross: false
can_test: true
- platform_name: Windows-x86_64
os: windows-latest
target: x86_64-pc-windows-msvc
expect_file: "x86-64.+Windows"
expect_cross: false
can_test: true
- platform_name: macOS-x86_64
os: macOS-latest
target: x86_64-apple-darwin
expect_file: "Mach-O.+x86_64"
expect_cross: false
can_test: true
- platform_name: macOS-aarch64
os: macOS-latest
target: aarch64-apple-darwin
expect_file: "Mach-O.+arm64"
expect_cross: false
can_test: false
runs-on: ${{ matrix.platform.os }}
steps:
@@ -146,9 +166,22 @@ jobs:
run: |
cp -a test-project/* .
rm -fr test-project
- name: Use self
- name: Run both commands
uses: "houseabsolute/actions-rust-cross@v0"
with:
command: both
target: ${{ matrix.platform.target }}
if: ${{ matrix.platform.can_test }}
- name: Run test command
uses: "houseabsolute/actions-rust-cross@v0"
with:
command: test
target: ${{ matrix.platform.target }}
if: ${{ matrix.platform.can_test }}
- name: Run build command
uses: "houseabsolute/actions-rust-cross@v0"
with:
command: build
target: ${{ matrix.platform.target }}
- name: Check for cross on ${{ matrix.platform.platform_name }}
shell: bash

View File

@@ -1,3 +1,8 @@
## 0.0.3 - 2023-03-17
- This action now supports running the `build` and `test` commands, or both,
with a new input parameter, `command`. The default is `build`.
## 0.0.2 - 2023-03-05
- Fixed some typos in the `README.md` documentation.

View File

@@ -18,18 +18,21 @@ jobs:
target: x86_64-unknown-freebsd
bin: precious
name: precious-FreeBSD-x86_64.tar.gz
command: build
- release_for: Windows-x86_64
os: windows-latest
target: x86_64-pc-windows-msvc
bin: precious.exe
name: precious-Windows-x86_64.zip
command: both
- release_for: macOS-x86_64
os: macOS-latest
target: x86_64-apple-darwin
bin: precious
name: precious-Darwin-x86_64.tar.gz
command: both
# more release targets here ...
@@ -40,6 +43,7 @@ jobs:
- name: Build binary
uses: houseabsolute/actions-rust-cross@v0
with:
command: ${{ matrix.platform.command }}
target: ${{ matrix.platform.target }}
args: "--locked --release"
strip: true
@@ -52,7 +56,8 @@ jobs:
This action takes the following parameters:
| Key | Type | Required? | Description |
| -------------- | --------------------------- | --------- | ----------------------------------------------------------------------------------------------------------------------------------------- |
| -------------- | ------------------------------------------ | --------- | ----------------------------------------------------------------------------------------------------------------------------------------- |
| `command` | string (one of `build`, `test`, or `both`) | no | The command(s) to run. The default is `build`. Running the `test` command will fails with \*BSD targets, non-x86 Windows, and macOS ARM. |
| `target` | string | yes | The target triple to compile for. This should be one of the targets listed by running `rustup target list`. |
| `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`. |

View File

@@ -6,6 +6,10 @@ branding:
description: |
Cross compile your Rust projects with cross (https://github.com/cross-rs/cross).
inputs:
command:
description: |
The commands to run (one of "build", "test", or "both").
default: build
target:
description: The target platform
required: true
@@ -52,23 +56,33 @@ runs:
id: set-build-command
shell: bash
run: set-build-command.sh
- name: Build binary (*nix)
- name: Run tests (*nix)
shell: bash
run: |
${{ steps.set-build-command.outputs.build-command }} build ${{ inputs.args }} --target ${{ inputs.target }}
if: ${{ runner.os != 'Windows' }}
${{ steps.set-build-command.outputs.build-command }} test ${{ inputs.args }} --target ${{ inputs.target }}
if: ${{ inputs.command != 'build' && runner.os != 'Windows' }}
# 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)
shell: powershell
run: |
& ${{ steps.set-build-command.outputs.build-command }} test ${{ inputs.args }} --target ${{ inputs.target }}
if: ${{ inputs.command != 'build' && runner.os == 'Windows' }}
- name: Build binary (*nix)
shell: bash
run: |
${{ steps.set-build-command.outputs.build-command }} build ${{ inputs.args }} --target ${{ inputs.target }}
if: ${{ inputs.command != 'test' && runner.os != 'Windows' }}
- name: Build binary (Windows)
shell: powershell
run: |
& ${{ steps.set-build-command.outputs.build-command }} build ${{ inputs.args }} --target ${{ inputs.target }}
if: ${{ runner.os == 'Windows' }}
if: ${{ inputs.command != 'test' && runner.os == 'Windows' }}
- name: Strip binary
shell: bash
run: |
strip target/${{ matrix.platform.target }}/release/${{ matrix.platform.bin }}
# strip doesn't work with cross-arch binaries on Linux or Windows.
if: ${{ inputs.strip == 'true' && steps.determine-cross-compile.outputs.needs-cross == 'false' && inputs.target != 'aarch64-pc-windows-msvc' }}
if: ${{ inputs.command != 'test' && inputs.strip == 'true' && steps.determine-cross-compile.outputs.needs-cross == 'false' && inputs.target != 'aarch64-pc-windows-msvc' }}

View File

@@ -1,3 +1,11 @@
fn main() {
println!("Hello, world!");
}
#[cfg(test)]
mod test {
#[test]
fn test_something() {
assert_eq!(1, 1);
}
}