name: Build
on:
push:
branches: [main]
pull_request:
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
cancel-in-progress: true
env:
CARGO_TERM_COLOR: always
jobs:
changes:
name: Detect changes
runs-on: ubuntu-latest
permissions:
pull-requests: read
outputs:
code: ${{ github.event_name == 'push' || steps.filter.outputs.code == 'true' }}
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd - uses: dorny/paths-filter@fbd0ab8f3e69293af611ebaee6363fc25e6d187d id: filter
with:
filters: |
code:
- 'src/**'
- 'examples/**'
- 'Cargo.toml'
- 'Cargo.lock'
build:
name: Build (${{ matrix.target }})
needs: [changes]
if: needs.changes.outputs.code == 'true'
strategy:
fail-fast: false
matrix:
include:
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
- target: aarch64-apple-darwin
os: macos-latest
- target: x86_64-pc-windows-msvc
os: windows-latest
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd - uses: tylerbutler/actions/setup-rust@c4c45a8284082163bc58623acfc4b3dc98633c3d with:
targets: ${{ matrix.target }}
- name: Check library compiles
run: cargo check --target ${{ matrix.target }}
- name: Check all features
run: cargo check --all-features --target ${{ matrix.target }}
build-result:
name: Build Result
if: always()
needs: [build]
runs-on: ubuntu-latest
steps:
- name: Check build matrix result
run: |
if [[ "${{ needs.build.result }}" == "failure" || "${{ needs.build.result }}" == "cancelled" ]]; then
echo "Build matrix failed or was cancelled"
exit 1
fi