diff --git a/.github/workflows/bundle.yml b/.github/workflows/bundle.yml index ce1c50b..92d4de6 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: @@ -43,18 +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 - watched='^(app/src-tauri/(nsis/|Info\.plist|tauri\.conf\.json|Cargo\.toml|build\.rs)|scripts/sidecar\.sh|Cargo\.toml$|\.github/workflows/(bundle|release)\.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 4cd1986..9b5f2ab 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,13 +17,14 @@ 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 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: @@ -32,22 +33,8 @@ jobs: - id: look env: - EVENT: ${{ github.event_name }} BASE: ${{ github.event.pull_request.base.sha }} - run: | - if [ "$EVENT" != "pull_request" ]; then - echo "rust=true" >> "$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}" + run: bash scripts/touched.sh "$BASE" | tee -a "$GITHUB_OUTPUT" test: name: test / ${{ matrix.os }} @@ -123,6 +110,8 @@ jobs: lint: name: fmt + needs: changes + if: needs.changes.outputs.rust == 'true' runs-on: ubuntu-24.04 timeout-minutes: 10 steps: @@ -134,6 +123,8 @@ jobs: picker: name: frontend + needs: changes + if: needs.changes.outputs.picker == 'true' runs-on: ubuntu-24.04 timeout-minutes: 20 defaults: @@ -151,6 +142,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.event.pull_request.user.login == 'dependabot[bot]' + run: npm test prose: name: markdown @@ -168,8 +162,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 +208,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 +247,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..d78066c 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 @@ -68,10 +66,6 @@ jobs: with: persist-credentials: false - 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 @@ -86,7 +80,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 @@ -116,10 +110,6 @@ jobs: with: persist-credentials: false - 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 @@ -137,7 +127,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 +171,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" @@ -215,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 @@ -259,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 d92cf26..0b5e92d 100644 --- a/.github/workflows/mutants.yml +++ b/.github/workflows/mutants.yml @@ -12,6 +12,8 @@ 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\nstryker=false\n' >> "$GITHUB_OUTPUT" + exit 0 fi + bash scripts/touched.sh "$BASE" | 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 +58,48 @@ 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 + if-no-files-found: ignore + # 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 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 +108,43 @@ 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/linkunbound-mac 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: 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' + 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" - 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,64 +153,51 @@ 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/ 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 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 @@ -240,6 +210,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 \ @@ -259,15 +230,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 @@ -279,9 +251,14 @@ 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 --inPlace --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 f14f5e0..eaa562a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -22,36 +22,6 @@ env: BUILD_MACOS: "true" jobs: - gate: - name: Style and prose - runs-on: ubuntu-24.04 - timeout-minutes: 15 - steps: - - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - with: - persist-credentials: false - - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 - 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 - - name: The notices on main name what this build ships - if: startsWith(github.ref, 'refs/tags/v') - run: | - 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")"