name: build-test-release # Runs on every merge/push to main: build the GUI, run tests + a microbenchmark, # and (when the change warrants it) cut an X.Y.Z release with the binary attached. on: push: branches: [main] concurrency: group: alkane-toolkit-main cancel-in-progress: false permissions: contents: write actions: write jobs: release: runs-on: alkane-ci container: image: gitea.bluefla.re/blueflare/alkane-ci@sha256:9d2a992bbcb91014af3c85d2e1ec8c5990701cecf83fd06c8d46f9ef13dbd948 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: 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: 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 }}" - 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