Files
space-game/.github/workflows/ci.yaml
2025-07-05 16:49:11 -04:00

141 lines
4.8 KiB
YAML

name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
concurrency:
group: ${{ github.workflow }}-${{ github.ref || github.run_id }}
cancel-in-progress: true
env:
# Reduce compile time and cache size.
RUSTFLAGS: -Zshare-generics=y -Zthreads=0
RUSTDOCFLAGS: -Zshare-generics=y -Zthreads=0
# Use the same Rust toolchain across jobs so they can share a cache.
toolchain: nightly-2025-04-03
jobs:
# Run Clippy lints.
clippy-lints:
name: Clippy lints
runs-on: ubuntu-latest
env:
RUSTFLAGS: "-Dwarnings"
timeout-minutes: 20
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.toolchain }}
components: clippy
- name: Restore Rust cache
id: cache
uses: Swatinem/rust-cache@v2
with:
shared-key: ci
save-if: ${{ github.ref == 'refs/heads/main' }}
- name: Install build dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: sudo apt-get -y update; sudo apt-get -y install --no-install-recommends libasound2-dev libudev-dev libwayland-dev
- name: Run Clippy lints
run: cargo clippy --locked --workspace --all-targets --profile ci --all-features
# Run Bevy lints.
bevy-lints:
name: Bevy lints
runs-on: ubuntu-latest
env:
RUSTFLAGS: "-Dwarnings"
timeout-minutes: 20
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Rust toolchain (plus bevy_lint)
uses: TheBevyFlock/bevy_cli/bevy_lint@lint-v0.3.0
- name: Restore Rust cache
id: cache
uses: Swatinem/rust-cache@v2
with:
shared-key: ci
save-if: false
- name: Install build dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: sudo apt-get -y update; sudo apt-get -y install --no-install-recommends libasound2-dev libudev-dev libwayland-dev
- name: Run Bevy lints
run: bevy_lint --locked --workspace --all-targets --profile ci --all-features
# Run tests.
tests:
name: Tests
runs-on: ubuntu-latest
timeout-minutes: 40
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up environment
run: echo "RUSTFLAGS=${RUSTFLAGS:+$RUSTFLAGS }-Zcodegen-backend=cranelift" >> "${GITHUB_ENV}"
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.toolchain }}
components: rustc-codegen-cranelift-preview
- name: Restore Rust cache
uses: Swatinem/rust-cache@v2
with:
shared-key: test
cache-directories: ${{ env.LD_LIBRARY_PATH }}
save-if: ${{ github.ref == 'refs/heads/main' }}
- name: Install build dependencies
run: sudo apt-get -y update; sudo apt-get -y install --no-install-recommends libasound2-dev libudev-dev libwayland-dev
- name: Run tests
run: cargo test --locked --workspace --all-targets --profile ci --no-fail-fast
# Check that the web build compiles.
# check-web:
# name: Check web
# runs-on: ubuntu-latest
# env:
# RUSTFLAGS: -Zshare-generics=y -Zthreads=0 --cfg getrandom_backend="wasm_js"
# timeout-minutes: 20
# steps:
# - name: Checkout repository
# uses: actions/checkout@v4
# - name: Install Rust toolchain
# uses: dtolnay/rust-toolchain@master
# with:
# toolchain: ${{ env.toolchain }}
# targets: wasm32-unknown-unknown
# - name: Restore Rust cache
# id: cache
# uses: Swatinem/rust-cache@v2
# with:
# shared-key: web-ci
# save-if: ${{ github.ref == 'refs/heads/main' }}
# - name: Install build dependencies
# if: steps.cache.outputs.cache-hit != 'true'
# run: sudo apt-get -y update; sudo apt-get -y install --no-install-recommends libasound2-dev libudev-dev libwayland-dev
# - name: Check web
# run: cargo check --config 'profile.web.inherits="dev"' --profile ci --no-default-features --features "dev web" --target wasm32-unknown-unknown