279 lines
9.6 KiB
YAML
279 lines
9.6 KiB
YAML
name: CI
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
paths:
|
|
- "Cargo.lock"
|
|
- "**.rs"
|
|
- "**.sh"
|
|
- "**.ps1"
|
|
- "**.yml"
|
|
- "**.toml"
|
|
- "!**.md"
|
|
- "!LICENSE-APACHE"
|
|
- "!LICENSE-MIT"
|
|
pull_request:
|
|
types: [opened, synchronize]
|
|
paths:
|
|
- "Cargo.lock"
|
|
- "**.rs"
|
|
- "**.sh"
|
|
- "**.ps1"
|
|
- "**.yml"
|
|
- "**.toml"
|
|
- "!**.md"
|
|
- "!LICENSE-APACHE"
|
|
- "!LICENSE-MIT"
|
|
|
|
env:
|
|
# Note: It is not possible to define top level env vars and pass them to composite actions.
|
|
# To work around this issue we use inputs and define all the env vars here.
|
|
|
|
RUST_PREVIOUS_VERSION: 1.95.0
|
|
|
|
# Dependency versioning
|
|
# from wgpu repo: https://github.com/gfx-rs/wgpu/blob/trunk/.github/workflows/ci.yml
|
|
|
|
# Mozilla Grcov
|
|
GRCOV_LINK: "https://github.com/mozilla/grcov/releases/download"
|
|
GRCOV_VERSION: "0.8.19"
|
|
|
|
# Test in release mode (make it an empty string to test in debug mode)
|
|
TEST_RELEASE_FLAG: "--release"
|
|
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
prepare-checks:
|
|
runs-on: ubuntu-latest
|
|
outputs:
|
|
rust-prev-version: ${{ env.RUST_PREVIOUS_VERSION }}
|
|
steps:
|
|
- name: Do Nothing
|
|
if: false
|
|
run: echo
|
|
|
|
code-quality:
|
|
runs-on: ubuntu-22.04
|
|
needs: prepare-checks
|
|
strategy:
|
|
matrix:
|
|
rust: [stable]
|
|
include:
|
|
- rust: stable
|
|
toolchain: stable
|
|
steps:
|
|
- name: checkout
|
|
uses: actions/checkout@v7
|
|
# --------------------------------------------------------------------------------
|
|
- name: Setup Rust
|
|
uses: tracel-ai/github-actions/install-rust@v9
|
|
with:
|
|
rust-toolchain: ${{ matrix.toolchain }}
|
|
cache-key: ${{ matrix.rust }}-linux
|
|
# --------------------------------------------------------------------------------
|
|
- name: Audit
|
|
run: cargo xtask check audit
|
|
# --------------------------------------------------------------------------------
|
|
- name: Format
|
|
shell: bash
|
|
env:
|
|
# work around for colors
|
|
# see: https://github.com/rust-lang/rustfmt/issues/3385
|
|
TERM: xterm-256color
|
|
run: cargo xtask check format
|
|
# --------------------------------------------------------------------------------
|
|
- name: Lint
|
|
run: cargo xtask check lint
|
|
# --------------------------------------------------------------------------------
|
|
- name: Typos
|
|
uses: tracel-ai/github-actions/check-typos@v9
|
|
|
|
documentation:
|
|
runs-on: ubuntu-22.04
|
|
needs: prepare-checks
|
|
strategy:
|
|
matrix:
|
|
rust: [stable]
|
|
include:
|
|
- rust: stable
|
|
toolchain: stable
|
|
steps:
|
|
- name: checkout
|
|
uses: actions/checkout@v7
|
|
# --------------------------------------------------------------------------------
|
|
- name: Setup Rust
|
|
uses: tracel-ai/github-actions/install-rust@v9
|
|
with:
|
|
rust-toolchain: ${{ matrix.toolchain }}
|
|
cache-key: ${{ matrix.rust }}-linux
|
|
# --------------------------------------------------------------------------------
|
|
- name: Documentation Build
|
|
run: cargo xtask doc build
|
|
# --------------------------------------------------------------------------------
|
|
- name: Documentation Tests
|
|
run: cargo xtask doc tests
|
|
|
|
linux-std-tests:
|
|
runs-on: ubuntu-22.04
|
|
needs: [prepare-checks, code-quality]
|
|
env:
|
|
DISABLE_WGPU_SPIRV: "1"
|
|
# disable incremental compilation (reduces artifact size)
|
|
CARGO_PROFILE_TEST_INCREMENTAL: "false"
|
|
CARGO_TERM_COLOR: always
|
|
strategy:
|
|
matrix:
|
|
rust: [stable, prev]
|
|
# Tests are split across 3 shards: backend tests, workspace crates, examples/*
|
|
ci_type: [backends, crates, examples]
|
|
include:
|
|
- rust: stable
|
|
toolchain: stable
|
|
coverage: --enable-coverage
|
|
- rust: prev
|
|
toolchain: ${{ needs.prepare-checks.outputs.rust-prev-version }}
|
|
steps:
|
|
- name: checkout
|
|
uses: actions/checkout@v7
|
|
# --------------------------------------------------------------------------------
|
|
- name: Setup Rust
|
|
uses: tracel-ai/github-actions/install-rust@v9
|
|
with:
|
|
rust-toolchain: ${{ matrix.toolchain }}
|
|
# Keep caches isolated per shard to prevent race conditions or bloated sizes
|
|
cache-key: ${{ matrix.rust }}-${{ matrix.ci_type }}-linux
|
|
# Disable cache on linux-std (stable) runner which currently always runs out of disk space with tests + coverage
|
|
enable-cache: ${{ matrix.rust != 'stable' }}
|
|
# # --------------------------------------------------------------------------------
|
|
- name: Install grcov
|
|
if: matrix.rust == 'stable'
|
|
shell: bash
|
|
run: |
|
|
curl -L "$GRCOV_LINK/v$GRCOV_VERSION/grcov-x86_64-unknown-linux-musl.tar.bz2" |
|
|
tar xj -C $HOME/.cargo/bin
|
|
cargo xtask coverage install
|
|
# --------------------------------------------------------------------------------
|
|
- name: Tests
|
|
run: cargo xtask ${{ matrix.coverage }} test ${{ env.TEST_RELEASE_FLAG }} --ci ${{ matrix.ci_type }}
|
|
# --------------------------------------------------------------------------------
|
|
- name: Generate lcov.info
|
|
if: matrix.rust == 'stable' && matrix.ci_type != 'examples'
|
|
# /* is to exclude std library code coverage from analysis
|
|
run: cargo xtask coverage generate --ignore "/*,xtask/*,examples/*" --profile release
|
|
# --------------------------------------------------------------------------------
|
|
- name: Upload Codecov Shard Artifact
|
|
if: matrix.rust == 'stable' && matrix.ci_type != 'examples'
|
|
uses: actions/upload-artifact@v7
|
|
with:
|
|
# Names must be unique so they don't overwrite each other in the storage backend
|
|
name: coverage-linux-${{ matrix.ci_type }}
|
|
path: lcov.info
|
|
|
|
# --- Dedicated coverage upload job ---
|
|
upload-coverage:
|
|
runs-on: ubuntu-latest
|
|
needs: linux-std-tests
|
|
steps:
|
|
- name: checkout
|
|
uses: actions/checkout@v7
|
|
|
|
- name: Download All Coverage Artifacts
|
|
uses: actions/download-artifact@v8
|
|
with:
|
|
# Finds all artifacts prefixed with coverage-linux-*
|
|
pattern: coverage-linux-*
|
|
path: coverage-reports
|
|
|
|
- name: Codecov upload
|
|
uses: codecov/codecov-action@v7
|
|
with:
|
|
# Codecov automatically discovers and merges multiple lcov files inside this directory
|
|
directory: coverage-reports
|
|
token: ${{ secrets.CODECOV_TOKEN }}
|
|
|
|
linux-no-std-tests:
|
|
runs-on: ubuntu-22.04
|
|
needs: [prepare-checks, code-quality]
|
|
strategy:
|
|
matrix:
|
|
rust: [stable, prev]
|
|
include:
|
|
- rust: stable
|
|
toolchain: stable
|
|
- rust: prev
|
|
toolchain: ${{ needs.prepare-checks.outputs.rust-prev-version }}
|
|
steps:
|
|
- name: checkout
|
|
uses: actions/checkout@v7
|
|
# --------------------------------------------------------------------------------
|
|
- name: Setup Rust
|
|
uses: tracel-ai/github-actions/install-rust@v9
|
|
with:
|
|
rust-toolchain: ${{ matrix.toolchain }}
|
|
cache-key: ${{ matrix.rust }}-linux-no-std
|
|
# --------------------------------------------------------------------------------
|
|
- name: Crates Build
|
|
run: cargo xtask --context no-std build --ci
|
|
# --------------------------------------------------------------------------------
|
|
- name: Crates Tests
|
|
run: cargo xtask --context no-std test ${{ env.TEST_RELEASE_FLAG }} --ci github-runner
|
|
|
|
windows-std-tests:
|
|
runs-on: windows-2022
|
|
needs: [prepare-checks, code-quality]
|
|
env:
|
|
CARGO_PROFILE_TEST_INCREMENTAL: "false"
|
|
CARGO_TERM_COLOR: always
|
|
strategy:
|
|
matrix:
|
|
rust: [stable]
|
|
# Tests are split across 3 shards: backend tests, workspace crates, examples/*
|
|
ci_type: [backends, crates, examples]
|
|
include:
|
|
- rust: stable
|
|
toolchain: stable
|
|
steps:
|
|
- name: checkout
|
|
uses: actions/checkout@v7
|
|
# --------------------------------------------------------------------------------
|
|
- name: Setup Rust
|
|
uses: tracel-ai/github-actions/install-rust@v9
|
|
with:
|
|
rust-toolchain: ${{ matrix.toolchain }}
|
|
cache-key: ${{ matrix.rust }}-${{ matrix.ci_type }}-windows
|
|
# --------------------------------------------------------------------------------
|
|
- name: Tests
|
|
run: cargo xtask test ${{ env.TEST_RELEASE_FLAG }} --ci ${{ matrix.ci_type }}
|
|
|
|
macos-std-tests:
|
|
runs-on: blaze/macos-15
|
|
needs: [prepare-checks, code-quality]
|
|
timeout-minutes: 60
|
|
# Keep the stragegy to be able to easily add new rust versions if required
|
|
strategy:
|
|
matrix:
|
|
rust: [stable]
|
|
include:
|
|
- rust: stable
|
|
toolchain: stable
|
|
steps:
|
|
- name: checkout
|
|
uses: actions/checkout@v7
|
|
# --------------------------------------------------------------------------------
|
|
- name: Setup Rust
|
|
uses: tracel-ai/github-actions/install-rust@v9
|
|
with:
|
|
rust-toolchain: ${{ matrix.toolchain }}
|
|
cache-key: ${{ matrix.rust }}-macos
|
|
# --------------------------------------------------------------------------------
|
|
- name: Device check
|
|
run: system_profiler SPHardwareDataType
|
|
# --------------------------------------------------------------------------------
|
|
- name: Tests
|
|
run: cargo xtask test ${{ env.TEST_RELEASE_FLAG }} --ci github-mac-runner
|