Skip to content

Commit

Permalink
Various improvements
Browse files Browse the repository at this point in the history
- Support binfmt. This allows running the cross-compiled binaries
  directly.
- Set the `DOCTEST_XCOMPILE` environment variable to easily run
  cross-testing of doctest.
- Add `runner` input option.
  • Loading branch information
taiki-e committed Feb 22, 2022
1 parent 71d4055 commit 96c84d0
Show file tree
Hide file tree
Showing 5 changed files with 251 additions and 130 deletions.
20 changes: 16 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,22 @@ on:
push:
branches:
- main
- dev
# - dev
schedule:
- cron: '0 0 * * *'
workflow_dispatch:

env:
CARGO_INCREMENTAL: 0
CARGO_NET_RETRY: 10
CARGO_TERM_COLOR: always
QEMU_STRACE: 1
RUST_BACKTRACE: full
RUST_TEST_THREADS: 1
RUSTDOCFLAGS: -D warnings
RUSTFLAGS: -D warnings
RUSTUP_MAX_RETRIES: 10

defaults:
run:
shell: bash
Expand Down Expand Up @@ -90,10 +101,11 @@ jobs:
working-directory: rust-cross-toolchain/docker/test/fixtures/rust
- run: cargo $BUILD_STD run --verbose --target ${{ matrix.target }}
working-directory: rust-cross-toolchain/docker/test/fixtures/rust
if: matrix.target != 'x86_64-unknown-linux-gnux32'
- run: cargo $BUILD_STD test --verbose --target ${{ matrix.target }}
- run: cargo $BUILD_STD test --verbose --target ${{ matrix.target }} $DOCTEST_XCOMPILE
working-directory: rust-cross-toolchain/docker/test/fixtures/rust
if: matrix.target != 'x86_64-unknown-linux-gnux32'
- run: ./target/${{ matrix.target }}/debug/rust-test
working-directory: rust-cross-toolchain
if: matrix.target != 'mipsisa32r6el-unknown-linux-gnu'

tidy:
runs-on: ubuntu-latest
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ Note: In this file, do not use the hard wrap in the middle of a sentence for com

## [Unreleased]

- Support binfmt. This allows running the cross-compiled binaries directly.

- Set the `DOCTEST_XCOMPILE` environment variable to easily run cross-testing of doctest.

- Add `runner` input option.

## [1.0.0] - 2022-02-20

Initial release
Expand Down
95 changes: 68 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@ GitHub Action for setup toolchains for cross compilation and cross testing for R

### Inputs

| Name | Required | Description | Type | Default |
|----------|:--------:|----------------------------------------------------------------------------------|--------|----------------|
| target | **true** | Target triple | String | |
| Name | Required | Description | Type | Default |
|----------|:--------:|---------------|--------|----------------|
| target | **true** | Target triple | String | |
| runner | false | Test runner | String | |

### Example workflow: Basic usage

Expand All @@ -39,6 +40,10 @@ jobs:
# setup-cross-toolchain sets the `CARGO_BUILD_TARGET` environment variable,
# so there is no need for an explicit `--target` flag.
- run: cargo test --verbose
# `cargo run` also works.
- run: cargo run --verbose
# You can also run the cross-compiled binaries directly.
- run: ./target/aarch64-unknown-linux-gnu/debug/my-app
```
### Example workflow: Multiple targets
Expand Down Expand Up @@ -80,51 +85,87 @@ jobs:
- run: cargo test --verbose -Z doctest-xcompile
```
Cross-testing of doctest is currently available only on nightly.
If you want to use stable and nightly in the same matrix, you can use the `DOCTEST_XCOMPILE` environment variable set by this action to enable doctest only in nightly.

