cargo-binstall/.github/workflows/ci.yml
Jiahao XU 35b32c43e0
Run release-build.yml unconditionally for consistency & inc cache hits (#982)
Since it is run on PR anyway, we should also run it on main just in case
it fails, i.e. merging of PRs without rebasing against main to test out
latest changes.

It will now also be run on draft PR so that they can test out the
changes and find out bugs before making it ready to review.

This change will also increase cache hits on PR, thus speeding up the CI.

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2023-04-06 18:08:14 +10:00

171 lines
4.3 KiB
YAML

name: CI
on:
workflow_dispatch:
pull_request:
types:
- opened
- reopened
- synchronize
- auto_merge_enabled
paths-ignore:
- README.md
- SUPPORT.md
push:
branches:
- main
paths-ignore:
- README.md
- SUPPORT.md
concurrency:
group: ${{ github.workflow }}-${{ github.ref || github.run_id }}
cancel-in-progress: true
env:
CARGO_TERM_COLOR: always
CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse
jobs:
test:
strategy:
fail-fast: false
matrix:
include:
- target: x86_64-apple-darwin
os: macos-latest
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
- target: x86_64-pc-windows-msvc
os: windows-latest
runs-on: ${{ matrix.os }}
env:
CARGO_BUILD_TARGET: ${{ matrix.target }}
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/just-setup
with:
cache-suffix: ${{ env.CARGO_BUILD_TARGET }}
env:
# just-setup use binstall to install sccache,
# which works better when we provide it with GITHUB_TOKEN.
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- run: just ci-install-deps
- run: just test
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
linux-cross-check:
strategy:
fail-fast: false
matrix:
target:
- armv7-unknown-linux-musleabihf
- armv7-unknown-linux-gnueabihf
- aarch64-unknown-linux-musl
- aarch64-unknown-linux-gnu
- x86_64-unknown-linux-musl
runs-on: ubuntu-latest
env:
CARGO_BUILD_TARGET: ${{ matrix.target }}
JUST_USE_CARGO_ZIGBUILD: true
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/just-setup
with:
cache-suffix: ${{ env.CARGO_BUILD_TARGET }}
env:
# just-setup use binstall to install sccache,
# which works better when we provide it with GITHUB_TOKEN.
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- run: just ci-install-deps
- run: just avoid-dev-deps
- run: just check
apple-m1-check:
runs-on: macos-latest
env:
CARGO_BUILD_TARGET: aarch64-apple-darwin
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/just-setup
with:
cache-suffix: ${{ env.CARGO_BUILD_TARGET }}
env:
# just-setup use binstall to install sccache,
# which works better when we provide it with GITHUB_TOKEN.
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- run: just avoid-dev-deps
- run: just check
windows-aarch64-check:
runs-on: windows-latest
env:
CARGO_BUILD_TARGET: aarch64-pc-windows-msvc
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/just-setup
with:
cache-suffix: ${{ env.CARGO_BUILD_TARGET }}
env:
# just-setup use binstall to install sccache,
# which works better when we provide it with GITHUB_TOKEN.
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- run: just avoid-dev-deps
- run: just check
lint:
strategy:
fail-fast: false
matrix:
include:
- target: x86_64-apple-darwin
os: macos-latest
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
- target: x86_64-pc-windows-msvc
os: windows-latest
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/just-setup
with:
cache-suffix: ${{ matrix.target }}
- run: just toolchain rustfmt,clippy
- run: just ci-install-deps
- run: just avoid-dev-deps
- run: just lint
# Dummy job to have a stable name for the "all tests pass" requirement
tests-pass:
name: Tests pass
needs:
- test
- linux-cross-check
- apple-m1-check
- lint
- windows-aarch64-check
if: always() # always run even if dependencies fail
runs-on: ubuntu-latest
steps:
# fail if ANY dependency has failed or been skipped or cancelled
- if: "contains(needs.*.result, 'failure') || contains(needs.*.result, 'skipped') || contains(needs.*.result, 'cancelled')"
run: exit 1
# Wait for 30s before release build to avoid overloading GitHub.
- run: sleep 30
release-builds:
needs: tests-pass
uses: ./.github/workflows/release-build.yml