name: CI on: push: branches: [main] pull_request: # The merge queue runs CI on the merged result; without this its required check never reports. merge_group: workflow_dispatch: permissions: contents: read concurrency: # Pull requests share a group per branch, so a new push cancels the older run. Every other run (a push # to main, a merge-queue run) gets a group of its own: GitHub keeps only one pending run per group, so a # shared group would let a newer push displace one still waiting for a runner. group: ci-${{ github.event_name == 'pull_request' && github.ref || github.run_id }} # Only cancel runs for pull requests. A push to main (or a merge-queue run) must run to the end: # the nightly gate reads the last CI result for main's head, and a run cancelled by a newer push # reads as failure and blocks the release, even though no test failed (2026-11-28: the #598 # merge's macOS job waited 10.5h for a runner, then was cancelled by the #601 merge). cancel-in-progress: ${{ github.event_name == 'pull_request' }} env: CARGO_TERM_COLOR: always CARGO_INCREMENTAL: "0" CARGO_BUILD_JOBS: "2" CARGO_PROFILE_DEV_DEBUG: "1" CARGO_PROFILE_TEST_DEBUG: "1" RUST_BACKTRACE: "1" jobs: # Decides whether the Rust jobs need to run at all. A pull request that only touches prose # (Markdown at the top level, `docs/` apart from the files tests read, `SKILLS/`, `work/`) # cannot change a build or a test result, so it skips the build, test, clippy and coverage # jobs; fmt and the static checks (links, text style, PII) still run on it. Pushes to main # and manual runs always run everything. changes: name: changes runs-on: ubuntu-24.04 timeout-minutes: 5 permissions: contents: read pull-requests: read outputs: code: ${{ steps.filter.outputs.code }} steps: - id: filter env: GH_TOKEN: ${{ github.token }} EVENT: ${{ github.event_name }} PR: ${{ github.event.pull_request.number }} REPO: ${{ github.repository }} run: | set -euo pipefail if [[ "$EVENT" != "pull_request" ]]; then echo "code=true" >> "$GITHUB_OUTPUT" exit 0 fi # Both sides of a rename count: moving code into docs/ is a code change. files=$(gh api --paginate "repos/$REPO/pulls/$PR/files" --jq '.[] | .filename, (.previous_filename // empty)') count=$(printf '%s\n' "$files" | grep -c . || true) code=false # The files API stops at 3000 entries; a list that long or an empty one is not trusted. if [[ "$count" -eq 0 || "$count" -ge 3000 ]]; then code=true; fi while IFS= read -r f; do [[ -z "$f" ]] && continue case "$f" in # Read by tests: the demo notebooks, the generated command list, the coverage baseline. docs/demo/* | docs/commands.md | docs/coverage.json) code=true ;; docs/* | SKILLS/* | work/*) ;; */*) code=true ;; *.md) ;; *) code=true ;; esac done <<< "$files" echo "$count changed paths; Rust jobs needed: $code" echo "code=$code" >> "$GITHUB_OUTPUT" fmt: name: fmt runs-on: ubuntu-24.04 timeout-minutes: 20 steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - name: Install Rust run: rustup install - run: cargo fmt --all -- --check clippy: name: clippy needs: changes if: needs.changes.outputs.code == 'true' runs-on: ubuntu-24.04 timeout-minutes: 60 steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - name: Install Linux build dependencies run: bash .github/scripts/linux-deps.sh build - name: Install Rust run: rustup install - uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 # v2.9.2 with: save-if: ${{ github.ref == 'refs/heads/main' }} - run: cargo clippy --workspace --all-targets --locked -- -D warnings platform-build-test: name: build/test (${{ matrix.platform }}) needs: changes if: needs.changes.outputs.code == 'true' strategy: fail-fast: false matrix: include: # Linux stays at two compile jobs: more ran the runner out of disk and memory # (see the infrastructure retry below). The macOS (3 cores) and Windows (4 cores) # runners have no such trouble, and two jobs left a core idle for every build. - platform: linux runner: ubuntu-24.04 build-jobs: "2" - platform: windows runner: windows-2025 build-jobs: "4" - platform: macos runner: macos-26 retry-runner: macos-15 build-jobs: "3" # Try the other Apple Silicon image when the job is rerun. runs-on: ${{ github.run_attempt > 1 && matrix.retry-runner || matrix.runner }} timeout-minutes: 90 env: CARGO_BUILD_JOBS: ${{ matrix.build-jobs }} steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - name: Restore main-branch build/test timing history uses: actions/cache/restore@caa296126883cff596d87d8935842f9db880ef25 # v5 with: path: target/devx/timings.jsonl key: devx-timing-v1-${{ matrix.platform }}-${{ hashFiles('rust-toolchain.toml') }}-${{ github.run_id }} restore-keys: | devx-timing-v1-${{ matrix.platform }}-${{ hashFiles('rust-toolchain.toml') }}- - name: Install Linux build dependencies if: matrix.platform == 'linux' run: bash .github/scripts/linux-deps.sh test - name: Install Rust run: rustup install - uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 # v2.9.2 with: save-if: ${{ github.ref == 'refs/heads/main' }} cache-on-failure: true - name: Show disk space if: matrix.platform == 'linux' run: | echo "CPUs: $(nproc)" free -h df -h / - name: Build workspace # Keep the running xtask timing wrapper out of its own build on Windows. Build xtask # in the next step so the workflow still builds the complete workspace. run: cargo xtask devx-time build -- cargo build --workspace --exclude xtask --locked --timings - name: Build xtask run: cargo build -p xtask --locked - name: Run workspace tests with infrastructure-only retry (Linux) if: matrix.platform == 'linux' shell: bash run: | cargo xtask devx-time tests -- bash -c ' set -o pipefail set +e cargo test --workspace --locked --timings 2>&1 | tee cargo-test.log status=${PIPESTATUS[0]} set -e if [[ "$status" -eq 0 ]]; then exit 0; fi if grep -Eq "No space left on device|IO failure on output stream|Bus error|signal 7" cargo-test.log; then echo "Retrying after an infrastructure/resource failure" cargo test --workspace --locked --timings exit $? fi exit "$status" ' - name: Run workspace tests if: matrix.platform != 'linux' run: cargo xtask devx-time tests -- cargo test --workspace --locked --timings - name: Upload Cargo compilation timings if: always() uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 with: name: cargo-timings-${{ matrix.platform }}-${{ github.run_attempt }} path: target/cargo-timings/cargo-timing-*.html if-no-files-found: ignore retention-days: 14 - name: Save main-branch build/test timing history if: github.ref == 'refs/heads/main' && success() uses: actions/cache/save@caa296126883cff596d87d8935842f9db880ef25 # v5 with: path: target/devx/timings.jsonl key: devx-timing-v1-${{ matrix.platform }}-${{ hashFiles('rust-toolchain.toml') }}-${{ github.run_id }} voice: # The optional dictation feature is off in default builds, so the workspace jobs above never # compile it. Build, lint and test it here, with the ALSA headers the microphone needs. name: voice (${{ matrix.platform }}) needs: changes if: needs.changes.outputs.code == 'true' strategy: fail-fast: false matrix: include: - platform: linux runner: ubuntu-24.04 - platform: windows runner: windows-2025 - platform: macos runner: macos-26 retry-runner: macos-15 runs-on: ${{ github.run_attempt > 1 && matrix.retry-runner || matrix.runner }} timeout-minutes: 60 steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - name: Install Linux build dependencies if: matrix.platform == 'linux' run: bash .github/scripts/linux-deps.sh voice - name: Install Rust run: rustup install - uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 # v2.9.2 with: key: voice save-if: ${{ github.ref == 'refs/heads/main' }} - name: Check macOS microphone metadata if: matrix.platform == 'macos' run: plutil -lint packaging/OSX/Info.plist.in packaging/OSX/entitlements.plist - run: cargo clippy -p craft-voice-core -p craft-voice-runtime -p notecraft-ui-egui -p notecraft --all-targets --locked --features craft-voice-runtime/microphone,notecraft/voice -- -D warnings - run: cargo test -p craft-voice-core -p craft-voice-runtime --locked --features craft-voice-runtime/microphone - run: cargo test -p notecraft-ui-egui --locked --features voice --lib app::voice static: name: static checks runs-on: ubuntu-24.04 timeout-minutes: 30 steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - name: Install Rust run: rustup install - name: Branch check run: cargo xtask check-branch - name: PII scanner run: bash SKILLS/nc-devx/scripts/check-pii.sh - name: Layers run: cargo xtask layers - name: Assets run: cargo xtask assets - name: Docs run: cargo xtask docs - name: Text run: cargo xtask text - name: Demo check run: cargo xtask demo-check coverage: name: coverage (${{ matrix.platform }}) needs: changes if: needs.changes.outputs.code == 'true' strategy: fail-fast: false matrix: include: - platform: linux runner: ubuntu-24.04 binary: cargo-llvm-cov - platform: windows runner: windows-2025 binary: cargo-llvm-cov.exe - platform: macos runner: macos-26 retry-runner: macos-15 binary: cargo-llvm-cov runs-on: ${{ github.run_attempt > 1 && matrix.retry-runner || matrix.runner }} timeout-minutes: 90 env: NC_LLVM_COV_VERSION: "0.9.1" defaults: run: shell: bash steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - name: Install Linux build dependencies if: matrix.platform == 'linux' run: bash .github/scripts/linux-deps.sh test - name: Install Rust and LLVM tools run: | rustup install rustup component add llvm-tools - uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 # v2.9.2 with: key: coverage-v2 save-if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} - name: Restore pinned coverage tool id: coverage-tool-cache uses: actions/cache/restore@caa296126883cff596d87d8935842f9db880ef25 # v5 with: path: ~/.cargo/bin/${{ matrix.binary }} key: cargo-llvm-cov-${{ github.run_attempt > 1 && matrix.retry-runner || matrix.runner }}-${{ runner.arch }}-${{ env.NC_LLVM_COV_VERSION }}-${{ hashFiles('rust-toolchain.toml') }} - name: Ensure pinned coverage tool run: | if [[ "$(cargo llvm-cov --version 2>/dev/null || true)" != "cargo-llvm-cov $NC_LLVM_COV_VERSION" ]]; then cargo install cargo-llvm-cov --locked --version "$NC_LLVM_COV_VERSION" --force fi [[ "$(cargo llvm-cov --version)" == "cargo-llvm-cov $NC_LLVM_COV_VERSION" ]] - name: Save pinned coverage tool on main if: github.event_name == 'push' && github.ref == 'refs/heads/main' && steps.coverage-tool-cache.outputs.cache-hit != 'true' uses: actions/cache/save@caa296126883cff596d87d8935842f9db880ef25 # v5 with: path: ~/.cargo/bin/${{ matrix.binary }} key: ${{ steps.coverage-tool-cache.outputs.cache-primary-key }} - name: Measure coverage run: cargo xtask devx-time coverage -- cargo xtask coverage - uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 with: name: coverage-${{ matrix.platform }} path: target/coverage-summary.json if-no-files-found: error overwrite: true retention-days: 14 - name: Check 80% line coverage floor run: cargo xtask coverage --check-floor - name: Point to coverage evidence if: failure() run: echo "::warning title=Coverage floor check failed::See the job steps for the measured percentage or the reason it is unavailable." coverage-floor: name: Coverage floor needs: [changes, coverage] if: always() runs-on: ubuntu-24.04 timeout-minutes: 5 steps: - name: Require coverage evidence for code changes env: CLASSIFICATION: ${{ needs.changes.result }} CODE: ${{ needs.changes.outputs.code }} COVERAGE: ${{ needs.coverage.result }} run: | case "$CLASSIFICATION:$CODE:$COVERAGE" in success:true:success) echo "All desktop platforms meet the 80% total line coverage floor." ;; success:false:skipped) echo "Only prose changed. Coverage is unchanged." ;; *) echo "::error title=Coverage floor unavailable or unmet::See the classification and coverage jobs."; exit 1 ;; esac # The Android app (android/): clippy for the arm64 target, which also builds every crate the # APK links, so a change that breaks the Android build fails here. The APK itself is built by # the Packaging workflow. android: name: android (clippy, arm64) needs: changes if: needs.changes.outputs.code == 'true' runs-on: ubuntu-24.04 timeout-minutes: 60 steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - name: Restore pinned cargo-ndk id: cargo-ndk uses: actions/cache/restore@caa296126883cff596d87d8935842f9db880ef25 # v5 with: path: ~/.cargo/bin/cargo-ndk key: cargo-ndk-ubuntu24-${{ runner.arch }}-${{ hashFiles('android/ci-setup.sh', 'rust-toolchain.toml') }} - name: Install the Android SDK packages, the Rust target and cargo-ndk run: bash android/ci-setup.sh - name: Save pinned cargo-ndk from main if: github.event_name == 'push' && github.ref == 'refs/heads/main' && steps.cargo-ndk.outputs.cache-hit != 'true' uses: actions/cache/save@caa296126883cff596d87d8935842f9db880ef25 # v5 with: path: ~/.cargo/bin/cargo-ndk key: ${{ steps.cargo-ndk.outputs.cache-primary-key }} - uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 # v2.9.2 with: key: android save-if: ${{ github.ref == 'refs/heads/main' }} - run: cargo ndk --target arm64-v8a --platform 26 clippy --locked -p notecraft-android -- -D warnings ci-status: name: CI runs-on: ubuntu-latest # Coverage is advisory and can finish after the required check. needs: [changes, fmt, clippy, platform-build-test, android, voice, static] if: always() steps: - name: Check CI result env: CHANGES: ${{ needs.changes.result }} CODE: ${{ needs.changes.outputs.code }} FMT: ${{ needs.fmt.result }} CLIPPY: ${{ needs.clippy.result }} BUILD_TEST: ${{ needs.platform-build-test.result }} ANDROID: ${{ needs.android.result }} VOICE: ${{ needs.voice.result }} STATIC: ${{ needs.static.result }} run: | # The change filter must have succeeded: if it failed, the jobs it gates were skipped, # and a skip must never pass as a green run. if [[ "$CHANGES" != "success" ]]; then echo "The change filter did not succeed ($CHANGES)" exit 1 fi if [[ "$CODE" != "true" && "$CODE" != "false" ]]; then echo "Unexpected change filter output: '$CODE'" exit 1 fi for result in "$FMT" "$STATIC"; do if [[ "$result" != "success" ]]; then echo "Quality checks failed"; exit 1; fi done for result in "$CLIPPY" "$BUILD_TEST" "$ANDROID" "$VOICE"; do if [[ "$result" != "success" && ! ( "$CODE" == "false" && "$result" == "skipped" ) ]]; then echo "Quality checks failed" exit 1 fi done if [[ "$CODE" != "true" ]]; then echo "Only prose changed: build, test, clippy, voice and coverage were skipped"; fi echo "CI checks passed"