```yaml
jobs:
test:
strategy:
matrix:
rust:
- stable
- nightly
target:
- aarch64-unknown-linux-gnu
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install Rust
run: rustup update ${{ matrix.rust }} && rustup default ${{ matrix.rust }}
- name: Install cross-compilation tools
uses: taiki-e/setup-cross-toolchain@v1
with:
target: ${{ matrix.target }}
# On nightly and `-Z doctest-xcompile` is available,
# `$DOCTEST_XCOMPILE` is `-Z doctest-xcompile`.
#
# On stable, `$DOCTEST_XCOMPILE` is not set.
# Once `-Z doctest-xcompile` is stabilized, the corresponding flag
# will be set to `$DOCTEST_XCOMPILE` (if it is available).
- run: cargo test --verbose $DOCTEST_XCOMPILE
```
## Platform Support
### Linux (GNU)
| C++ | test |
| --- | ---- |
| ✓ (libstdc++) | ✓ (qemu) |
| ✓ (libstdc++) | ✓ |
**Supported targets**:
| target | host |
| ------ | ----- |
| `aarch64-unknown-linux-gnu` | ubuntu-latest/ubuntu-20.04 [1], ubuntu-18.04 [2] |
| `arm-unknown-linux-gnueabi` | ubuntu-latest/ubuntu-20.04 [1], ubuntu-18.04 [2] |
| `armv5te-unknown-linux-gnueabi` | ubuntu-latest/ubuntu-20.04 [1], ubuntu-18.04 [2] |
| `armv7-unknown-linux-gnueabi` | ubuntu-latest/ubuntu-20.04 [1], ubuntu-18.04 [2] |
| `armv7-unknown-linux-gnueabihf` | ubuntu-latest/ubuntu-20.04 [1], ubuntu-18.04 [2] |
| `i586-unknown-linux-gnu` | ubuntu-latest/ubuntu-20.04 [1], ubuntu-18.04 [2] |
| `i686-unknown-linux-gnu` | ubuntu-latest/ubuntu-20.04 [1], ubuntu-18.04 [2] |
| `mips-unknown-linux-gnu` | <!-- ubuntu-latest/ubuntu-20.04 [1],--> ubuntu-18.04 [2] |
| `mips64-unknown-linux-gnuabi64` | <!-- ubuntu-latest/ubuntu-20.04 [1],--> ubuntu-18.04 [2] |
| `mips64el-unknown-linux-gnuabi64` | ubuntu-latest/ubuntu-20.04 [1], ubuntu-18.04 [2] |
| `mipsel-unknown-linux-gnu` | ubuntu-latest/ubuntu-20.04 [1], ubuntu-18.04 [2] |
| `mipsisa32r6el-unknown-linux-gnu` (tier3) | ubuntu-latest/ubuntu-20.04 [1] |
| `mipsisa64r6el-unknown-linux-gnuabi64` (tier3) | ubuntu-latest/ubuntu-20.04 [1] |
| `powerpc-unknown-linux-gnu` | ubuntu-latest/ubuntu-20.04 [1], ubuntu-18.04 [2] |
| `powerpc64-unknown-linux-gnu` | <!-- ubuntu-latest/ubuntu-20.04 [1],--> ubuntu-18.04 [2] |
| `powerpc64le-unknown-linux-gnu` | ubuntu-latest/ubuntu-20.04 [1], ubuntu-18.04 [2] |
| `riscv64gc-unknown-linux-gnu` | ubuntu-latest/ubuntu-20.04 [1] <!--, ubuntu-18.04 [2]--> |
| `s390x-unknown-linux-gnu` | ubuntu-latest/ubuntu-20.04 [1], ubuntu-18.04 [2] |
| `sparc64-unknown-linux-gnu` | <!-- ubuntu-latest/ubuntu-20.04 [1],--> ubuntu-18.04 [2] |
| `thumbv7neon-unknown-linux-gnueabihf` | ubuntu-latest/ubuntu-20.04 [1], ubuntu-18.04 [2] |
| `x86_64-unknown-linux-gnu` [3] | ubuntu-latest/ubuntu-20.04 [1], ubuntu-18.04 [2] |
| target | host | runner |
| ------ | ----- | ------ |
| `aarch64-unknown-linux-gnu` | ubuntu-latest/ubuntu-20.04 [1], ubuntu-18.04 [2] | qemu-user |
| `arm-unknown-linux-gnueabi` | ubuntu-latest/ubuntu-20.04 [1], ubuntu-18.04 [2] | qemu-user |
| `armv5te-unknown-linux-gnueabi` | ubuntu-latest/ubuntu-20.04 [1], ubuntu-18.04 [2] | qemu-user |
| `armv7-unknown-linux-gnueabi` | ubuntu-latest/ubuntu-20.04 [1], ubuntu-18.04 [2] | qemu-user |
| `armv7-unknown-linux-gnueabihf` | ubuntu-latest/ubuntu-20.04 [1], ubuntu-18.04 [2] | qemu-user |
| `i586-unknown-linux-gnu` | ubuntu-latest/ubuntu-20.04 [1], ubuntu-18.04 [2] | native (default), qemu-user |
| `i686-unknown-linux-gnu` | ubuntu-latest/ubuntu-20.04 [1], ubuntu-18.04 [2] | native (default), qemu-user |
| `mips-unknown-linux-gnu` | <!-- ubuntu-latest/ubuntu-20.04 [1],--> ubuntu-18.04 [2] | qemu-user |
| `mips64-unknown-linux-gnuabi64` | <!-- ubuntu-latest/ubuntu-20.04 [1],--> ubuntu-18.04 [2] | qemu-user |
| `mips64el-unknown-linux-gnuabi64` | ubuntu-latest/ubuntu-20.04 [1], ubuntu-18.04 [2] | qemu-user |
| `mipsel-unknown-linux-gnu` | ubuntu-latest/ubuntu-20.04 [1], ubuntu-18.04 [2] | qemu-user |
| `mipsisa32r6el-unknown-linux-gnu` (tier3) | ubuntu-latest/ubuntu-20.04 [1] | qemu-user [4] |
| `mipsisa64r6el-unknown-linux-gnuabi64` (tier3) | ubuntu-latest/ubuntu-20.04 [1] | qemu-user |
| `powerpc-unknown-linux-gnu` | ubuntu-latest/ubuntu-20.04 [1], ubuntu-18.04 [2] | qemu-user |
| `powerpc64-unknown-linux-gnu` | <!-- ubuntu-latest/ubuntu-20.04 [1],--> ubuntu-18.04 [2] | qemu-user |
| `powerpc64le-unknown-linux-gnu` | ubuntu-latest/ubuntu-20.04 [1], ubuntu-18.04 [2] | qemu-user |
| `riscv64gc-unknown-linux-gnu` | ubuntu-latest/ubuntu-20.04 [1] <!--, ubuntu-18.04 [2]--> | qemu-user |
| `s390x-unknown-linux-gnu` | ubuntu-latest/ubuntu-20.04 [1], ubuntu-18.04 [2] | qemu-user |
| `sparc64-unknown-linux-gnu` | <!-- ubuntu-latest/ubuntu-20.04 [1],--> ubuntu-18.04 [2] | qemu-user |
| `thumbv7neon-unknown-linux-gnueabihf` | ubuntu-latest/ubuntu-20.04 [1], ubuntu-18.04 [2] | qemu-user |
| `x86_64-unknown-linux-gnu` [3] | ubuntu-latest/ubuntu-20.04 [1], ubuntu-18.04 [2] | native (default), qemu-user |

[1] GCC 9, glibc 2.31<br>
[2] GCC 7, glibc 2.27<br>
[3] no-op<br>
[4] binfmt doesn't work<br>

## Related Projects

- [rust-cross-toolchain]: Toolchains for cross compilation and cross testing for Rust.
- [install-action]: GitHub Action for installing development tools.
- [create-gh-release-action]: GitHub Action for creating GitHub Releases based on changelog.
- [upload-rust-binary-action]: GitHub Action for building and uploading Rust binary to GitHub Releases.

[create-gh-release-action]: https://github.com/taiki-e/create-gh-release-action
[install-action]: https://github.com/taiki-e/install-action
[rust-cross-toolchain]: https://github.com/taiki-e/rust-cross-toolchain
[upload-rust-binary-action]: https://github.com/taiki-e/upload-rust-binary-action

## License

Expand Down
3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ inputs:
target:
description: Target name
required: true
runner:
description: Test runner
required: false

runs:
using: node16
Expand Down
Loading

0 comments on commit 96c84d0

Please sign in to comment.