name: CI
on:
push:
branches: [main, master]
pull_request:
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
cancel-in-progress: true
permissions:
contents: read
env:
CARGO_TERM_COLOR: always
CARGO_INCREMENTAL: "0"
CARGO_BUILD_JOBS: "1"
MSRV: "1.89"
NO_STD_TARGET: thumbv7em-none-eabihf
NO_STD_CARGO_ARGS: "--no-default-features --features row_width_240"
CLIPPY_ARGS: "--lib --all-features"
DOCS_ARGS: "--lib --no-deps --all-features"
CHECK_ARGS: "--lib --all-features"
CI_UNIT_TEST_ARGS: "--lib"
CI_INTEGRATION_TEST_ARGS: "--features lighting,textured -- --test-threads=1"
CI_INTEGRATION_CHECK: "true"
CI_INTEGRATION_CHECK_CMD: "cargo build --examples --all-features"
CI_EXTRA_TEST_COMMANDS: |
cargo test --lib --features "scene-extras,textured,lighting,raycast,hud,painters,physics"
TELEMETRY_MAX_RECORD_DRAW_COMMANDS: "3"
TELEMETRY_MAX_EXECUTE_COMMANDS_TOTAL: "4"
TELEMETRY_MAX_EXECUTE_DRAW_COMMANDS: "3"
TELEMETRY_STRESS_MAX_RECORD_DRAW_COMMANDS: "24"
TELEMETRY_STRESS_MAX_EXECUTE_COMMANDS_TOTAL: "25"
TELEMETRY_STRESS_MAX_EXECUTE_DRAW_COMMANDS: "24"
TELEMETRY_FAILSOFT_MAX_RECORD_DRAW_COMMANDS: "1"
TELEMETRY_FAILSOFT_MAX_EXECUTE_COMMANDS_TOTAL: "2"
TELEMETRY_FAILSOFT_MAX_EXECUTE_DRAW_COMMANDS: "1"
TELEMETRY_FAILSOFT_EXPECTED_BUDGET_KIND: "MeshesPerFrame"
jobs:
fmt:
name: Formatting
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt
- run: cargo fmt --all
- uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: "style: auto-format code with cargo fmt"
commit_user_name: "github-actions[bot]"
commit_user_email: "github-actions[bot]@users.noreply.github.com"
check:
name: Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- run: |
if [ -n "${{ env.CI_HOST_TARGET }}" ]; then
cargo check ${{ env.CHECK_ARGS }} --target ${{ env.CI_HOST_TARGET }}
else
cargo check ${{ env.CHECK_ARGS }}
fi
check-no-std:
name: Check (no_std - ${{ matrix.target }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
target:
- thumbv6m-none-eabi
- thumbv7em-none-eabihf
- riscv32imc-unknown-none-elf
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- uses: Swatinem/rust-cache@v2
- run: cargo check --lib ${{ env.NO_STD_CARGO_ARGS }} --target ${{ matrix.target }}
msrv:
name: MSRV check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.MSRV }}
- run: bash .github/scripts/ci_msrv.sh
clippy:
name: Clippy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
components: clippy
- uses: Swatinem/rust-cache@v2
- run: cargo clippy ${{ env.CLIPPY_ARGS }} -- -W clippy::all
- run: rustup target add ${{ env.NO_STD_TARGET }}
- run: cargo clippy --lib ${{ env.NO_STD_CARGO_ARGS }} --target ${{ env.NO_STD_TARGET }} -- -W clippy::all
no-alloc-frame-path:
name: No-Alloc Frame Path Guard
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: python3 .github/scripts/check_no_alloc_frame_path.py
test:
name: Test
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- name: Install SDL2
run: sudo apt-get update && sudo apt-get install -y libsdl2-dev
- name: Unit and integration tests
run: bash .github/scripts/ci_test.sh
- name: Telemetry budget guard
run: cargo test --test integration_tests test_ci_telemetry_snapshot_ -- --nocapture 2>&1 | .github/scripts/check_telemetry_budget.py
- name: Golden image diff guard
run: python3 .github/scripts/check_image_diff.py --golden-dir tests/golden_images --rendered-dir target/rendered_images
embedded-budget:
name: Embedded Budget (${{ matrix.row_width_feature }})
runs-on: ubuntu-latest
timeout-minutes: 20
strategy:
fail-fast: false
matrix:
row_width_feature:
- row_width_96
- row_width_160
- row_width_240
- row_width_320
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- name: Install SDL2
run: sudo apt-get update && sudo apt-get install -y libsdl2-dev
- name: no_std-style library check
run: cargo check --lib --no-default-features --features ${{ matrix.row_width_feature }}
- name: no_std-style clippy
run: cargo clippy --lib --no-default-features --features ${{ matrix.row_width_feature }} -- -W clippy::all
- name: Constrained telemetry budget guard
run: cargo test --test integration_tests test_ci_telemetry_snapshot_ --no-default-features --features ${{ matrix.row_width_feature }} -- --nocapture 2>&1 | .github/scripts/check_telemetry_budget.py
minimal-feature-guard:
name: Minimal Feature Guard
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
targets: thumbv7em-none-eabihf
- uses: Swatinem/rust-cache@v2
- name: Install binutils (arm-none-eabi-size)
run: sudo apt-get update && sudo apt-get install -y binutils-arm-none-eabi
- name: Minimal / lighting check recipes
run: |
cargo check --lib --no-default-features --features row_width_320,depth-u16
cargo check --lib --no-default-features --features row_width_320,depth-u16,lighting
cargo check --lib --features std,physics
- name: Flash size budget (size-harness)
run: ./.github/scripts/measure_feature_size.sh --check
feature-isolation:
name: Feature Isolation
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- name: Verify standalone features compile in isolation
run: |
cargo check --lib --no-default-features --features row_width_240,fixed-raster
cargo check --lib --no-default-features --features row_width_240,dma2d
cargo check --lib --no-default-features --features row_width_240,triple-buffering
cargo check --lib --no-default-features --features row_width_240,hud
cargo check --lib --no-default-features --features row_width_240,painters
cargo check --lib --no-default-features --features row_width_240,anim-blend
cargo check --lib --no-default-features --features row_width_240,gizmos
cargo check --lib --no-default-features --features row_width_240,aabb-cull
cargo check --lib --no-default-features --features row_width_240,depth-u16
cargo check --lib --no-default-features --features row_width_240,physics
profile-budget:
name: Profile Budget (${{ matrix.caps_profile }})
runs-on: ubuntu-latest
timeout-minutes: 20
strategy:
fail-fast: false
matrix:
caps_profile:
- m0
- m3
- m4
- m33
- m55
env:
EMBEDDED_3DGFX_CAPS: ${{ matrix.caps_profile }}
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- name: Install SDL2
run: sudo apt-get update && sudo apt-get install -y libsdl2-dev
- name: Profile telemetry budget guard
run: cargo test --test integration_tests test_ci_telemetry_snapshot_ -- --nocapture 2>&1 | .github/scripts/check_telemetry_budget.py
perf-baseline:
name: Perf Baseline (${{ matrix.caps_profile }})
runs-on: ubuntu-latest
timeout-minutes: 25
strategy:
fail-fast: false
matrix:
caps_profile:
- m0
- m3
- m4
- m33
- m55
env:
EMBEDDED_3DGFX_CAPS: ${{ matrix.caps_profile }}
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- name: Install SDL2
run: sudo apt-get update && sudo apt-get install -y libsdl2-dev
- name: Raster perf baseline (report-only)
run: cargo bench --bench raster_benchmark --features fixed-raster | tee -a "$GITHUB_STEP_SUMMARY"
m55-perf-budget:
name: M55 Perf Budget
runs-on: ubuntu-latest
timeout-minutes: 20
env:
EMBEDDED_3DGFX_CAPS: m55
TELEMETRY_MAX_RECORD_DRAW_COMMANDS: "4"
TELEMETRY_MAX_EXECUTE_COMMANDS_TOTAL: "5"
TELEMETRY_MAX_EXECUTE_DRAW_COMMANDS: "4"
TELEMETRY_STRESS_MAX_RECORD_DRAW_COMMANDS: "24"
TELEMETRY_STRESS_MAX_EXECUTE_COMMANDS_TOTAL: "25"
TELEMETRY_STRESS_MAX_EXECUTE_DRAW_COMMANDS: "24"
TELEMETRY_FAILSOFT_MAX_RECORD_DRAW_COMMANDS: "1"
TELEMETRY_FAILSOFT_MAX_EXECUTE_COMMANDS_TOTAL: "2"
TELEMETRY_FAILSOFT_MAX_EXECUTE_DRAW_COMMANDS: "1"
TELEMETRY_FAILSOFT_EXPECTED_BUDGET_KIND: "MeshesPerFrame"
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- name: Install SDL2
run: sudo apt-get update && sudo apt-get install -y libsdl2-dev
- name: M55 perf telemetry budget guard
run: cargo test --test integration_tests test_ci_telemetry_snapshot_ -- --nocapture 2>&1 | .github/scripts/check_telemetry_budget.py
docs:
name: Docs & GitHub Pages
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- run: bash .github/scripts/ci_docs.sh
- name: Deploy Docs to GitHub Pages
if: github.ref == 'refs/heads/master' && github.event_name == 'push'
uses: JamesIves/github-pages-deploy-action@v4
with:
folder: target/doc
branch: gh-pages
asset-budget:
name: Asset Budget Report
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: python3 .github/scripts/asset_budget_report.py
publish-dry-run:
name: Publish dry-run
runs-on: ubuntu-latest
continue-on-error: true
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- run: cargo publish --dry-run
audit:
name: Security & License Audit
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: EmbarkStudios/cargo-deny-action@v2
with:
command: check
arguments: --all-features
coverage:
name: Code Coverage
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
components: llvm-tools-preview
- uses: taiki-e/install-action@cargo-llvm-cov
- uses: Swatinem/rust-cache@v2
- name: Install SDL2
run: sudo apt-get update && sudo apt-get install -y libsdl2-dev
- name: Measure code coverage
run: |
echo "### 📊 Code Coverage Report" >> "$GITHUB_STEP_SUMMARY"
echo '```text' >> "$GITHUB_STEP_SUMMARY"
cargo llvm-cov --all-features --summary-only | tee -a "$GITHUB_STEP_SUMMARY"
echo '```' >> "$GITHUB_STEP_SUMMARY"
cargo llvm-cov --all-features --lcov --output-path lcov-all.info
cargo llvm-cov --no-default-features --features row_width_320,depth-u16,fixed-raster --lcov --output-path lcov-nostd.info
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v5
with:
files: lcov-all.info,lcov-nostd.info
fail_ci_if_error: false
token: ${{ secrets.CODECOV_TOKEN }}
slug: leftger/embedded-3dgfx
- name: Install nextest
if: ${{ !cancelled() }}
uses: taiki-e/install-action@nextest
- name: Run tests with JUnit report
if: ${{ !cancelled() }}
run: |
set +e
cargo nextest run -p embedded-3dgfx --all-features --profile ci
status=$?
cp target/nextest/ci/junit.xml junit.xml
exit $status
- name: Upload test results to Codecov
if: ${{ !cancelled() }}
uses: codecov/codecov-action@v5
with:
files: junit.xml
fail_ci_if_error: false
token: ${{ secrets.CODECOV_TOKEN }}
slug: leftger/embedded-3dgfx
report_type: test_results