2020-07-03 11:38:52 -04:00
|
|
|
name: Test
|
|
|
|
|
2023-08-20 12:41:16 -04:00
|
|
|
on:
|
|
|
|
pull_request:
|
|
|
|
workflow_dispatch:
|
2020-07-03 11:38:52 -04:00
|
|
|
|
|
|
|
jobs:
|
2020-07-03 11:51:57 -04:00
|
|
|
test:
|
2020-07-03 11:55:22 -04:00
|
|
|
name: ${{ matrix.target }}
|
2020-07-03 11:38:52 -04:00
|
|
|
runs-on: ${{ matrix.os }}
|
|
|
|
strategy:
|
|
|
|
matrix:
|
|
|
|
include:
|
|
|
|
- os: ubuntu-latest
|
|
|
|
target: x86_64-unknown-linux-gnu
|
2021-02-28 23:41:21 -05:00
|
|
|
use-cross: false
|
2020-07-03 11:38:52 -04:00
|
|
|
|
|
|
|
- os: ubuntu-latest
|
|
|
|
target: x86_64-unknown-linux-musl
|
2021-02-28 23:41:21 -05:00
|
|
|
use-cross: false
|
|
|
|
|
|
|
|
- os: ubuntu-latest
|
|
|
|
target: arm-unknown-linux-gnueabihf
|
|
|
|
use-cross: true
|
2020-07-03 11:38:52 -04:00
|
|
|
|
2023-08-20 12:42:08 -04:00
|
|
|
- os: windows-latest
|
|
|
|
target: x86_64-pc-windows-gnu
|
|
|
|
use-cross: false
|
|
|
|
|
|
|
|
- os: windows-latest
|
|
|
|
target: x86_64-pc-windows-msvc
|
|
|
|
use-cross: false
|
2020-07-03 11:38:52 -04:00
|
|
|
|
|
|
|
- os: macos-latest
|
|
|
|
target: x86_64-apple-darwin
|
2021-02-28 23:41:21 -05:00
|
|
|
use-cross: false
|
2020-07-03 11:38:52 -04:00
|
|
|
|
2023-10-23 19:36:58 -06:00
|
|
|
- os: macos-latest
|
|
|
|
target: aarch64-apple-darwin
|
|
|
|
use-cross: false
|
2023-05-17 14:54:28 -04:00
|
|
|
|
|
|
|
- os: ubuntu-latest
|
|
|
|
target: aarch64-unknown-linux-musl
|
|
|
|
use-cross: true
|
|
|
|
|
2023-08-20 12:38:02 -04:00
|
|
|
- os: ubuntu-latest
|
|
|
|
target: armv7-unknown-linux-gnueabihf
|
|
|
|
use-cross: true
|
|
|
|
|
2020-07-03 11:38:52 -04:00
|
|
|
steps:
|
2020-07-03 11:40:54 -04:00
|
|
|
- name: Checkout repository
|
2023-09-23 21:57:51 -06:00
|
|
|
uses: actions/checkout@v4
|
2020-07-03 11:40:54 -04:00
|
|
|
with:
|
|
|
|
fetch-depth: 1
|
|
|
|
|
|
|
|
- name: Install Rust
|
2023-10-20 18:02:45 -06:00
|
|
|
uses: dtolnay/rust-toolchain@stable
|
2020-07-03 11:40:54 -04:00
|
|
|
with:
|
2023-10-20 18:02:45 -06:00
|
|
|
targets: ${{ matrix.target }}
|
2020-07-03 11:38:52 -04:00
|
|
|
|
2023-10-21 20:06:52 -06:00
|
|
|
- name: Setup native compilation
|
|
|
|
if: ${{ matrix.use-cross == false }}
|
|
|
|
shell: bash
|
|
|
|
run: |
|
|
|
|
echo "CARGO=cargo" >> $GITHUB_ENV
|
|
|
|
|
2023-10-20 18:02:45 -06:00
|
|
|
- name: Install Cross
|
2021-03-19 16:12:55 +01:00
|
|
|
if: ${{ matrix.use-cross == true }}
|
|
|
|
shell: bash
|
|
|
|
run: |
|
2023-10-20 18:02:45 -06:00
|
|
|
dir="$RUNNER_TEMP/cross-download"
|
|
|
|
mkdir "$dir"
|
|
|
|
echo "$dir" >> $GITHUB_PATH
|
|
|
|
cd "$dir"
|
|
|
|
curl -LO "https://github.com/cross-rs/cross/releases/download/v0.2.5/cross-x86_64-unknown-linux-musl.tar.gz"
|
|
|
|
tar xf cross-x86_64-unknown-linux-musl.tar.gz
|
|
|
|
echo "CARGO=cross" >> $GITHUB_ENV
|
2023-10-21 20:06:52 -06:00
|
|
|
echo "RUSTFLAGS=--cfg sd_cross_compile" >> $GITHUB_ENV
|
2023-10-20 18:02:45 -06:00
|
|
|
echo "TARGET_DIR=./target/${{ matrix.target }}" >> $GITHUB_ENV
|
2021-03-19 16:12:55 +01:00
|
|
|
|
2021-02-28 23:46:49 -05:00
|
|
|
- name: Test
|
2023-10-21 20:06:52 -06:00
|
|
|
shell: bash
|
2023-10-20 18:02:45 -06:00
|
|
|
run: |
|
2023-10-21 20:06:52 -06:00
|
|
|
$CARGO --version
|
2023-10-23 19:36:58 -06:00
|
|
|
# For legal reasons, cross doesn't support Apple Silicon. See this:
|
|
|
|
# https://github.com/cross-rs/cross-toolchains#darwin-targets
|
|
|
|
# It builds and runs fine, but there's no easy way to test it in CI
|
|
|
|
if [ "${{ matrix.target }}" = "aarch64-apple-darwin" ]; then
|
|
|
|
$CARGO build --target ${{ matrix.target }}
|
|
|
|
else
|
|
|
|
$CARGO test --target ${{ matrix.target }}
|
|
|
|
fi
|