name: build-test-release # Runs on every merge/push to main: build the GUI for Linux and Windows, run the # tests + a microbenchmark, and (when the change warrants it) cut an X.Y.Z # release with both binaries attached. on: push: branches: [main] concurrency: group: alkane-toolkit-main cancel-in-progress: false permissions: contents: write actions: write jobs: # Windows build of the same commit: cross-compiled with mingw-w64 against the # vendored wxMSW, unit-tested and UI-self-tested under Wine, packaged as a # zip. The release job below waits for it and attaches the zip next to the # Linux tarball, so a release never ships one platform without the other. windows: runs-on: alkane-ci container: image: gitea.bluefla.re/blueflare/alkane-ci@sha256:8f20439b38ae1c070b1a692a89c084f69134f4fa16a755d02783f621cd9ac041 env: CARGO_TARGET_DIR: target CARGO_BUILD_JOBS: 2 WX_WINDOWS_PREFIX: /root/.cache/wx-3.3.3-mingw steps: - name: Checkout (full history for tags) uses: actions/checkout@v4 with: fetch-depth: 0 - name: Compute version id: ver run: bash ci/compute-version.sh | tee -a "$GITHUB_OUTPUT" - name: Install Windows toolchain run: bash ci/windows-ci.sh toolchain - name: Configure bounded Rust compiler cache run: bash ci/configure-rust-cache.sh - name: Compute wxMSW cache key id: wx-key run: bash ci/wx-cache-key.sh windows - name: Check prebuilt wxMSW id: wx-image run: bash ci/check-wx-image-prefix.sh windows - name: Cache vendored wxMSW build if: steps.wx-image.outputs.available != 'true' id: wx-cache uses: actions/cache/restore@v4 continue-on-error: true with: path: /root/.cache/wx-3.3.3-mingw key: ${{ steps.wx-key.outputs.key }} - name: Build wxMSW (once, then cached) id: wx-build run: bash ci/ensure-wx-prefix.sh windows - name: Save vendored wxMSW build if: steps.wx-cache.outputs.cache-hit != 'true' && steps.wx-build.outputs.built == 'true' uses: actions/cache/save@v4 continue-on-error: true with: path: /root/.cache/wx-3.3.3-mingw key: ${{ steps.wx-key.outputs.key }} - name: Clippy (Windows target, warnings are errors) run: bash ci/windows-ci.sh clippy - name: Set crate version to ${{ steps.ver.outputs.version }} if: steps.ver.outputs.release == 'true' run: | sed -i "0,/^version = \".*\"/s//version = \"${{ steps.ver.outputs.version }}\"/" Cargo.toml grep -m1 '^version' Cargo.toml - name: Build release (Windows) run: bash ci/windows-ci.sh build - name: Unit tests (Windows build, under Wine) run: bash ci/windows-ci.sh test - name: Headless UI self-test (Windows build, under Wine) run: bash ci/windows-ci.sh selftest - name: Package Windows artifact if: steps.ver.outputs.release == 'true' run: bash ci/windows-ci.sh package "${{ steps.ver.outputs.version }}" - name: Bundle Windows test executables run: bash ci/windows-ci.sh test-bundle - uses: https://github.com/ChristopherHX/gitea-upload-artifact@81f940d004763f986ba3582c007fd842dd5cb0d7 if: steps.ver.outputs.release == 'true' with: name: alkane-toolkit-windows path: dist/alkane-toolkit-v*-windows-x86_64.zip # Consumed by .gitea/workflows/windows-native.yml on the Windows VM runner. - uses: https://github.com/ChristopherHX/gitea-upload-artifact@81f940d004763f986ba3582c007fd842dd5cb0d7 with: name: alkane-toolkit-windows-tests path: | dist/alkane-toolkit-windows-tests.zip target/x86_64-pc-windows-gnu/release/alkane-toolkit.exe - name: Clean generated Toolkit build if: always() run: python3 ci/cleanup-generated.py release: needs: windows runs-on: alkane-ci container: image: gitea.bluefla.re/blueflare/alkane-ci@sha256:8f20439b38ae1c070b1a692a89c084f69134f4fa16a755d02783f621cd9ac041 env: CARGO_TARGET_DIR: target CARGO_BUILD_JOBS: 2 WX_PREFIX: /root/.cache/wx-3.3.3-linux # Set once for the whole job so build/clippy/test/bench steps don't each # re-export it (round 18 #12). WX_RS_WXCONFIG: /root/.cache/wx-3.3.3-linux/bin/wx-config steps: - name: Checkout (full history for tags) uses: actions/checkout@v4 with: fetch-depth: 0 - name: Check runner image pins run: python3 ci/check-runner-image.py - name: Check wx-rs patch queue reproduces the patched tree run: python3 scripts/wx_rs_patches.py check - name: Check first-party Rust formatting run: | rustup component add rustfmt >/dev/null cargo fmt -p alkane-gui -p alkane-artifacts -p alkane-flash -p alkane-cli -p alkane-access -p alkane-core -- --check - name: Compute version id: ver run: bash ci/compute-version.sh | tee -a "$GITHUB_OUTPUT" - name: Test version logic run: bash ci/test-compute-version.sh - name: Last-attempt badge checks run: python3 ci/test-last-attempt-badge.py - name: Benchmark history checks run: python3 ci/test-bench-history.py - name: Benchmark suite checks run: python3 ci/test-bench-badge.py - name: Install build dependencies run: bash ci/ensure-build-deps.sh all - name: Configure bounded Rust compiler cache run: bash ci/configure-rust-cache.sh - name: Compute wxWidgets cache key id: wx-key run: bash ci/wx-cache-key.sh - name: Check prebuilt wxWidgets id: wx-image run: bash ci/check-wx-image-prefix.sh - name: Cache vendored wxWidgets build if: steps.wx-image.outputs.available != 'true' id: wx-cache uses: actions/cache/restore@v4 continue-on-error: true with: path: /root/.cache/wx-3.3.3-linux key: ${{ steps.wx-key.outputs.key }} - name: Build wxWidgets (once, then cached) id: wx-build run: bash ci/ensure-wx-prefix.sh - name: Save vendored wxWidgets build if: steps.wx-cache.outputs.cache-hit != 'true' && steps.wx-build.outputs.built == 'true' uses: actions/cache/save@v4 continue-on-error: true with: path: /root/.cache/wx-3.3.3-linux key: ${{ steps.wx-key.outputs.key }} - name: Clippy (our crate, warnings are errors) run: | rustup component add clippy >/dev/null 2>&1 || true cargo clippy -p alkane-gui --no-deps --release --bins --offline -- -D warnings cargo clippy --workspace --exclude alkane-gui --exclude wx-rs --all-targets --offline -- -D warnings - name: Set crate version to ${{ steps.ver.outputs.version }} if: steps.ver.outputs.release == 'true' run: | sed -i "0,/^version = \".*\"/s//version = \"${{ steps.ver.outputs.version }}\"/" Cargo.toml grep -m1 '^version' Cargo.toml - name: Build release run: | cargo build --release -p alkane-gui --offline - name: Unit tests run: | set -o pipefail cargo test -p alkane-gui --offline 2>&1 | tee tests-gui.txt cargo test --workspace --exclude alkane-gui --exclude wx-rs --offline 2>&1 | tee tests-core.txt cat tests-gui.txt tests-core.txt > tests-current.txt - name: Load previous main benchmark measurement env: GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }} run: python3 ci/bench_history.py prepare - name: Microbenchmarks run: | # Require every declared benchmark before publishing history or a release. set -o pipefail cargo test -p alkane-gui -p alkane-artifacts --release --offline -- --ignored --nocapture bench_ --test-threads=1 \ | tee bench-current.txt python3 ci/bench-badge.py --current bench-current.txt \ --baseline badges/bench-baseline.json --no-write - name: Headless UI self-test run: | BIN=target/release/alkane-toolkit xvfb-run -a env GDK_BACKEND=x11 ALKANE_SELFTEST=1 "$BIN" - name: Dependency audit (best-effort) continue-on-error: true run: | if command -v cargo-audit >/dev/null 2>&1; then cargo audit || echo "cargo audit reported findings (accepted ones in .cargo/audit.toml)" else echo "cargo-audit not installed on this runner; skipping" fi - name: Rust compiler cache statistics if: always() run: | if [ -n "${SCCACHE_DIR:-}" ]; then sccache --show-stats fi # Merge coverage from unit tests and the headless UI self-test. A failed # measurement must not publish a stale badge or create a release. - name: Coverage id: cov run: | set -euo pipefail rustup component add llvm-tools-preview >/dev/null 2>&1 || true [ "$(cargo llvm-cov --version)" = 'cargo-llvm-cov 0.8.7' ] PCT=$(bash ci/coverage.sh --summary-only \ | awk '/^TOTAL/{gsub(/%/,"",$10); print $10}') [ -n "$PCT" ] || { echo "coverage report produced no TOTAL line" >&2; exit 1; } echo "pct=${PCT}" >> "$GITHUB_OUTPUT" echo "line coverage (tests + self-test): ${PCT}%" - name: Microbenchmark coverage id: benchcov run: | set -euo pipefail command -v cargo-llvm-cov >/dev/null PCT=$(bash ci/bench-coverage.sh --summary-only \ | awk '/^TOTAL/{gsub(/%/,"",$10); print $10}') [ -n "$PCT" ] || { echo "microbenchmark coverage unavailable" >&2; exit 1; } echo "pct=${PCT}" >> "$GITHUB_OUTPUT" echo "microbenchmark line coverage: ${PCT}%" - name: Generate measured badges run: | set -euo pipefail PASS=$(grep -E '^test result: ' tests-current.txt \ | grep -oE '[0-9]+ passed' | grep -oE '[0-9]+' \ | awk '{s+=$1} END{print s+0}') [ "$PASS" -gt 0 ] || { echo "no passing tests counted" >&2; exit 1; } BENCH_DELTA=$(python3 ci/bench-badge.py --current bench-current.txt \ --baseline badges/bench-baseline.json --no-write) python3 ci/gen-badges.py --tests "$PASS" \ --coverage "${{ steps.cov.outputs.pct }}" \ --bench-coverage "${{ steps.benchcov.outputs.pct }}" \ --bench-delta "$BENCH_DELTA" --clippy clean - name: Publish measured badges env: GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }} run: python3 ci/publish-metrics.py - name: Record private benchmark history env: GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }} run: python3 ci/bench_history.py publish - uses: https://github.com/ChristopherHX/gitea-upload-artifact@81f940d004763f986ba3582c007fd842dd5cb0d7 with: name: alkane-toolkit-benchmark-site-preview path: bench-site/index.html - name: Package artifact if: steps.ver.outputs.release == 'true' id: pkg run: | V="${{ steps.ver.outputs.version }}" NAME="alkane-toolkit-v${V}-linux-x86_64" mkdir -p "dist/$NAME" cp target/release/alkane-toolkit "dist/$NAME/" cat > "dist/$NAME/README.txt" <> "$GITHUB_OUTPUT" echo "assetname=${NAME}.tar.gz" >> "$GITHUB_OUTPUT" - name: Fetch Windows artifact if: steps.ver.outputs.release == 'true' uses: https://github.com/ChristopherHX/gitea-download-artifact@75635f32b4c1c41c4b3d64e8f85210112ed4c9c7 with: name: alkane-toolkit-windows path: dist/windows - name: Locate Windows artifact if: steps.ver.outputs.release == 'true' id: winpkg run: | set -euo pipefail V="${{ steps.ver.outputs.version }}" ZIP="dist/windows/alkane-toolkit-v${V}-windows-x86_64.zip" [ -s "$ZIP" ] || { echo "Windows artifact for v${V} is missing" >&2; ls -lR dist/windows >&2; exit 1; } echo "asset=$ZIP" >> "$GITHUB_OUTPUT" - name: Create Gitea release + upload artifact if: steps.ver.outputs.release == 'true' env: GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }} run: | python3 ci/release-rc.py "${{ steps.ver.outputs.tag }}" false \ "${{ steps.pkg.outputs.asset }}" "${{ steps.winpkg.outputs.asset }}" - name: No release needed if: steps.ver.outputs.release != 'true' run: echo "No backend/UI change since ${{ steps.ver.outputs.last_tag }} - skipping release." - name: Clean generated Toolkit build if: always() run: python3 ci/cleanup-generated.py