sd/.github/workflows/test.yml

93 lines
2.5 KiB
YAML
Raw Normal View History

2020-07-03 11:38:52 -04:00
name: Test
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
- os: macos-latest
target: aarch64-apple-darwin
use-cross: false
- os: ubuntu-latest
target: aarch64-unknown-linux-musl
use-cross: true
- 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
uses: actions/checkout@v4
2020-07-03 11:40:54 -04:00
with:
fetch-depth: 1
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
2020-07-03 11:40:54 -04:00
with:
targets: ${{ matrix.target }}
2020-07-03 11:38:52 -04:00
- name: Setup native compilation
if: ${{ matrix.use-cross == false }}
shell: bash
run: |
echo "CARGO=cargo" >> $GITHUB_ENV
- name: Install Cross
if: ${{ matrix.use-cross == true }}
shell: bash
run: |
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
echo "RUSTFLAGS=--cfg sd_cross_compile" >> $GITHUB_ENV
echo "TARGET_DIR=./target/${{ matrix.target }}" >> $GITHUB_ENV
2021-02-28 23:46:49 -05:00
- name: Test
shell: bash
run: |
$CARGO --version
# 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