From a7faae889448782979d07ce9d878e762c87d3cba Mon Sep 17 00:00:00 2001 From: rgdevment Date: Sun, 8 Nov 2026 16:56:56 -0300 Subject: [PATCH 1/3] ci: a pull request pays only for what it touched, and the Mac weighs only the mutants Linux cannot --- .github/workflows/bundle.yml | 4 +- .github/workflows/ci.yml | 33 ++++++++++- .github/workflows/mutants-sweep.yml | 10 ++-- .github/workflows/mutants.yml | 90 ++++++++++++----------------- .github/workflows/release.yml | 18 +++--- 5 files changed, 85 insertions(+), 70 deletions(-) diff --git a/.github/workflows/bundle.yml b/.github/workflows/bundle.yml index ce1c50b..e6cd0ad 100644 --- a/.github/workflows/bundle.yml +++ b/.github/workflows/bundle.yml @@ -12,7 +12,6 @@ on: - "scripts/sidecar.sh" - "Cargo.toml" - ".github/workflows/bundle.yml" - - ".github/workflows/release.yml" pull_request: workflow_dispatch: @@ -48,7 +47,8 @@ jobs: echo "packaging=true" >> "$GITHUB_OUTPUT" exit 0 fi - watched='^(app/src-tauri/(nsis/|Info\.plist|tauri\.conf\.json|Cargo\.toml|build\.rs)|scripts/sidecar\.sh|Cargo\.toml$|\.github/workflows/(bundle|release)\.yml$)' + # release.yml runs none of what is below; actionlint and zizmor in Rules are what read it. + watched='^(app/src-tauri/(nsis/|Info\.plist|tauri\.conf\.json|Cargo\.toml|build\.rs)|scripts/sidecar\.sh|Cargo\.toml$|\.github/workflows/bundle\.yml$)' from=$(git merge-base "$BASE" HEAD) if git diff --name-only --diff-filter=d "$from" HEAD | grep -qE "$watched"; then echo "packaging=true" >> "$GITHUB_OUTPUT" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4cd1986..575e492 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -24,6 +24,8 @@ jobs: timeout-minutes: 5 outputs: rust: ${{ steps.look.outputs.rust }} + picker: ${{ steps.look.outputs.picker }} + deps: ${{ steps.look.outputs.deps }} steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: @@ -36,7 +38,7 @@ jobs: BASE: ${{ github.event.pull_request.base.sha }} run: | if [ "$EVENT" != "pull_request" ]; then - echo "rust=true" >> "$GITHUB_OUTPUT" + printf 'rust=true\npicker=true\ndeps=true\n' >> "$GITHUB_OUTPUT" exit 0 fi aside='^(app/src/|app/(\.gitignore|biome\.json|index\.html|package(-lock)?\.json|stryker\.config\.json|tsconfig(\.node)?\.json|vite\.config\.ts)$|hooks/|packaging/|resources/|(CLA|COMMERCIAL|CONTRIBUTING|PRIVACY|README|SECURITY)\.md$|package(-lock)?\.json$|\.markdownlint-cli2\.jsonc$|\.editorconfig$|\.github/(FUNDING|dependabot)\.yml$|\.github/(not-this-spanish|oversized)\.txt$|\.github/workflows/(bundle|caches|cla|commits|feed|mutants|mutants-sweep|release|rules|update-badge)\.yml$)' @@ -48,6 +50,13 @@ jobs: [ -n "$first" ] && rust=true || rust=false echo "rust=$rust" >> "$GITHUB_OUTPUT" echo "the first path Rust has to answer for: ${first:-none}" + self='^\.github/workflows/ci\.yml$' + picker=false + grep -qE "^app/([^/]+|src/.*)$|$self" <<< "$changed" && picker=true + deps=false + grep -qE "(^|/)(Cargo\.(toml|lock)|package(-lock)?\.json)$|^deny\.toml$|$self" <<< "$changed" && deps=true + printf 'picker=%s\ndeps=%s\n' "$picker" "$deps" >> "$GITHUB_OUTPUT" + echo "the picker: $picker; the dependencies: $deps" test: name: test / ${{ matrix.os }} @@ -123,6 +132,8 @@ jobs: lint: name: fmt + needs: changes + if: needs.changes.outputs.rust == 'true' runs-on: ubuntu-24.04 timeout-minutes: 10 steps: @@ -134,6 +145,8 @@ jobs: picker: name: frontend + needs: changes + if: needs.changes.outputs.picker == 'true' runs-on: ubuntu-24.04 timeout-minutes: 20 defaults: @@ -151,6 +164,9 @@ jobs: - run: npm ci - run: npm run lint - run: npm run build + # Coverage, which runs the tests everywhere else, skips Dependabot's bumps. + - if: github.actor == 'dependabot[bot]' + run: npm test prose: name: markdown @@ -168,8 +184,11 @@ jobs: - run: npm ci - run: npm run lint:md + # On a pull request only the manifests, the locks and deny.toml can change what this says; main reads it every push. audit: name: advisories + licences + needs: changes + if: needs.changes.outputs.deps == 'true' runs-on: ubuntu-24.04 timeout-minutes: 15 steps: @@ -211,8 +230,10 @@ jobs: coverage: name: coverage needs: changes - # A dependency bump changes no line of ours, so it pays for neither coverage nor Sonar. - if: github.actor != 'dependabot[bot]' + # A dependency bump changes no line of ours, and neither does prose, so they pay for neither coverage nor Sonar. + if: >- + github.actor != 'dependabot[bot]' + && (needs.changes.outputs.rust == 'true' || needs.changes.outputs.picker == 'true') runs-on: ubuntu-24.04 timeout-minutes: 40 steps: @@ -248,13 +269,19 @@ jobs: sudo apt-get install -y -qq libgtk-3-dev libayatana-appindicator3-dev libxdo-dev libfontconfig1-dev libfreetype6-dev libxkbcommon-dev libwayland-dev libxcb1-dev cargo llvm-cov nextest -p linkunbound-core -p linkunbound-shell --lcov --output-path lcov-rust.info + - name: No picker lines to measure on this branch + if: needs.changes.outputs.picker != 'true' + run: mkdir -p app/coverage && touch app/coverage/lcov.info + - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 + if: needs.changes.outputs.picker == 'true' with: node-version: 22 cache: npm cache-dependency-path: app/package-lock.json - name: The picker + if: needs.changes.outputs.picker == 'true' working-directory: app run: | npm ci diff --git a/.github/workflows/mutants-sweep.yml b/.github/workflows/mutants-sweep.yml index ec3a827..e355989 100644 --- a/.github/workflows/mutants-sweep.yml +++ b/.github/workflows/mutants-sweep.yml @@ -15,6 +15,8 @@ concurrency: env: CARGO_TERM_COLOR: always DESKTOP_LIBS: libgtk-3-dev libayatana-appindicator3-dev libxdo-dev libfontconfig1-dev libfreetype6-dev libxkbcommon-dev libwayland-dev libxcb1-dev + NOT_ON_LINUX: "mac::|local_web_file|launchable_file|host::|reaction_to|sent_by_launch_services|platform::|dress_natively|replace is_bundle|relaunch_resident|relay_links|hand_to_the_resident|replace base -> Option|replace address -> String|replace named -> Option Option|replace address -> String|replace named -> Option Option|replace address -> String|replace named -> Option> "$GITHUB_OUTPUT" - name: What survived @@ -86,7 +88,7 @@ jobs: run: | set +e cargo mutants -p linkunbound-shell --shard $(( ${{ matrix.shard }} - 1 ))/4 -j 2 \ - --exclude-re 'mac::|local_web_file|launchable_file|host::|reaction_to|sent_by_launch_services|platform::|dress_natively|replace is_bundle|relaunch_resident|relay_links|hand_to_the_resident|replace base -> Option|replace address -> String|replace named -> Option> "$GITHUB_OUTPUT" - name: What survived @@ -137,7 +139,7 @@ jobs: run: | set +e cargo mutants -p linkunbound-settings --shard $(( ${{ matrix.shard }} - 1 ))/2 --in-place \ - --exclude-re 'mac::|local_web_file|launchable_file|host::|reaction_to|sent_by_launch_services|platform::|dress_natively|replace is_bundle|relaunch_resident|relay_links|hand_to_the_resident|replace base -> Option|replace address -> String|replace named -> Option> "$GITHUB_OUTPUT" - name: What survived @@ -181,7 +183,7 @@ jobs: cargo mutants -p linkunbound-mac --shard $(( ${{ matrix.shard }} - 1 ))/2 -j 2 code=$? cargo mutants -p linkunbound-core -p linkunbound-shell --shard $(( ${{ matrix.shard }} - 1 ))/2 -j 2 \ - -F 'mac::|local_web_file|launchable_file|reaction_to|sent_by_launch_services|replace drawing|replace base -> Option|replace address -> String|replace named -> Option> "$GITHUB_OUTPUT" diff --git a/.github/workflows/mutants.yml b/.github/workflows/mutants.yml index d92cf26..3135b34 100644 --- a/.github/workflows/mutants.yml +++ b/.github/workflows/mutants.yml @@ -12,6 +12,9 @@ concurrency: env: CARGO_TERM_COLOR: always + NOT_ON_LINUX: "mac::|local_web_file|launchable_file|host::|reaction_to|sent_by_launch_services|platform::|dress_natively|replace is_bundle|relaunch_resident|relay_links|hand_to_the_resident|replace base -> Option|replace address -> String|replace named -> Option Option|replace address -> String|replace named -> Option> "$GITHUB_OUTPUT" - else - echo "mutable=false" >> "$GITHUB_OUTPUT" + # A dependency bump changes no line of ours, even when it touches a crate's manifest. + if [ "$ACTOR" = "dependabot[bot]" ]; then + printf 'crates=false\nmac=false\nsettings=false\nwindow=false\n' >> "$GITHUB_OUTPUT" + exit 0 fi + from=$(git merge-base "$BASE" HEAD) + touched() { git diff --quiet "$from" HEAD -- "$@" && echo false || echo true; } + { + echo "crates=$(touched crates/linkunbound-core crates/linkunbound-shell)" + echo "mac=$(touched crates)" + echo "settings=$(touched app/src-tauri/src)" + echo "window=$(touched app/src)" + } | tee -a "$GITHUB_OUTPUT" crates-on-the-branch: name: crates / the lines this branch changed runs-on: ubuntu-24.04 needs: changes - if: github.actor != 'dependabot[bot]' && needs.changes.outputs.mutable == 'true' + if: needs.changes.outputs.crates == 'true' timeout-minutes: 90 steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 @@ -52,60 +65,51 @@ jobs: persist-credentials: false - name: What the branch changed in the crates - id: touched env: BASE: ${{ github.event.pull_request.base.sha }} - run: | - from=$(git merge-base "$BASE" HEAD) - git diff "$from" -- crates/linkunbound-core crates/linkunbound-shell > branch.diff - if [ -s branch.diff ]; then echo "any=yes" >> "$GITHUB_OUTPUT"; fi + run: git diff "$(git merge-base "$BASE" HEAD)" -- crates/linkunbound-core crates/linkunbound-shell > branch.diff - uses: ./.github/actions/toolchain - if: steps.touched.outputs.any == 'yes' - uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 # v2.9.3 with: shared-key: workspace save-if: false - if: steps.touched.outputs.any == 'yes' - uses: taiki-e/install-action@5488ac5a951645ce95062214902ac4b6bc1a1037 # v2.87.32 - if: steps.touched.outputs.any == 'yes' with: tool: nextest,cargo-mutants - name: What a desktop is not needed to build - if: steps.touched.outputs.any == 'yes' run: | sudo apt-get update -qq sudo apt-get install -y -qq libgtk-3-dev libayatana-appindicator3-dev libxdo-dev libfontconfig1-dev libfreetype6-dev libxkbcommon-dev libwayland-dev libxcb1-dev - name: A mutant that lives on a line this branch wrote id: run - if: steps.touched.outputs.any == 'yes' run: | set +e - cargo mutants --in-diff branch.diff -p linkunbound-core -p linkunbound-shell -j 2 \ - --exclude-re 'mac::|local_web_file|launchable_file|host::|reaction_to|sent_by_launch_services|platform::|dress_natively|replace is_bundle|relaunch_resident|relay_links|hand_to_the_resident|replace base -> Option|replace address -> String|replace named -> Option> "$GITHUB_OUTPUT" - name: What survived - if: always() && steps.touched.outputs.any == 'yes' + if: always() env: CODE: ${{ steps.run.outputs.code }} TITLE: The lines this branch changed run: bash scripts/mutants-report.sh - uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 - if: always() && steps.touched.outputs.any == 'yes' + if: always() with: name: mutants-branch-crates path: mutants.out/ retention-days: 7 + # Weighing the core and the picker again here, all of it, outlasted everything else a pull request runs. mac-on-the-branch: name: mac / the lines this branch changed runs-on: macos-latest needs: changes - if: github.actor != 'dependabot[bot]' && needs.changes.outputs.mutable == 'true' + if: needs.changes.outputs.mac == 'true' timeout-minutes: 90 steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 @@ -114,54 +118,47 @@ jobs: persist-credentials: false - name: What the branch changed in the crates, read with a Mac's eyes - id: touched env: BASE: ${{ github.event.pull_request.base.sha }} - run: | - from=$(git merge-base "$BASE" HEAD) - git diff "$from" -- crates > branch.diff - if [ -s branch.diff ]; then echo "any=yes" >> "$GITHUB_OUTPUT"; fi + run: git diff "$(git merge-base "$BASE" HEAD)" -- crates > branch.diff - uses: ./.github/actions/toolchain - if: steps.touched.outputs.any == 'yes' - uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 # v2.9.3 with: shared-key: workspace save-if: false - if: steps.touched.outputs.any == 'yes' - uses: taiki-e/install-action@5488ac5a951645ce95062214902ac4b6bc1a1037 # v2.87.32 - if: steps.touched.outputs.any == 'yes' with: tool: nextest,cargo-mutants - name: A mutant that lives on a line this branch wrote id: run - if: steps.touched.outputs.any == 'yes' run: | set +e cargo mutants --in-diff branch.diff -p linkunbound-mac -p linkunbound-core -p linkunbound-shell -j 2 \ - --exclude-re 'replace forget with' + --re "^crates/linkunbound-mac/|$MAC_BRANCHES" --exclude-re 'replace forget with' echo "code=$?" >> "$GITHUB_OUTPUT" - name: What survived - if: always() && steps.touched.outputs.any == 'yes' + if: always() env: CODE: ${{ steps.run.outputs.code }} TITLE: The lines this branch changed, on a Mac run: bash scripts/mutants-report.sh - uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 - if: always() && steps.touched.outputs.any == 'yes' + if: always() with: name: mutants-branch-mac path: mutants.out/ retention-days: 7 + if-no-files-found: ignore settings-on-the-branch: name: settings / the lines this branch changed runs-on: ubuntu-24.04 needs: changes - if: github.actor != 'dependabot[bot]' && needs.changes.outputs.mutable == 'true' + if: needs.changes.outputs.settings == 'true' timeout-minutes: 90 steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 @@ -170,54 +167,43 @@ jobs: persist-credentials: false - name: What the branch changed in the settings backend - id: touched env: BASE: ${{ github.event.pull_request.base.sha }} - run: | - from=$(git merge-base "$BASE" HEAD) - git diff "$from" -- app/src-tauri/src > branch.diff - if [ -s branch.diff ]; then echo "any=yes" >> "$GITHUB_OUTPUT"; fi + run: git diff "$(git merge-base "$BASE" HEAD)" -- app/src-tauri/src > branch.diff - uses: ./.github/actions/toolchain - if: steps.touched.outputs.any == 'yes' - uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 # v2.9.3 with: shared-key: workspace save-if: false - if: steps.touched.outputs.any == 'yes' - uses: taiki-e/install-action@5488ac5a951645ce95062214902ac4b6bc1a1037 # v2.87.32 - if: steps.touched.outputs.any == 'yes' with: tool: nextest,cargo-mutants - name: What a desktop is not needed to build - if: steps.touched.outputs.any == 'yes' run: | sudo apt-get update -qq sudo apt-get install -y -qq libgtk-3-dev libayatana-appindicator3-dev libxdo-dev libfontconfig1-dev libfreetype6-dev libxkbcommon-dev libwayland-dev libxcb1-dev libwebkit2gtk-4.1-dev libsoup-3.0-dev libjavascriptcoregtk-4.1-dev - name: The resident rides along - if: steps.touched.outputs.any == 'yes' run: bash scripts/sidecar.sh - name: A mutant that lives on a line this branch wrote id: run - if: steps.touched.outputs.any == 'yes' run: | set +e - cargo mutants --in-diff branch.diff -p linkunbound-settings --in-place \ - --exclude-re 'mac::|local_web_file|launchable_file|host::|reaction_to|sent_by_launch_services|platform::|dress_natively|replace is_bundle|relaunch_resident|relay_links|hand_to_the_resident|replace base -> Option|replace address -> String|replace named -> Option> "$GITHUB_OUTPUT" - name: What survived - if: always() && steps.touched.outputs.any == 'yes' + if: always() env: CODE: ${{ steps.run.outputs.code }} TITLE: The lines this branch changed in settings run: bash scripts/mutants-report.sh - uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 - if: always() && steps.touched.outputs.any == 'yes' + if: always() with: name: mutants-branch-settings path: mutants.out/ @@ -227,7 +213,7 @@ jobs: name: window / the lines this branch changed runs-on: ubuntu-24.04 needs: changes - if: github.actor != 'dependabot[bot]' && needs.changes.outputs.mutable == 'true' + if: needs.changes.outputs.window == 'true' timeout-minutes: 60 steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f14f5e0..58970ff 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -22,30 +22,30 @@ env: BUILD_MACOS: "true" jobs: + # Markdown and the picker's style are CI's on main, which the tested job waits for; the notices are read here. gate: - name: Style and prose + name: The notices name what ships runs-on: ubuntu-24.04 timeout-minutes: 15 + env: + TAGGED: ${{ startsWith(github.ref, 'refs/tags/v') }} steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + if: env.TAGGED == 'true' with: persist-credentials: false - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 + if: env.TAGGED == 'true' with: node-version: 22 package-manager-cache: false - - run: npm ci - - run: npm run lint:md - - name: Frontend style - working-directory: app - run: | - npm ci - npm run lint # About carries both files inside the binary, so the tag ships whatever the tree holds. - uses: ./.github/actions/toolchain + if: env.TAGGED == 'true' - name: The notices on main name what this build ships - if: startsWith(github.ref, 'refs/tags/v') + if: env.TAGGED == 'true' run: | + (cd app && npm ci) npm run notices if ! git diff --exit-code THIRD-PARTY-BUNDLED.md THIRD-PARTY-LICENSES.md; then echo "::error::THIRD-PARTY-BUNDLED.md or THIRD-PARTY-LICENSES.md is behind the lockfiles; run npm run notices and land them before tagging" From 8af9d55ef50615e1da05b28fccb5a7a93c182f83 Mon Sep 17 00:00:00 2001 From: rgdevment Date: Sun, 8 Nov 2026 17:35:13 -0300 Subject: [PATCH 2/3] ci: one script says what a branch touched, the Mac weighs host::, and mutants config changes are tried --- .github/workflows/bundle.yml | 14 +------- .github/workflows/ci.yml | 24 +------------ .github/workflows/mutants-sweep.yml | 14 +------- .github/workflows/mutants.yml | 50 +++++++++++---------------- .github/workflows/release.yml | 52 +++++++++++------------------ .github/workflows/rules.yml | 19 +++-------- scripts/mutants-branch.sh | 14 ++++++++ scripts/touched.sh | 42 +++++++++++++++++++++++ 8 files changed, 103 insertions(+), 126 deletions(-) create mode 100755 scripts/mutants-branch.sh create mode 100755 scripts/touched.sh diff --git a/.github/workflows/bundle.yml b/.github/workflows/bundle.yml index e6cd0ad..92d4de6 100644 --- a/.github/workflows/bundle.yml +++ b/.github/workflows/bundle.yml @@ -42,19 +42,7 @@ jobs: - id: look env: BASE: ${{ github.event.pull_request.base.sha }} - run: | - if [ -z "$BASE" ]; then - echo "packaging=true" >> "$GITHUB_OUTPUT" - exit 0 - fi - # release.yml runs none of what is below; actionlint and zizmor in Rules are what read it. - watched='^(app/src-tauri/(nsis/|Info\.plist|tauri\.conf\.json|Cargo\.toml|build\.rs)|scripts/sidecar\.sh|Cargo\.toml$|\.github/workflows/bundle\.yml$)' - from=$(git merge-base "$BASE" HEAD) - if git diff --name-only --diff-filter=d "$from" HEAD | grep -qE "$watched"; then - echo "packaging=true" >> "$GITHUB_OUTPUT" - else - echo "packaging=false" >> "$GITHUB_OUTPUT" - fi + run: bash scripts/touched.sh "$BASE" | tee -a "$GITHUB_OUTPUT" nsis: name: the installer builds diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 575e492..9bd0de8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,7 +17,6 @@ env: RUSTFLAGS: -D warnings jobs: - # Anything not known to stay out of Rust's way counts as Rust, so a new path runs the whole suite. changes: name: what the branch touched runs-on: ubuntu-24.04 @@ -34,29 +33,8 @@ jobs: - id: look env: - EVENT: ${{ github.event_name }} BASE: ${{ github.event.pull_request.base.sha }} - run: | - if [ "$EVENT" != "pull_request" ]; then - printf 'rust=true\npicker=true\ndeps=true\n' >> "$GITHUB_OUTPUT" - exit 0 - fi - aside='^(app/src/|app/(\.gitignore|biome\.json|index\.html|package(-lock)?\.json|stryker\.config\.json|tsconfig(\.node)?\.json|vite\.config\.ts)$|hooks/|packaging/|resources/|(CLA|COMMERCIAL|CONTRIBUTING|PRIVACY|README|SECURITY)\.md$|package(-lock)?\.json$|\.markdownlint-cli2\.jsonc$|\.editorconfig$|\.github/(FUNDING|dependabot)\.yml$|\.github/(not-this-spanish|oversized)\.txt$|\.github/workflows/(bundle|caches|cla|commits|feed|mutants|mutants-sweep|release|rules|update-badge)\.yml$)' - from=$(git merge-base "$BASE" HEAD) - changed=$(git diff --name-only "$from" HEAD) - # The resident embeds the news, so it is Rust's though it lives beside the picker. - first=$( { echo "$changed" | grep -x 'app/src/news.json'; echo "$changed" | grep -vE "$aside"; } \ - | grep -v '^$' | head -1 || true) - [ -n "$first" ] && rust=true || rust=false - echo "rust=$rust" >> "$GITHUB_OUTPUT" - echo "the first path Rust has to answer for: ${first:-none}" - self='^\.github/workflows/ci\.yml$' - picker=false - grep -qE "^app/([^/]+|src/.*)$|$self" <<< "$changed" && picker=true - deps=false - grep -qE "(^|/)(Cargo\.(toml|lock)|package(-lock)?\.json)$|^deny\.toml$|$self" <<< "$changed" && deps=true - printf 'picker=%s\ndeps=%s\n' "$picker" "$deps" >> "$GITHUB_OUTPUT" - echo "the picker: $picker; the dependencies: $deps" + run: bash scripts/touched.sh "$BASE" | tee -a "$GITHUB_OUTPUT" test: name: test / ${{ matrix.os }} diff --git a/.github/workflows/mutants-sweep.yml b/.github/workflows/mutants-sweep.yml index e355989..fe9d7d8 100644 --- a/.github/workflows/mutants-sweep.yml +++ b/.github/workflows/mutants-sweep.yml @@ -16,7 +16,7 @@ env: CARGO_TERM_COLOR: always DESKTOP_LIBS: libgtk-3-dev libayatana-appindicator3-dev libxdo-dev libfontconfig1-dev libfreetype6-dev libxkbcommon-dev libwayland-dev libxcb1-dev NOT_ON_LINUX: "mac::|local_web_file|launchable_file|host::|reaction_to|sent_by_launch_services|platform::|dress_natively|replace is_bundle|relaunch_resident|relay_links|hand_to_the_resident|replace base -> Option|replace address -> String|replace named -> Option Option|replace address -> String|replace named -> Option Option|replace address -> String|replace named -> Option Option|replace address -> String|replace named -> Option Option|replace address -> String|replace named -> Option Option|replace address -> String|replace named -> Option> "$GITHUB_OUTPUT" + printf 'crates=false\nmac=false\nsettings=false\nwindow=false\nstryker=false\n' >> "$GITHUB_OUTPUT" exit 0 fi - from=$(git merge-base "$BASE" HEAD) - touched() { git diff --quiet "$from" HEAD -- "$@" && echo false || echo true; } - { - echo "crates=$(touched crates/linkunbound-core crates/linkunbound-shell)" - echo "mac=$(touched crates)" - echo "settings=$(touched app/src-tauri/src)" - echo "window=$(touched app/src)" - } | tee -a "$GITHUB_OUTPUT" + bash scripts/touched.sh "$BASE" | tee -a "$GITHUB_OUTPUT" crates-on-the-branch: name: crates / the lines this branch changed @@ -70,10 +63,6 @@ jobs: run: git diff "$(git merge-base "$BASE" HEAD)" -- crates/linkunbound-core crates/linkunbound-shell > branch.diff - uses: ./.github/actions/toolchain - - uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 # v2.9.3 - with: - shared-key: workspace - save-if: false - uses: taiki-e/install-action@5488ac5a951645ce95062214902ac4b6bc1a1037 # v2.87.32 with: tool: nextest,cargo-mutants @@ -87,7 +76,7 @@ jobs: id: run run: | set +e - cargo mutants --in-diff branch.diff -p linkunbound-core -p linkunbound-shell -j 2 --exclude-re "$NOT_ON_LINUX" + bash scripts/mutants-branch.sh -p linkunbound-core -p linkunbound-shell -j 2 --exclude-re "$NOT_ON_LINUX" echo "code=$?" >> "$GITHUB_OUTPUT" - name: What survived @@ -103,8 +92,9 @@ jobs: name: mutants-branch-crates path: mutants.out/ retention-days: 7 + if-no-files-found: ignore - # Weighing the core and the picker again here, all of it, outlasted everything else a pull request runs. + # Linux weighs everything it compiles; a Mac adds only what compiles nowhere else. mac-on-the-branch: name: mac / the lines this branch changed runs-on: macos-latest @@ -120,13 +110,9 @@ jobs: - name: What the branch changed in the crates, read with a Mac's eyes env: BASE: ${{ github.event.pull_request.base.sha }} - run: git diff "$(git merge-base "$BASE" HEAD)" -- crates > branch.diff + run: git diff "$(git merge-base "$BASE" HEAD)" -- crates/linkunbound-mac crates/linkunbound-core crates/linkunbound-shell > branch.diff - uses: ./.github/actions/toolchain - - uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 # v2.9.3 - with: - shared-key: workspace - save-if: false - uses: taiki-e/install-action@5488ac5a951645ce95062214902ac4b6bc1a1037 # v2.87.32 with: tool: nextest,cargo-mutants @@ -135,7 +121,7 @@ jobs: id: run run: | set +e - cargo mutants --in-diff branch.diff -p linkunbound-mac -p linkunbound-core -p linkunbound-shell -j 2 \ + bash scripts/mutants-branch.sh -p linkunbound-mac -p linkunbound-core -p linkunbound-shell -j 2 \ --re "^crates/linkunbound-mac/|$MAC_BRANCHES" --exclude-re 'replace forget with' echo "code=$?" >> "$GITHUB_OUTPUT" @@ -172,10 +158,6 @@ jobs: run: git diff "$(git merge-base "$BASE" HEAD)" -- app/src-tauri/src > branch.diff - uses: ./.github/actions/toolchain - - uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 # v2.9.3 - with: - shared-key: workspace - save-if: false - uses: taiki-e/install-action@5488ac5a951645ce95062214902ac4b6bc1a1037 # v2.87.32 with: tool: nextest,cargo-mutants @@ -192,7 +174,7 @@ jobs: id: run run: | set +e - cargo mutants --in-diff branch.diff -p linkunbound-settings --in-place --exclude-re "$NOT_ON_LINUX" + bash scripts/mutants-branch.sh -p linkunbound-settings --in-place --exclude-re "$NOT_ON_LINUX" echo "code=$?" >> "$GITHUB_OUTPUT" - name: What survived @@ -208,6 +190,7 @@ jobs: name: mutants-branch-settings path: mutants.out/ retention-days: 7 + if-no-files-found: ignore window-on-the-branch: name: window / the lines this branch changed @@ -226,6 +209,7 @@ jobs: working-directory: app env: BASE: ${{ github.event.pull_request.base.sha }} + STRYKER: ${{ needs.changes.outputs.stryker }} run: | from=$(git merge-base "$BASE" HEAD) list=$(git diff --unified=0 --relative --diff-filter=d "$from" -- src \ @@ -245,15 +229,16 @@ jobs: }' \ | paste -sd, -) echo "list=$list" >> "$GITHUB_OUTPUT" + if [ -n "$list" ] || [ "$STRYKER" = "true" ]; then echo "any=yes" >> "$GITHUB_OUTPUT"; fi - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 - if: steps.touched.outputs.list != '' + if: steps.touched.outputs.any == 'yes' with: node-version: 22 cache: npm cache-dependency-path: app/package-lock.json - - if: steps.touched.outputs.list != '' + - if: steps.touched.outputs.any == 'yes' working-directory: app run: npm ci @@ -268,6 +253,11 @@ jobs: npx stryker run --mutate "$TOUCHED" echo "::notice::survivors are in the report above and the artifact; this check does not fail on them" + - name: Only the configuration changed, and Stryker still starts with it + if: steps.touched.outputs.list == '' && steps.touched.outputs.any == 'yes' + working-directory: app + run: npx stryker run --dryRunOnly + - uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 if: always() && steps.touched.outputs.list != '' with: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 58970ff..eaa562a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -22,36 +22,6 @@ env: BUILD_MACOS: "true" jobs: - # Markdown and the picker's style are CI's on main, which the tested job waits for; the notices are read here. - gate: - name: The notices name what ships - runs-on: ubuntu-24.04 - timeout-minutes: 15 - env: - TAGGED: ${{ startsWith(github.ref, 'refs/tags/v') }} - steps: - - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - if: env.TAGGED == 'true' - with: - persist-credentials: false - - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 - if: env.TAGGED == 'true' - with: - node-version: 22 - package-manager-cache: false - # About carries both files inside the binary, so the tag ships whatever the tree holds. - - uses: ./.github/actions/toolchain - if: env.TAGGED == 'true' - - name: The notices on main name what this build ships - if: env.TAGGED == 'true' - run: | - (cd app && npm ci) - npm run notices - if ! git diff --exit-code THIRD-PARTY-BUNDLED.md THIRD-PARTY-LICENSES.md; then - echo "::error::THIRD-PARTY-BUNDLED.md or THIRD-PARTY-LICENSES.md is behind the lockfiles; run npm run notices and land them before tagging" - exit 1 - fi - tested: name: Tested when it landed runs-on: ubuntu-24.04 @@ -100,11 +70,11 @@ jobs: ran: a tag belongs on a commit that reached main and was tested there" exit 1 + # Markdown and the picker's style are CI's on main, which the tested job waits for; the notices are read here. version: name: Resolve the version - needs: [gate] runs-on: ubuntu-24.04 - timeout-minutes: 5 + timeout-minutes: 15 outputs: version: ${{ steps.resolve.outputs.version }} prerelease: ${{ steps.resolve.outputs.prerelease }} @@ -231,6 +201,24 @@ jobs: VERSION: ${{ steps.resolve.outputs.version }} run: bash scripts/news.sh "$VERSION" + - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 + if: startsWith(github.ref, 'refs/tags/v') + with: + node-version: 22 + package-manager-cache: false + - uses: ./.github/actions/toolchain + if: startsWith(github.ref, 'refs/tags/v') + # About carries both files inside the binary, so the tag ships whatever the tree holds. + - name: The notices on main name what this build ships + if: startsWith(github.ref, 'refs/tags/v') + run: | + (cd app && npm ci) + npm run notices + if ! git diff --exit-code THIRD-PARTY-BUNDLED.md THIRD-PARTY-LICENSES.md; then + echo "::error::THIRD-PARTY-BUNDLED.md or THIRD-PARTY-LICENSES.md is behind the lockfiles; run npm run notices and land them before tagging" + exit 1 + fi + bundle-windows: name: linkunbound-windows-installer needs: [version] diff --git a/.github/workflows/rules.yml b/.github/workflows/rules.yml index 1f49cc0..41df729 100644 --- a/.github/workflows/rules.yml +++ b/.github/workflows/rules.yml @@ -219,27 +219,16 @@ jobs: - id: look env: BASE: ${{ github.event.pull_request.base.sha }} - run: | - if [ -z "$BASE" ]; then - echo "touched=true" >> "$GITHUB_OUTPUT" - exit 0 - fi - watched='^(scripts/third-party\.mjs|THIRD-PARTY-(BUNDLED|LICENSES)\.md|scripts/licences/.*|Cargo\.(lock|toml)|.*/Cargo\.toml|app/package(-lock)?\.json|app/src/.*|app/index\.html|app/vite\.config\.ts|\.github/workflows/rules\.yml)$' - from=$(git merge-base "$BASE" HEAD) - if git diff --name-only --diff-filter=d "$from" HEAD | grep -qE "$watched"; then - echo "touched=true" >> "$GITHUB_OUTPUT" - else - echo "touched=false" >> "$GITHUB_OUTPUT" - fi - - if: steps.look.outputs.touched == 'true' + run: bash scripts/touched.sh "$BASE" | tee -a "$GITHUB_OUTPUT" + - if: steps.look.outputs.notices == 'true' uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 with: node-version: 22 package-manager-cache: false - - if: steps.look.outputs.touched == 'true' + - if: steps.look.outputs.notices == 'true' uses: ./.github/actions/toolchain - name: Regenerated, they match the copy in the tree - if: steps.look.outputs.touched == 'true' + if: steps.look.outputs.notices == 'true' run: | (cd app && npm ci) npm run notices diff --git a/scripts/mutants-branch.sh b/scripts/mutants-branch.sh new file mode 100755 index 0000000..abdbd10 --- /dev/null +++ b/scripts/mutants-branch.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env bash +set -uo pipefail + +if [ -s branch.diff ]; then + cargo mutants --in-diff branch.diff "$@" + exit $? +fi + +listed=$(cargo mutants --list "$@") || exit $? +if [ -z "$listed" ]; then + echo "::error::only the configuration changed, and it names no mutant at all" + exit 1 +fi +echo "only the configuration changed; it names $(grep -c . <<< "$listed") mutants" diff --git a/scripts/touched.sh b/scripts/touched.sh new file mode 100755 index 0000000..cdc21ad --- /dev/null +++ b/scripts/touched.sh @@ -0,0 +1,42 @@ +#!/usr/bin/env bash +set -euo pipefail + +base=${1:-} +flags=(rust picker deps packaging notices crates mac settings window stryker) + +everything() { + printf '%s=true\n' "${flags[@]}" + exit 0 +} + +[ -n "$base" ] || everything + +from=$(git merge-base "$base" HEAD) +changed=$(git diff --name-only "$from" HEAD) +present=$(git diff --name-only --diff-filter=d "$from" HEAD) + +grep -qx 'scripts/touched\.sh' <<< "$changed" && everything + +either() { grep -qE "$1" <<< "$2" && echo true || echo false; } + +# A path not known to stay out of Rust's way counts as Rust, so a new one runs the whole suite. +outside_rust='^(app/src/|app/(\.gitignore|biome\.json|index\.html|package(-lock)?\.json|stryker\.config\.json|tsconfig(\.node)?\.json|vite\.config\.ts)$|hooks/|packaging/|resources/|(CLA|COMMERCIAL|CONTRIBUTING|PRIVACY|README|SECURITY)\.md$|package(-lock)?\.json$|\.markdownlint-cli2\.jsonc$|\.editorconfig$|\.github/(FUNDING|dependabot)\.yml$|\.github/(not-this-spanish|oversized)\.txt$|\.github/workflows/(bundle|caches|cla|commits|feed|mutants|mutants-sweep|release|rules|update-badge)\.yml$)' +news_the_resident_embeds='app/src/news\.json' +first=$( { grep -x "$news_the_resident_embeds" <<< "$changed"; grep -vE "$outside_rust" <<< "$changed"; } \ + | grep -v '^$' | head -1 || true) +echo "the first path Rust has to answer for: ${first:-none}" >&2 + +ci='^\.github/workflows/ci\.yml$' +mutants='^(\.github/workflows/mutants\.yml|\.cargo/mutants\.toml)$' +stryker='^(\.github/workflows/mutants\.yml|app/stryker\.config\.json)$' + +echo "rust=$([ -n "$first" ] && echo true || echo false)" +echo "picker=$(either "^app/([^/]+|src/.*)$|$ci" "$changed")" +echo "deps=$(either "(^|/)(Cargo\.(toml|lock)|package(-lock)?\.json)$|^deny\.toml$|$ci" "$changed")" +echo "packaging=$(either '^(app/src-tauri/(nsis/|Info\.plist|tauri\.conf\.json|Cargo\.toml|build\.rs)|scripts/sidecar\.sh|Cargo\.toml$|\.github/workflows/bundle\.yml$)' "$present")" +echo "notices=$(either '^(scripts/third-party\.mjs|THIRD-PARTY-(BUNDLED|LICENSES)\.md|scripts/licences/.*|Cargo\.(lock|toml)|.*/Cargo\.toml|app/package(-lock)?\.json|app/src/.*|app/index\.html|app/vite\.config\.ts|\.github/workflows/rules\.yml)$' "$present")" +echo "crates=$(either "^crates/linkunbound-(core|shell)/|$mutants" "$changed")" +echo "mac=$(either "^crates/linkunbound-(mac|core|shell)/|$mutants" "$changed")" +echo "settings=$(either "^app/src-tauri/src/|$mutants" "$changed")" +echo "window=$(either "^app/src/|$stryker" "$changed")" +echo "stryker=$(either "$stryker" "$changed")" From d1ce90366c01f35c1f8bbc4430cef68ab7b9e815 Mon Sep 17 00:00:00 2001 From: rgdevment Date: Sun, 8 Nov 2026 18:57:13 -0300 Subject: [PATCH 3/3] ci: Stryker runs in place so the notices test resolves, and Dependabot is told by the pull request author --- .github/workflows/ci.yml | 2 +- .github/workflows/mutants-sweep.yml | 3 ++- .github/workflows/mutants.yml | 5 +++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9bd0de8..9b5f2ab 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -143,7 +143,7 @@ jobs: - run: npm run lint - run: npm run build # Coverage, which runs the tests everywhere else, skips Dependabot's bumps. - - if: github.actor == 'dependabot[bot]' + - if: github.event.pull_request.user.login == 'dependabot[bot]' run: npm test prose: diff --git a/.github/workflows/mutants-sweep.yml b/.github/workflows/mutants-sweep.yml index fe9d7d8..d78066c 100644 --- a/.github/workflows/mutants-sweep.yml +++ b/.github/workflows/mutants-sweep.yml @@ -205,6 +205,7 @@ jobs: path: mutants-elsewhere/mutants.out/ retention-days: 14 + # Stryker runs in place: the notices markdown.test.ts reads live outside app/, where no sandbox reaches. window: name: window / shard ${{ matrix.shard }} of 4 runs-on: ubuntu-24.04 @@ -249,7 +250,7 @@ jobs: }' \ | paste -sd, -) echo "$list" - npx stryker run --mutate "$list" --concurrency 4 \ + npx stryker run --inPlace --mutate "$list" --concurrency 4 \ --reporters progress-append-only,clear-text,json - uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 diff --git a/.github/workflows/mutants.yml b/.github/workflows/mutants.yml index 688a17f..0b5e92d 100644 --- a/.github/workflows/mutants.yml +++ b/.github/workflows/mutants.yml @@ -192,6 +192,7 @@ jobs: retention-days: 7 if-no-files-found: ignore + # Stryker runs in place: the notices markdown.test.ts reads live outside app/, where no sandbox reaches. window-on-the-branch: name: window / the lines this branch changed runs-on: ubuntu-24.04 @@ -250,13 +251,13 @@ jobs: env: TOUCHED: ${{ steps.touched.outputs.list }} run: | - npx stryker run --mutate "$TOUCHED" + npx stryker run --inPlace --mutate "$TOUCHED" echo "::notice::survivors are in the report above and the artifact; this check does not fail on them" - name: Only the configuration changed, and Stryker still starts with it if: steps.touched.outputs.list == '' && steps.touched.outputs.any == 'yes' working-directory: app - run: npx stryker run --dryRunOnly + run: npx stryker run --inPlace --dryRunOnly - uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 if: always() && steps.touched.outputs.list != ''