From 6dd2c13e24881e47d091a667b7ad52b3f55bdf28 Mon Sep 17 00:00:00 2001 From: Muneer Alam Date: Tue, 17 Nov 2026 14:52:35 +0530 Subject: [PATCH 1/2] ci: avoid duplicate runs and unrelated native rebuilds --- .github/workflows/branding.yml | 5 +++ .github/workflows/ci-scope.yml | 36 +++++++++++++++ .github/workflows/ci.yml | 50 ++++++++++++++++----- .github/workflows/codeql.yml | 4 +- .github/workflows/packages.yml | 27 ++++++++++- .github/workflows/windows-core.yml | 13 +++--- .github/workflows/windows-portable.yml | 5 +++ .github/workflows/windows-qualification.yml | 7 ++- CONTRIBUTING.md | 20 ++++++--- scripts/ci-scope.py | 26 +++++++++++ scripts/test_ci_scope.py | 30 +++++++++++++ 11 files changed, 195 insertions(+), 28 deletions(-) create mode 100644 .github/workflows/ci-scope.yml create mode 100644 scripts/ci-scope.py create mode 100644 scripts/test_ci_scope.py diff --git a/.github/workflows/branding.yml b/.github/workflows/branding.yml index e822377..1494d98 100644 --- a/.github/workflows/branding.yml +++ b/.github/workflows/branding.yml @@ -2,6 +2,7 @@ name: Brand asset consistency on: push: + branches: [master] paths: - assets/branding/** - tools/branding/** @@ -17,6 +18,10 @@ on: permissions: contents: read +concurrency: + group: branding-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: ${{ github.event_name == 'pull_request' }} + jobs: exports: runs-on: ubuntu-latest diff --git a/.github/workflows/ci-scope.yml b/.github/workflows/ci-scope.yml new file mode 100644 index 0000000..38f827c --- /dev/null +++ b/.github/workflows/ci-scope.yml @@ -0,0 +1,36 @@ +name: CI scope + +on: + workflow_call: + outputs: + native: + value: ${{ jobs.scope.outputs.native }} + packages: + value: ${{ jobs.scope.outputs.packages }} + +permissions: + contents: read + +jobs: + scope: + runs-on: ubuntu-latest + outputs: + native: ${{ steps.scope.outputs.native }} + packages: ${{ steps.scope.outputs.packages }} + steps: + - uses: actions/checkout@v5 + with: + persist-credentials: false + fetch-depth: 2 + - name: Choose checks for this change + id: scope + shell: bash + env: + EVENT_NAME: ${{ github.event_name }} + BASE_SHA: ${{ github.event.pull_request.base.sha }} + run: | + if [[ "$EVENT_NAME" == pull_request ]]; then + git diff --name-only -z "$BASE_SHA" HEAD | python3 scripts/ci-scope.py >> "$GITHUB_OUTPUT" + else + printf 'native=true\npackages=true\n' >> "$GITHUB_OUTPUT" + fi diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 189b624..47daed1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -3,13 +3,23 @@ name: CI on: workflow_call: push: + branches: [master] pull_request: permissions: contents: read +concurrency: + group: ci-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: ${{ github.event_name == 'pull_request' }} + jobs: + scope: + uses: ./.github/workflows/ci-scope.yml + omarchy-plugin: + needs: scope + if: needs.scope.outputs.native != 'false' name: Omarchy plugin export runs-on: ubuntu-latest timeout-minutes: 5 @@ -30,6 +40,8 @@ jobs: if-no-files-found: error macos-installation: + needs: scope + if: needs.scope.outputs.native != 'false' name: macOS lifecycle (${{ matrix.os }}) runs-on: ${{ matrix.os }} timeout-minutes: 15 @@ -71,6 +83,8 @@ jobs: fi powershell: + needs: scope + if: needs.scope.outputs.native != 'false' name: PowerShell syntax runs-on: windows-latest steps: @@ -87,6 +101,8 @@ jobs: } check: + needs: scope + if: ${{ !cancelled() }} name: ${{ matrix.os }} runs-on: ${{ matrix.os }} strategy: @@ -95,16 +111,28 @@ jobs: os: [ubuntu-latest, macos-latest] steps: + - name: Require successful scope detection + env: + SCOPE_RESULT: ${{ needs.scope.result }} + run: test "$SCOPE_RESULT" = success - uses: actions/checkout@v5 - - name: Install Linux dependencies + - name: Install shell linter if: runner.os == 'Linux' - run: sudo apt-get update && sudo apt-get install -y libasound2-dev shellcheck + run: sudo apt-get update && sudo apt-get install -y shellcheck + - name: Install Linux dependencies + if: runner.os == 'Linux' && needs.scope.outputs.native == 'true' + run: sudo apt-get install -y libasound2-dev - name: Install Rust components + if: runner.os == 'Linux' || needs.scope.outputs.native == 'true' run: rustup component add clippy rustfmt - name: Check formatting + if: runner.os == 'Linux' run: cargo fmt --check - name: Check documentation - run: python3 scripts/check-docs.py + if: runner.os == 'Linux' + run: | + python3 scripts/check-docs.py + python3 -B -m unittest scripts/test_check_docs.py scripts/test_ci_scope.py - name: Check Linux installer lifecycle if: runner.os == 'Linux' run: python3 -B -m unittest scripts/test_install_lifecycle.py @@ -114,7 +142,7 @@ jobs: for script in scripts/*.sh packaging/omarchy-bar/*.sh; do bash -n "$script"; done shellcheck scripts/*.sh packaging/omarchy-bar/*.sh - name: Check macOS menu bar helper - if: runner.os == 'macOS' + if: runner.os == 'macOS' && needs.scope.outputs.native == 'true' run: | swiftc packaging/macos/KlickyMenu.swift -o /tmp/klicky-menu-check python3 -B scripts/test-macos-menu.py @@ -128,16 +156,14 @@ jobs: '/tmp/actionlint.tar.gz' | sha256sum --check tar -xzf /tmp/actionlint.tar.gz -C /tmp actionlint /tmp/actionlint -ignore 'SC2016:' - - name: Check - run: cargo check --all-targets - name: Test - run: cargo test + if: needs.scope.outputs.native == 'true' + run: cargo test --locked - name: Lint - run: cargo clippy --all-targets --all-features -- -D warnings - - name: Build release - run: cargo build --release + if: needs.scope.outputs.native == 'true' + run: cargo clippy --locked --all-targets --all-features -- -D warnings - name: Check systemd unit - if: runner.os == 'Linux' + if: runner.os == 'Linux' && needs.scope.outputs.native == 'true' run: | - install -Dm755 target/release/klicky "$HOME/.local/bin/klicky" + install -Dm755 target/debug/klicky "$HOME/.local/bin/klicky" systemd-analyze --user verify packaging/systemd/klicky.service diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index f5ee1ba..d04601b 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -2,8 +2,10 @@ name: CodeQL advanced on: pull_request: + paths-ignore: ['**.md'] push: branches: [master] + paths-ignore: ['**.md'] schedule: - cron: '17 3 * * 2' workflow_dispatch: @@ -60,7 +62,7 @@ jobs: with: category: /language:${{ matrix.language }} output: ${{ runner.temp }}/codeql-results - # Default setup stays active until the reviewed migration is ready. + # Disable uploads before restoring default setup during a rollback. upload: ${{ vars.CODEQL_ADVANCED_ENABLED == 'true' && 'always' || 'never' }} upload-database: false - name: Verify the Swift helper was extracted diff --git a/.github/workflows/packages.yml b/.github/workflows/packages.yml index edc2677..19fc45f 100644 --- a/.github/workflows/packages.yml +++ b/.github/workflows/packages.yml @@ -3,15 +3,29 @@ name: Packages on: workflow_call: push: + branches: [master] pull_request: permissions: contents: read +concurrency: + group: packages-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: ${{ github.event_name == 'pull_request' }} + jobs: + scope: + uses: ./.github/workflows/ci-scope.yml + debian-package: + needs: scope + if: ${{ !cancelled() && needs.scope.outputs.packages != 'false' }} runs-on: ubuntu-latest steps: + - name: Require successful scope detection + env: + SCOPE_RESULT: ${{ needs.scope.result }} + run: test "$SCOPE_RESULT" = success - uses: actions/checkout@v5 - name: Install dependencies run: | @@ -44,9 +58,14 @@ jobs: retention-days: 14 apt-repository: - needs: debian-package + needs: [scope, debian-package] + if: ${{ !cancelled() && needs.scope.outputs.packages != 'false' }} runs-on: ubuntu-latest steps: + - name: Require successful package build + env: + PACKAGE_RESULT: ${{ needs.debian-package.result }} + run: test "$PACKAGE_RESULT" = success - uses: actions/checkout@v5 - uses: actions/download-artifact@v5 with: @@ -65,11 +84,17 @@ jobs: --exercise-history-retention "$package" arch-package: + needs: scope + if: ${{ !cancelled() && needs.scope.outputs.packages != 'false' }} runs-on: ubuntu-latest container: archlinux:latest env: SOURCE_SHA: ${{ github.event.pull_request.head.sha || github.sha }} steps: + - name: Require successful scope detection + env: + SCOPE_RESULT: ${{ needs.scope.result }} + run: test "$SCOPE_RESULT" = success - name: Install dependencies run: pacman -Syu --noconfirm base-devel git rust alsa-lib systemd namcap python - uses: actions/checkout@v5 diff --git a/.github/workflows/windows-core.yml b/.github/workflows/windows-core.yml index bbf01e8..47e9021 100644 --- a/.github/workflows/windows-core.yml +++ b/.github/workflows/windows-core.yml @@ -3,6 +3,7 @@ name: Windows portable core on: workflow_call: push: + branches: [master] paths: - src/** - tests/** @@ -24,6 +25,10 @@ on: permissions: contents: read +concurrency: + group: windows-core-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: ${{ github.event_name == 'pull_request' }} + jobs: check: name: windows-core @@ -31,14 +36,8 @@ jobs: steps: - uses: actions/checkout@v5 - name: Install declared minimum Rust - run: rustup toolchain install 1.87.0 --profile minimal --component rustfmt --component clippy - - name: Check formatting - run: cargo +1.87.0 fmt --check - - name: Check compilation - run: cargo +1.87.0 check --locked --all-targets + run: rustup toolchain install 1.87.0 --profile minimal --component clippy - name: Test portable code run: cargo +1.87.0 test --locked - name: Lint run: cargo +1.87.0 clippy --locked --all-targets --all-features -- -D warnings - - name: Build development targets - run: cargo +1.87.0 build --locked --release diff --git a/.github/workflows/windows-portable.yml b/.github/workflows/windows-portable.yml index b5b519b..f452754 100644 --- a/.github/workflows/windows-portable.yml +++ b/.github/workflows/windows-portable.yml @@ -3,6 +3,7 @@ name: Windows packages on: workflow_call: push: + branches: [master] paths: - src/** - sounds/** @@ -44,6 +45,10 @@ on: permissions: contents: read +concurrency: + group: windows-portable-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: ${{ github.event_name == 'pull_request' }} + jobs: bundle: runs-on: windows-latest diff --git a/.github/workflows/windows-qualification.yml b/.github/workflows/windows-qualification.yml index 1597ada..355828d 100644 --- a/.github/workflows/windows-qualification.yml +++ b/.github/workflows/windows-qualification.yml @@ -2,6 +2,7 @@ name: Windows qualification tooling on: push: + branches: [master] paths: - tools/windows-qualification/** - src/player.rs @@ -19,6 +20,10 @@ on: permissions: contents: read +concurrency: + group: windows-qualification-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: ${{ github.event_name == 'pull_request' }} + jobs: check: strategy: @@ -39,8 +44,6 @@ jobs: run: rustup toolchain install 1.87.0 --profile minimal --component rustfmt --component clippy - name: Check formatting run: cargo +1.87.0 fmt --manifest-path tools/windows-qualification/Cargo.toml --check - - name: Check compilation - run: cargo +1.87.0 check --locked --all-targets --manifest-path tools/windows-qualification/Cargo.toml - name: Lint run: cargo +1.87.0 clippy --locked --all-targets --manifest-path tools/windows-qualification/Cargo.toml -- -D warnings - name: Build qualification executable diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 42b3018..4201a99 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -81,17 +81,27 @@ Write tests for behavior that can regress: Do not add tests for trivial delegation or compiler-enforced properties. Hardware behavior needs a real device test and a written environment description. -Run before every pull request: +For Rust changes, run: ```bash cargo fmt --check -cargo check --all-targets -cargo test -cargo clippy --all-targets --all-features -- -D warnings +cargo test --locked +cargo clippy --locked --all-targets --all-features -- -D warnings PYTHONUTF8=1 python3 -B scripts/check-docs.py -cargo build --release ``` +Clippy includes compilation checks. Run `cargo build --release` when changing +build behavior or preparing a package; package CI also builds release binaries. +For prose-only edits, the documentation check is sufficient locally. + +PR validation runs once per commit, with superseded runs cancelled. Markdown-only +PRs keep the fast documentation, formatting and script checks, without rebuilding +native apps and packages. Website changes retain package/APT validation. Unknown +files and workflow changes use full checks; `master` and release candidates always +run the full native and package suite. Required check names remain available even +when their expensive work is unnecessary. A failed scope check fails the required +checks rather than silently accepting the change. + For APT changes, run `python3 -B -m unittest scripts/test_apt_repository.py` and, on Linux with GnuPG and reprepro, `python3 -B scripts/test_apt_repository_integration.py PACKAGE.deb`. See [APT validation coverage](docs/MAINTAINING_APT.md#validation-coverage) for what these checks establish. For website changes, follow the [website checks](docs/WEBSITE.md#preview-and-validate). In PowerShell, set `$env:PYTHONUTF8 = '1'` before running Python. ## macOS menu checks diff --git a/scripts/ci-scope.py b/scripts/ci-scope.py new file mode 100644 index 0000000..3feca75 --- /dev/null +++ b/scripts/ci-scope.py @@ -0,0 +1,26 @@ +#!/usr/bin/env python3 +"""Select expensive PR checks from NUL-delimited git diff paths on stdin. + +Only known documentation and website paths get a reduced check set. Unknown +paths, workflow changes and an empty diff retain full native/package coverage. +""" +import sys + + +def scope(paths): + paths = list(paths) + native = packages = not paths + for path in paths: + if path.endswith(".md"): + continue + packages = True + if not path.startswith(("assets/website/", "packaging/apt/")): + native = True + return {"native": native, "packages": packages} + + +if __name__ == "__main__": + result = scope(p.decode("utf-8", errors="surrogateescape") + for p in sys.stdin.buffer.read().split(b"\0") if p) + for name, enabled in result.items(): + print(f"{name}={str(enabled).lower()}") diff --git a/scripts/test_ci_scope.py b/scripts/test_ci_scope.py new file mode 100644 index 0000000..507d1bb --- /dev/null +++ b/scripts/test_ci_scope.py @@ -0,0 +1,30 @@ +"""Protect scope selection: native changes must never take the prose shortcut.""" +import importlib.util +from pathlib import Path +import unittest + +spec = importlib.util.spec_from_file_location("ci_scope", Path(__file__).with_name("ci-scope.py")) +ci_scope = importlib.util.module_from_spec(spec) +spec.loader.exec_module(ci_scope) + + +class ScopeTests(unittest.TestCase): + def test_prose_only(self): + self.assertEqual(ci_scope.scope(["README.md", "docs/WINDOWS.md"]), + {"native": False, "packages": False}) + + def test_website_keeps_package_and_repository_checks(self): + self.assertEqual(ci_scope.scope(["assets/website/site.js", "packaging/apt/index.html"]), + {"native": False, "packages": True}) + + def test_native_and_unknown_changes_keep_full_checks(self): + for path in ("src/main.rs", "Cargo.lock", "sounds/eg-oreo/sound.ogg", + "scripts/install-macos.sh", "packaging/macos/KlickyMenu.swift", + ".github/workflows/ci.yml", ".github/workflows/ci-scope.yml", + "some-new-build-input", "scripts/a file\nwith newline.py"): + with self.subTest(path=path): + self.assertEqual(ci_scope.scope(["README.md", path]), + {"native": True, "packages": True}) + + def test_empty_diff_keeps_full_checks(self): + self.assertEqual(ci_scope.scope([]), {"native": True, "packages": True}) From f758c52ec58da76215dae68e8a793a5622ea124c Mon Sep 17 00:00:00 2001 From: Muneer Alam Date: Tue, 17 Nov 2026 14:55:13 +0530 Subject: [PATCH 2/2] ci: avoid macOS runner queues for prose checks --- .github/workflows/ci.yml | 24 +++++++++++++----------- CONTRIBUTING.md | 3 ++- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 47daed1..7f4c441 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -104,7 +104,8 @@ jobs: needs: scope if: ${{ !cancelled() }} name: ${{ matrix.os }} - runs-on: ${{ matrix.os }} + # Keep required names without queueing a macOS VM for prose/website edits. + runs-on: ${{ needs.scope.outputs.native == 'false' && 'ubuntu-latest' || matrix.os }} strategy: fail-fast: false matrix: @@ -116,38 +117,39 @@ jobs: SCOPE_RESULT: ${{ needs.scope.result }} run: test "$SCOPE_RESULT" = success - uses: actions/checkout@v5 + if: matrix.os == 'ubuntu-latest' || needs.scope.outputs.native == 'true' - name: Install shell linter - if: runner.os == 'Linux' + if: matrix.os == 'ubuntu-latest' run: sudo apt-get update && sudo apt-get install -y shellcheck - name: Install Linux dependencies - if: runner.os == 'Linux' && needs.scope.outputs.native == 'true' + if: matrix.os == 'ubuntu-latest' && needs.scope.outputs.native == 'true' run: sudo apt-get install -y libasound2-dev - name: Install Rust components - if: runner.os == 'Linux' || needs.scope.outputs.native == 'true' + if: matrix.os == 'ubuntu-latest' || needs.scope.outputs.native == 'true' run: rustup component add clippy rustfmt - name: Check formatting - if: runner.os == 'Linux' + if: matrix.os == 'ubuntu-latest' run: cargo fmt --check - name: Check documentation - if: runner.os == 'Linux' + if: matrix.os == 'ubuntu-latest' run: | python3 scripts/check-docs.py python3 -B -m unittest scripts/test_check_docs.py scripts/test_ci_scope.py - name: Check Linux installer lifecycle - if: runner.os == 'Linux' + if: matrix.os == 'ubuntu-latest' run: python3 -B -m unittest scripts/test_install_lifecycle.py - name: Check shell scripts - if: runner.os == 'Linux' + if: matrix.os == 'ubuntu-latest' run: | for script in scripts/*.sh packaging/omarchy-bar/*.sh; do bash -n "$script"; done shellcheck scripts/*.sh packaging/omarchy-bar/*.sh - name: Check macOS menu bar helper - if: runner.os == 'macOS' && needs.scope.outputs.native == 'true' + if: matrix.os == 'macos-latest' && needs.scope.outputs.native == 'true' run: | swiftc packaging/macos/KlickyMenu.swift -o /tmp/klicky-menu-check python3 -B scripts/test-macos-menu.py - name: Check GitHub Actions workflows - if: runner.os == 'Linux' + if: matrix.os == 'ubuntu-latest' run: | curl -fsSLo /tmp/actionlint.tar.gz \ https://github.com/rhysd/actionlint/releases/download/v1.7.12/actionlint_1.7.12_linux_amd64.tar.gz @@ -163,7 +165,7 @@ jobs: if: needs.scope.outputs.native == 'true' run: cargo clippy --locked --all-targets --all-features -- -D warnings - name: Check systemd unit - if: runner.os == 'Linux' && needs.scope.outputs.native == 'true' + if: matrix.os == 'ubuntu-latest' && needs.scope.outputs.native == 'true' run: | install -Dm755 target/debug/klicky "$HOME/.local/bin/klicky" systemd-analyze --user verify packaging/systemd/klicky.service diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 4201a99..dca4e9c 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -99,7 +99,8 @@ PRs keep the fast documentation, formatting and script checks, without rebuildin native apps and packages. Website changes retain package/APT validation. Unknown files and workflow changes use full checks; `master` and release candidates always run the full native and package suite. Required check names remain available even -when their expensive work is unnecessary. A failed scope check fails the required +when their expensive work is unnecessary; the macOS check reports from a small +Linux job for prose/website edits. A failed scope check fails the required checks rather than silently accepting the change. For APT changes, run `python3 -B -m unittest scripts/test_apt_repository.py` and, on Linux with GnuPG and reprepro, `python3 -B scripts/test_apt_repository_integration.py PACKAGE.deb`. See [APT validation coverage](docs/MAINTAINING_APT.md#validation-coverage) for what these checks establish. For website changes, follow the [website checks](docs/WEBSITE.md#preview-and-validate). In PowerShell, set `$env:PYTHONUTF8 = '1'` before running Python.