From 8170ef860aa5018362775edd736a5eaf685d1dbd Mon Sep 17 00:00:00 2001 From: Sacha Brants Date: Tue, 27 Oct 2026 09:32:01 +0530 Subject: [PATCH] CI: stop building the same commit several times - codeql.yml: replace CodeQL default setup with a workflow that scans PRs and runs weekly, not every push to main. With "require up to date" on, the merge commit has the tree the PR scan already analyzed. - release-cache.yml: skip when a push only changes the wavetrace version in Cargo.toml/Cargo.lock (every release bump). rust-cache caches dependencies only, so the existing caches still fit, and the run used to rebuild all five release targets alongside the release itself. - dependabot.yml: put npm and Cargo in one multi-ecosystem group, so one PR and one CI run replace two (plus a rerun after the first merge), and the Tauri npm packages and crates can't land at different versions. Co-Authored-By: Claude Opus 5.5 --- .github/dependabot.yml | 39 +++++++++++---------------- .github/workflows/codeql.yml | 42 +++++++++++++++++++++++++++++ .github/workflows/release-cache.yml | 36 +++++++++++++++++++++++++ 3 files changed, 93 insertions(+), 24 deletions(-) create mode 100644 .github/workflows/codeql.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 93f91c9..0348b2c 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -1,42 +1,33 @@ version: 2 -updates: - - package-ecosystem: npm - directory: / + +# npm and Cargo land in one PR: one CI run instead of two (plus a rerun of whichever +# merges second), and the Tauri npm packages and crates always move together. A Cargo +# bump merged ahead of its npm counterpart once broke release builds with +# "Found version mismatched Tauri packages". +multi-ecosystem-groups: + app-deps: schedule: interval: weekly day: monday - open-pull-requests-limit: 3 labels: - dependencies + +updates: + - package-ecosystem: npm + directory: / + multi-ecosystem-group: app-deps + patterns: ["*"] ignore: - dependency-name: "*" update-types: ["version-update:semver-major"] - groups: - npm-minor-patch: - patterns: - - "*" - update-types: - - minor - - patch - package-ecosystem: cargo directory: /src-tauri - schedule: - interval: weekly - day: monday - open-pull-requests-limit: 3 - labels: - - dependencies + multi-ecosystem-group: app-deps + patterns: ["*"] ignore: - dependency-name: "*" update-types: ["version-update:semver-major"] - groups: - cargo-minor-patch: - patterns: - - "*" - update-types: - - minor - - patch - package-ecosystem: github-actions directory: / diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml new file mode 100644 index 0000000..c01f2ff --- /dev/null +++ b/.github/workflows/codeql.yml @@ -0,0 +1,42 @@ +# Replaces CodeQL default setup, which also scanned every push to main. With "require +# branches to be up to date" on main, a merge commit has the same tree the PR's scan +# just analyzed, so main is only rescanned weekly (keeps its alert state current). +name: CodeQL + +on: + pull_request: + branches: [main] + schedule: + - cron: "0 6 * * 1" + workflow_dispatch: + +permissions: + contents: read + +concurrency: + group: codeql-${{ github.ref }} + cancel-in-progress: true + +jobs: + analyze: + name: Analyze (${{ matrix.language }}) + runs-on: ubuntu-latest + permissions: + contents: read + security-events: write + actions: read + strategy: + fail-fast: false + matrix: + language: [actions, javascript-typescript, python, rust] + steps: + - uses: actions/checkout@v7 + + - uses: github/codeql-action/init@v4 + with: + languages: ${{ matrix.language }} + build-mode: none + + - uses: github/codeql-action/analyze@v4 + with: + category: /language:${{ matrix.language }} diff --git a/.github/workflows/release-cache.yml b/.github/workflows/release-cache.yml index 5274d96..cba63af 100644 --- a/.github/workflows/release-cache.yml +++ b/.github/workflows/release-cache.yml @@ -25,7 +25,39 @@ concurrency: cancel-in-progress: true jobs: + # A release's version bump touches Cargo.toml/Cargo.lock but no dependency, and + # rust-cache only caches dependencies, so the existing caches still fit. Skip those. + changes: + runs-on: ubuntu-latest + outputs: + deps: ${{ steps.check.outputs.deps }} + steps: + - uses: actions/checkout@v7 + with: + fetch-depth: 0 + + - id: check + env: + BEFORE: ${{ github.event.before }} + run: | + if [ "$GITHUB_EVENT_NAME" != push ] || ! git cat-file -e "$BEFORE^{commit}" 2>/dev/null; then + echo "deps=true" >> "$GITHUB_OUTPUT"; exit 0 + fi + # Blank out the app's own version, then compare. + norm_lock() { git show "$1:src-tauri/Cargo.lock" | awk '/^name = "wavetrace"$/ { print; getline; print "version = -"; next } { print }'; } + norm_toml() { git show "$1:src-tauri/Cargo.toml" | awk '/^\[/ { sec = $0 } sec == "[package]" && /^version = / { print "version = -"; next } { print }'; } + if git diff --quiet "$BEFORE" HEAD -- .github/workflows/release-cache.yml \ + && cmp -s <(norm_lock "$BEFORE") <(norm_lock HEAD) \ + && cmp -s <(norm_toml "$BEFORE") <(norm_toml HEAD); then + echo "Only the wavetrace version changed; caches are still valid." + echo "deps=false" >> "$GITHUB_OUTPUT" + else + echo "deps=true" >> "$GITHUB_OUTPUT" + fi + native: + needs: changes + if: needs.changes.outputs.deps == 'true' strategy: fail-fast: false matrix: @@ -73,6 +105,8 @@ jobs: run: npm run tauri build -- --no-bundle macos: + needs: changes + if: needs.changes.outputs.deps == 'true' strategy: fail-fast: false matrix: @@ -109,6 +143,8 @@ jobs: run: npm run tauri build -- --target ${{ matrix.target }} --no-bundle --config src-tauri/tauri.macos.ci.conf.json arch: + needs: changes + if: needs.changes.outputs.deps == 'true' runs-on: ubuntu-latest container: image: archlinux:latest