~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.
Python academiaanthropicarxivbravedeep-researchencryptionhome-automationhomeserverlocallocal-deep-researchlocal-llmmistralollamaopenaipubmedresearchresearch-toolretrieval-augmented-generationsearxngself-hosted
ci(deps): open fewer dependency PRs by grouping updates (#7520)
LearningCircuit364db82d5f07
diff --git a/.github/dependabot.yml b/.github/dependabot.ymlindex d4af300944..fb684f27ac 100644--- a/.github/dependabot.yml+++ b/.github/dependabot.yml@@ -41,6 +41,21 @@ updates:# playwright AND patchright admits pyee 14.- dependency-name: "pyee"versions: [">=14"]+ # One PR per weekly run for every minor/patch bump and one for security fixes,+ # instead of one PR per dependency. Majors stay individual PRs so each+ # breaking upgrade is reviewed on its own.+ groups:+ python-minor-and-patch:+ applies-to: version-updates+ patterns:+ - "*"+ update-types:+ - "minor"+ - "patch"+ python-security:+ applies-to: security-updates+ patterns:+ - "*"# These .in/.txt pairs use pip-compile, including hash regeneration for# transitive updates. Bootstrap requirements remain in the root pip job.@@ -63,6 +78,21 @@ updates:commit-message:prefix: "chore"include: "scope"+ # One PR per weekly run for every minor/patch bump and one for security fixes,+ # instead of one PR per dependency. Majors stay individual PRs so each+ # breaking upgrade is reviewed on its own.+ groups:+ requirements-minor-and-patch:+ applies-to: version-updates+ patterns:+ - "*"+ update-types:+ - "minor"+ - "patch"+ requirements-security:+ applies-to: security-updates+ patterns:+ - "*"# JavaScript dependencies- package-ecosystem: "npm"@@ -181,6 +211,19 @@ updates:applies-to: security-updatespatterns:- "github/codeql-action*"+ # Catch-alls for every other action. They must stay BELOW the+ # codeql-action groups (first match wins). Action bumps are usually+ # major-tag moves (v6 -> v7) of SHA-pinned refs, so no update-types+ # filter: all version updates arrive as one PR, security fixes as+ # another.+ github-actions:+ applies-to: version-updates+ patterns:+ - "*"+ github-actions-security:+ applies-to: security-updates+ patterns:+ - "*"- package-ecosystem: dockerdirectory: /diff --git a/.github/workflows/README.md b/.github/workflows/README.mdindex 65c29532ed..9c7ac1e6eb 100644--- a/.github/workflows/README.md+++ b/.github/workflows/README.md@@ -52,7 +52,8 @@ Automatically updates NPM dependencies across all package.json files in the proj2. **Security Fixes**: Automatically fixes moderate+ severity vulnerabilities with `npm audit fix`3. **Dependency Updates**: Updates all dependencies to latest compatible versions with `npm update`4. **Testing**: Runs relevant tests to ensure updates don't break functionality-5. **Pull Request**: Creates one automated PR per directory with changes+5. **Pull Request**: Opens **one** combined PR per run covering every+ directory whose update, install, build and test passed### Directories ManagedDiscovered dynamically: a `discover` job finds every directory containing a@@ -62,11 +63,20 @@ fans out one matrix leg per directory. By convention the repo root buildslockfile directory fails the discover job until explicitly classified inthe workflow.+The legs run in parallel with `contents: read` only. A leg that passes+uploads a short-lived `npm-update-<slug>` artifact (`.` → `root`, `/` → `-`):+a tarball of that directory's `package.json`/`package-lock.json` when they+changed, or an `unchanged` marker. A failed leg uploads nothing. The final+`pr` job (the only job with write permissions) runs even when some legs+failed, checks that each archive holds nothing but those two files for a+discovered directory (no absolute paths, `..`, links or extra files),+extracts them, and opens a single PR. Its body lists the updated+directories and any directory whose leg did not pass. If nothing changed,+no PR is opened.+### Branch Strategy-- Creates branch: `update-npm-dependencies-{run_number}-{directory-slug}`,- one per changed directory (`.` → `root`, `/` → `-`; e.g.- `update-npm-dependencies-42-tests-ui_tests`) so concurrent matrix legs- never race on a shared ref+- Creates branch: `update-npm-dependencies-{run_number}` (one per run,+ e.g. `update-npm-dependencies-42`), titled `🤖 Update npm dependencies`- Targets: `main` branch- Labels: `maintenance`- Reviewers: `djpetti,HashedViking,LearningCircuit`diff --git a/.github/workflows/update-npm-dependencies.yml b/.github/workflows/update-npm-dependencies.ymlindex ac9e06f50b..8542b1d6c8 100644--- a/.github/workflows/update-npm-dependencies.yml+++ b/.github/workflows/update-npm-dependencies.yml@@ -35,10 +35,12 @@ jobs:# unrecognized package enter the matrix with no build/test is the# exact coverage gap this job exists to prevent; add explicit# classification above before such a dir can be swept.- # - every entry also carries a "slug": the per-directory PR-branch- # suffix ("." -> "root", "/" -> "-"). Slugs outside the conservative- # ASCII policy, slugs that would make an invalid Git ref, and collisions- # between two dirs' slugs fail this job (see the guards below).+ # - every entry also carries a "slug" ("." -> "root", "/" -> "-"): it+ # names the leg's result artifact (npm-update-<slug>) and is how the+ # `pr` job maps an artifact back to its directory. Slugs outside the+ # conservative ASCII policy, slugs that would make an invalid Git ref,+ # and collisions between two dirs' slugs fail this job (see the guards+ # below).# - root-level dot-dirs (./.git, ./.venv, ./.claude, ./.github) are# pruned entirely (see below), so a lockfile under a NEW root# dot-dir is silently exempt from the fail-loud guard above —@@ -104,15 +106,15 @@ jobs:echo "::error::No package-lock.json files discovered — matrix would be empty"exit 1fi- # Reject slugs that would make create-pull-request fail when it- # creates update-npm-dependencies-${run_number}-${slug}. The ASCII- # charset is intentionally stricter than Git: unusual directory- # names should be renamed instead of widening the branch policy.- # The remaining checks cover Git-invalid values that pass the- # charset: "..", a trailing ".", and a ".lock" suffix. The 200-byte- # ceiling also leaves room within the common 255-byte ref-component- # limit for the fixed prefix, run number, and Git's temporary- # ".lock" suffix.+ # Reject slugs that are unsafe as the artifact-name suffix in+ # npm-update-${slug}. The policy predates the single combined PR+ # (slugs used to be per-directory branch suffixes) and is kept as+ # a conservative identifier policy: the ASCII charset excludes+ # every character upload-artifact forbids in names, unusual+ # directory names should be renamed instead of widening it, and+ # the Git-ref rules ("..", a trailing ".", a ".lock" suffix, the+ # 200-byte ceiling) keep the slug usable in a ref should it ever+ # be needed there again.MAX_BRANCH_SLUG_LENGTH=200INVALID_SLUGS=$(echo "$MATRIX" | jq -c \--argjson max_slug_length "$MAX_BRANCH_SLUG_LENGTH" '[@@ -126,7 +128,7 @@ jobs:)]')if [ "$(echo "$INVALID_SLUGS" | jq 'length')" != "0" ]; then- echo "::error::Invalid branch slug(s) — rename these lockfile directories:"+ echo "::error::Invalid directory slug(s) — rename these lockfile directories:"echo "$INVALID_SLUGS" | jq -r '.[] | " - path=" + (.path | @json) + ", slug=" + (.slug | @json)'exit 1fi@@ -139,13 +141,15 @@ jobs:while IFS= read -r d; do echo " - $d"; done <<< "$UNKNOWN"exit 1fi- # Slugs must be unique — each maps to a PR branch name. A collision- # (e.g. tests/a-b vs tests/a/b, both -> tests-a-b) would put two- # legs on one branch, reintroducing the shared-ref race fixed in- # PR #5090. Fail loud so the colliding dir gets renamed instead.+ # Slugs must be unique — each names one leg's result artifact and+ # maps it back to its directory in the pr job. A collision (e.g.+ # tests/a-b vs tests/a/b, both -> tests-a-b) would make two legs+ # upload the same artifact name (the second upload fails) and make+ # the artifact's directory ambiguous. Fail loud so the colliding dir+ # gets renamed instead.DUPES=$(echo "$MATRIX" | jq -r '[.[].slug] | group_by(.) | map(select(length > 1) | .[0]) | .[]')if [ -n "$DUPES" ]; then- echo "::error::Colliding branch slugs — these dirs would share a PR branch:"+ echo "::error::Colliding directory slugs — these dirs would share one result artifact:"while IFS= read -r s; doecho " slug '$s' from:"echo "$MATRIX" | jq -r --arg s "$s" '.[] | select(.slug == $s) | " - " + .path'@@ -156,13 +160,19 @@ jobs:echo "Discovered $(echo "$MATRIX" | jq 'length') dir(s):"echo "$MATRIX" | jq -r '.[].path'++ # One leg per lockfile dir: update, install, build and test in parallel.+ # Legs only READ the repo. Each leg that passes uploads one artifact named+ # npm-update-<slug>: a tarball of the dir's package.json/package-lock.json+ # when they changed, or an "unchanged" marker otherwise. A failed leg+ # uploads nothing, which is how the `pr` job tells failures apart. The+ # `pr` job alone holds write permissions and opens ONE PR for the run.update:name: 📦 Update with NPMneeds: [discover]runs-on: ubuntu-latestpermissions:- contents: write # Required for creating PRs- pull-requests: write # Required for creating PRs+ contents: readstrategy:# Legs are independent per-directory sweeps: one dir's failure must not# cancel the others (fail-fast cancelled 5 of 8 legs in run #36,@@ -261,36 +271,213 @@ jobs:if git diff --quiet package.json package-lock.json; thenecho "changed=false" >> "$GITHUB_OUTPUT"else- {- echo "changed=true"- # Use $NPM_DIR (env) rather than a direct GitHub-Actions- # expression so a path can never be expanded as a shell expr.- echo "path=$NPM_DIR"- } >> "$GITHUB_OUTPUT"+ echo "changed=true" >> "$GITHUB_OUTPUT"fi- - name: 📝 Create pull request- uses: peter-evans/create-pull-request@5f6978faf089d4d20b00c7766989d076bb2fc7f1 # v8.1.1- if: steps.verify-changed-files.outputs.changed == 'true'+ # Runs only when every earlier step passed, so a lockfile whose+ # install, build or test failed is never handed to the PR job. The+ # tarball keeps the repo-relative path (upload-artifact would strip+ # the common ancestor of plain files) and holds nothing but the two+ # manifests; the pr job re-validates that before extracting.+ - name: 🗜️ Pack updated manifests+ id: pack+ env:+ NPM_DIR: ${{ matrix.npm_directory.path }}+ CHANGED: ${{ steps.verify-changed-files.outputs.changed }}+ OUT_DIR: ${{ runner.temp }}/npm-update+ run: |+ set -euo pipefail+ rm -rf "$OUT_DIR"+ mkdir -p "$OUT_DIR"+ if [ "$CHANGED" != "true" ]; then+ echo "unchanged" > "$OUT_DIR/unchanged"+ exit 0+ fi+ if [ "$NPM_DIR" = "." ]; then prefix=""; else prefix="$NPM_DIR/"; fi+ files=()+ for name in package.json package-lock.json; do+ file="$prefix$name"+ if [ -f "$file" ] && [ ! -L "$file" ]; then+ files+=("$file")+ fi+ done+ if [ "${#files[@]}" -eq 0 ]; then+ echo "::error::No package.json/package-lock.json to pack in $NPM_DIR"+ exit 1+ fi+ tar --create --format=gnu --no-recursion \+ --file "$OUT_DIR/update.tar" -- "${files[@]}"+ tar --list --file "$OUT_DIR/update.tar"++ - name: ⬆️ Upload leg result+ uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2+ with:+ name: npm-update-${{ matrix.npm_directory.slug }}+ path: ${{ runner.temp }}/npm-update/+ retention-days: 1+ if-no-files-found: error++ # Collect every leg's result and open ONE pull request for the run. Runs+ # even when some legs failed so the other dirs' updates still land; the+ # PR body names the dirs whose leg failed. Skipped on cancellation and+ # when discovery failed (there is no matrix to validate against).+ pr:+ name: 📝 Open combined PR+ needs: [discover, update]+ if: ${{ !cancelled() && needs.discover.result == 'success' }}+ runs-on: ubuntu-latest+ permissions:+ contents: write # Required for creating PRs+ pull-requests: write # Required for creating PRs+ steps:+ - name: Harden the runner (Audit all outbound calls)+ uses: step-security/harden-runner@ccd8616d44fd3846e67624a50d5aad6d37bf2d25 # v2.22.1with:- branch: update-npm-dependencies-${{ github.run_number }}-${{ matrix.npm_directory.slug }}- title: 🤖 Update dependencies (${{ steps.verify-changed-files.outputs.path }})- body: |- This PR updates dependencies to their latest compatible versions.+ egress-policy: audit- **Updated directory:** `${{ steps.verify-changed-files.outputs.path }}`+ - name: 📰 Checkout+ uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1+ with:+ persist-credentials: false+ ref: main- **Changes include:**- - Security vulnerability fixes (moderate severity and above)- - Compatible version updates for dependencies- - Updated lock files for reproducible builds+ - name: ⬇️ Download leg results+ uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2+ with:+ pattern: npm-update-*+ path: ${{ runner.temp }}/npm-artifacts+ merge-multiple: false- This PR was created by the Dependency Update Bot.+ # Legs run third-party npm install/build code, so their artifacts are+ # untrusted. Each artifact is matched to a discover matrix entry by+ # slug and must hold exactly one regular file: "unchanged", or an+ # "update.tar" whose members are only regular files named exactly+ # <dir>/package.json or <dir>/package-lock.json for that entry's dir+ # (so no absolute paths, "..", links or extra files). Only then are+ # those named members extracted at the repo root.+ - name: 🔎 Validate and apply updates+ id: apply+ env:+ MATRIX: ${{ needs.discover.outputs.matrix }}+ UPDATE_RESULT: ${{ needs.update.result }}+ ARTIFACTS_DIR: ${{ runner.temp }}/npm-artifacts+ BODY_FILE: ${{ runner.temp }}/npm-pr-body.md+ RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}+ run: |+ set -euo pipefail+ shopt -s nullglob dotglob+ mkdir -p "$ARTIFACTS_DIR"+ # Every artifact directory must belong to a discovered slug.+ for artifact in "$ARTIFACTS_DIR"/*; do+ name=${artifact##*/}+ slug=${name#npm-update-}+ if [ "$slug" = "$name" ] || [ ! -d "$artifact" ] || [ -L "$artifact" ] \+ || ! jq -e --arg s "$slug" 'any(.[]; .slug == $s)' <<< "$MATRIX" > /dev/null; then+ echo "::error::Unexpected artifact entry: $name"+ exit 1+ fi+ done+ updated=()+ unchanged=()+ failed=()+ while IFS= read -r -d '' path && IFS= read -r -d '' slug; do+ artifact="$ARTIFACTS_DIR/npm-update-$slug"+ if [ ! -d "$artifact" ]; then+ failed+=("$path")+ continue+ fi+ entries=("$artifact"/*)+ if [ "${#entries[@]}" -ne 1 ] || [ ! -f "${entries[0]}" ] || [ -L "${entries[0]}" ]; then+ echo "::error::Artifact for $path must contain exactly one regular file"+ exit 1+ fi+ case "${entries[0]##*/}" in+ unchanged)+ unchanged+=("$path")+ continue+ ;;+ update.tar) ;;+ *)+ echo "::error::Unexpected file in artifact for $path: ${entries[0]##*/}"+ exit 1+ ;;+ esac+ tarball="${entries[0]}"+ if [ "$path" = "." ]; then prefix=""; else prefix="$path/"; fi+ # --quoting-style=escape keeps a newline inside a member name+ # from splitting it into two plausible-looking lines.+ mapfile -t members < <(tar --list --quoting-style=escape --file "$tarball")+ mapfile -t types < <(tar --list --verbose --quoting-style=escape --file "$tarball" | cut -c1)+ if [ "${#members[@]}" -eq 0 ] || [ "${#members[@]}" -ne "${#types[@]}" ]; then+ echo "::error::Archive for $path is empty or unreadable"+ exit 1+ fi+ if [ "$(printf '%s\n' "${members[@]}" | sort -u | wc -l)" -ne "${#members[@]}" ]; then+ echo "::error::Archive for $path repeats a member"+ exit 1+ fi+ for i in "${!members[@]}"; do+ member=${members[$i]}+ if [ "${types[$i]}" != "-" ]; then+ echo "::error::Archive for $path has a non-regular member: $member"+ exit 1+ fi+ if [ "$member" != "${prefix}package.json" ] && [ "$member" != "${prefix}package-lock.json" ]; then+ echo "::error::Archive for $path has a disallowed member: $member"+ exit 1+ fi+ done+ tar --extract --no-same-owner --no-same-permissions \+ --file "$tarball" -- "${members[@]}"+ updated+=("$path")+ done < <(jq -j '.[] | .path, "\u0000", .slug, "\u0000"' <<< "$MATRIX")++ {+ echo "This PR updates npm dependencies to their latest compatible versions in every directory whose update, install, build and test passed."+ echo+ echo "**Changes include:**"+ echo "- Security vulnerability fixes (moderate severity and above)"+ echo "- Compatible version updates for dependencies"+ echo "- Updated lock files for reproducible builds"+ echo+ echo "**Updated directories:**"+ if [ "${#updated[@]}" -eq 0 ]; then echo "- (none)"; fi+ for d in "${updated[@]}"; do echo "- \`$d\`"; done+ if [ "${#failed[@]}" -gt 0 ]; then+ echo+ echo "**Not included — the update, install, build or test did not pass (see [the workflow run]($RUN_URL)):**"+ for d in "${failed[@]}"; do echo "- \`$d\`"; done+ fi+ echo+ echo "This PR was created by the Dependency Update Bot."+ } > "$BODY_FILE"+ cat "$BODY_FILE" >> "${GITHUB_STEP_SUMMARY:-/dev/null}"++ echo "Updated: ${#updated[@]}, unchanged: ${#unchanged[@]}, failed: ${#failed[@]} (update job: $UPDATE_RESULT)"+ if [ "${#failed[@]}" -gt 0 ]; then+ echo "::warning::npm update did not pass for ${#failed[@]} lockfile dir(s); they are left out of the PR"+ fi+ if [ "${#updated[@]}" -gt 0 ]; then+ echo "updated=true" >> "$GITHUB_OUTPUT"+ else+ echo "updated=false" >> "$GITHUB_OUTPUT"+ echo "No directory has updates to propose — skipping PR creation."+ fi++ - name: 📝 Create pull request+ uses: peter-evans/create-pull-request@5f6978faf089d4d20b00c7766989d076bb2fc7f1 # v8.1.1+ if: steps.apply.outputs.updated == 'true'+ with:+ branch: update-npm-dependencies-${{ github.run_number }}+ title: 🤖 Update npm dependencies+ body-path: ${{ runner.temp }}/npm-pr-body.mdsign-commits: trueadd-paths: |- ${{ steps.verify-changed-files.outputs.path }}/package.json- ${{ steps.verify-changed-files.outputs.path }}/package-lock.json- commit-message: 🤖 Update dependencies (${{ steps.verify-changed-files.outputs.path }})+ package.json+ package-lock.json+ **/package.json+ **/package-lock.json+ commit-message: 🤖 Update npm dependencieslabels: maintenancedraft: falsebase: maindiff --git a/changelog.d/+fewer-dependency-prs.misc.md b/changelog.d/+fewer-dependency-prs.misc.mdnew file mode 100644index 0000000000..edd1a88115--- /dev/null+++ b/changelog.d/+fewer-dependency-prs.misc.md@@ -0,0 +1 @@+Dependency bots open fewer PRs while still upgrading to the latest versions. The weekly npm sweep still updates, installs, builds and tests every lockfile directory in parallel, but the legs are now read-only and hand their `package.json`/`package-lock.json` to a final job that validates each archive (only those two files, only for a discovered directory) and opens one combined PR per run, listing any directory whose leg failed. Dependabot now groups pip (`/` and `/requirements`) minor and patch updates into one PR per directory and security updates into another, with majors still individual, and groups all GitHub Actions updates (after the codeql-action lockstep groups) into one PR plus one security PR.diff --git a/docs/CI_CD_INFRASTRUCTURE.md b/docs/CI_CD_INFRASTRUCTURE.mdindex 2753dda717..85f7048381 100644--- a/docs/CI_CD_INFRASTRUCTURE.md+++ b/docs/CI_CD_INFRASTRUCTURE.md@@ -115,7 +115,7 @@ pre-commit install-hooks|----------|---------|---------|| `dependency-review.yml` | PR | Review dependency changes || `update-dependencies.yml` | Schedule | Auto-update Python deps |-| `update-npm-dependencies.yml` | Schedule | Auto-update npm deps |+| `update-npm-dependencies.yml` | Schedule | Auto-update npm deps (one combined PR per run) || `update-precommit-hooks.yml` | Schedule | Update pre-commit hooks || `validate-image-pinning.yml` | PR, push | Verify Docker image pins |@@ -160,13 +160,14 @@ pre-commit install-hooksDependabot automatically creates PRs for dependency updates:-| Ecosystem | Directories | Schedule |-|-----------|-------------|----------|-| Python (pip) | `/` | Weekly (Monday 04:00) |-| npm | `/` | Weekly (Monday 04:00) |-| npm (test dirs) | `/tests/*` | Weekly (Tuesday 04:00) |-| GitHub Actions | `/` | Weekly |-| Docker | `/` | Daily |+| Ecosystem | Directories | Schedule | Grouping |+|-----------|-------------|----------|----------|+| Python (pip) | `/` | Weekly (Monday 04:00) | One minor+patch PR, one security PR; majors individual |+| Python (pip-compile) | `/requirements` | Weekly (Monday 04:00) | One minor+patch PR, one security PR; majors individual |+| npm | `/` | Weekly (Monday 04:00) | vitest lockstep group; one minor+patch PR, one security PR |+| npm (test dirs) | `/tests/*` | Weekly (Tuesday 04:00) | One minor+patch PR, one security PR |+| GitHub Actions | `/` | Weekly | codeql-action lockstep group; one PR for all other actions, one security PR |+| Docker | `/` | Daily | None |---diff --git a/tests/ci/test_dependabot_config.py b/tests/ci/test_dependabot_config.pyindex 62119f3dbc..0e15dec1d0 100644--- a/tests/ci/test_dependabot_config.py+++ b/tests/ci/test_dependabot_config.py@@ -96,6 +96,79 @@ def test_npm_minor_patch_and_security_updates_are_grouped():)+def _entries(ecosystem):+ config = yaml.safe_load(DEPENDABOT_CONFIG.read_text(encoding="utf-8"))+ return [+ update+ for update in config["updates"]+ if update["package-ecosystem"] == ecosystem+ ]+++ ("directory", "prefix"),+ [("/", "python"), ("/requirements", "requirements")],+)+def test_pip_minor_patch_and_security_updates_are_grouped(directory, prefix):+ """Each pip directory gets one minor+patch PR and one security PR.++ Majors are deliberately outside every version-updates group, so each+ breaking upgrade still arrives as its own PR.+ """+ entry = next(+ entry for entry in _entries("pip") if entry["directory"] == directory+ )+ assert list(entry["groups"]) == [+ f"{prefix}-minor-and-patch",+ f"{prefix}-security",+ ]+ _assert_group(+ entry,+ f"{prefix}-minor-and-patch",+ applies_to="version-updates",+ update_types={"minor", "patch"},+ )+ _assert_group(entry, f"{prefix}-security", applies_to="security-updates")+++def test_pip_grouping_keeps_existing_filters():+ root, requirements = (+ next(e for e in _entries("pip") if e["directory"] == d)+ for d in ("/", "/requirements")+ )+ assert {i["dependency-name"] for i in root["ignore"]} >= {+ "faiss-cpu",+ "pyee",+ }+ assert "requirements/pip-vendor-refresh.txt" in root["exclude-paths"]+ assert "pip-vendor-refresh.txt" in requirements["exclude-paths"]+ assert requirements["allow"] == [{"dependency-type": "all"}]+++def test_github_actions_are_grouped_behind_codeql_lockstep_groups():+ """Every action update lands in one PR; codeql-action keeps its own.++ The codeql-action groups must come first: first match wins, so a+ catch-all above them would capture codeql-action and its dedicated+ init/analyze lockstep group (#5400) would never form.+ """+ (entry,) = _entries("github-actions")+ assert list(entry["groups"]) == [+ "codeql-action",+ "codeql-action-security",+ "github-actions",+ "github-actions-security",+ ]+ # Action bumps are mostly major-tag moves, so the catch-all takes every+ # update type rather than only minor and patch.+ _assert_group(entry, "github-actions", applies_to="version-updates")+ assert "update-types" not in entry["groups"]["github-actions"]+ _assert_group(+ entry, "github-actions-security", applies_to="security-updates"+ )+ assert _hidden_groups(entry) == []++def _glob_matches(glob, text):"""Match like Dependabot: ``*`` is the only wildcard, case is ignored.diff --git a/tests/ci/test_npm_update_matrix.py b/tests/ci/test_npm_update_matrix.pyindex 0870fa79d0..57209d1b1f 100644--- a/tests/ci/test_npm_update_matrix.py+++ b/tests/ci/test_npm_update_matrix.py@@ -7,12 +7,13 @@ Coverage in two layers:output, the ``update`` job consuming``fromJson(needs.discover.outputs.matrix)``, the ``set -euo pipefail``and empty-matrix guard, the minimal ``contents: read`` permission,- ``fail-fast: false`` on the per-directory legs, the create-pull-request- branch template's well-formed ``${{ matrix.npm_directory.slug }}``- expression (the slug is computed once in discover's jq and threaded- through the matrix — it is no longer re-derived in the update job), and- the fail-loud invalid-slug and slug-collision guards in discover. These- prevent the safety features from being silently removed — same philosophy as+ ``fail-fast: false`` on the per-directory legs, the read-only legs that+ upload one ``npm-update-${{ matrix.npm_directory.slug }}`` artifact+ instead of opening PRs, the single ``pr`` job that validates those+ artifacts and opens ONE pull request per run, and the fail-loud+ invalid-slug and slug-collision guards in discover (the slug is computed+ once in discover's jq and names each leg's artifact). These prevent the+ safety features from being silently removed — same philosophy as``tests/ci/test_release_gate_integrity.py``.2. Behavioral tests extract the discover step's real ``run:`` script from the@@ -22,6 +23,12 @@ Coverage in two layers:and that the empty-matrix, unknown-path, invalid-slug, and slug-collisionguards all fail the job loudly — without duplicating the pipeline, so itcannot drift from the workflow.++3. Hand-off tests run the legs' real pack script and the ``pr`` job's real+ validate-and-apply script against fixture artifacts, including malicious+ ones (``..`` members, extra files, links, unknown artifacts), to prove+ only ``<dir>/package.json`` and ``<dir>/package-lock.json`` can ever+ reach the combined PR."""import json@@ -81,6 +88,14 @@ def workflow():return yaml.safe_load(WORKFLOW.read_text())+def _step_run(workflow: dict, job: str, step_id: str) -> str:+ """Return the ``run:`` script of ``job``'s step with ``id: step_id``."""+ for step in workflow["jobs"][job]["steps"]:+ if step.get("id") == step_id:+ return step["run"]+ raise AssertionError(f"{job} job has no step with id {step_id!r}")++def _discover_run(workflow: dict) -> str:"""Return the discover job's ``list`` step ``run:`` script."""for step in workflow["jobs"]["discover"]["steps"]:@@ -163,20 +178,21 @@ class TestWorkflowStructure:def test_discover_has_slug_collision_guard(self, workflow):run = _discover_run(workflow)- assert "Colliding branch slugs" in run, (+ assert "Colliding directory slugs" in run, ("The slug-collision guard is gone from discover's list step — "- "two directories whose paths map to the same branch slug (e.g. "- "tests/a-b and tests/a/b, both -> tests-a-b) would silently "- "share one PR branch, reintroducing the concurrent-ref race "- "fixed in PR #5090."+ "two directories whose paths map to the same slug (e.g. "+ "tests/a-b and tests/a/b, both -> tests-a-b) would upload the "+ "same npm-update-<slug> artifact name, and the pr job could not "+ "tell which directory an artifact belongs to.")def test_discover_has_invalid_slug_guard(self, workflow):run = _discover_run(workflow)- assert "Invalid branch slug" in run, (+ assert "Invalid directory slug" in run, ("The invalid-slug guard is gone from discover's list step — a "- "directory such as tests/a..b would enter the update matrix and "- "fail only when create-pull-request tries to create its branch."+ "directory such as tests/a..b or 'tests/a b' would enter the "+ "update matrix with a slug outside the conservative identifier "+ "policy used for its artifact name.")def test_discover_keeps_paths_nul_delimited_until_json_encoding(@@ -212,16 +228,13 @@ class TestWorkflowStructure:returnraise AssertionError("discover has no actions/checkout step")- def test_update_still_can_open_prs(self, workflow):- # Sanity: the update job retains the write permissions it needs to- # create the dependency-bump PR — don't let a permissions tightening- # here break the workflow's actual purpose.+ def test_update_legs_are_read_only(self, workflow):+ # The legs run third-party npm install/build code. They hand their+ # result to the pr job as an artifact and must not be able to write+ # the repo or open PRs themselves.perms = workflow["jobs"]["update"].get("permissions", {})- assert perms.get("contents") == "write", (- "update lost contents:write — it can no longer create the PR."- )- assert perms.get("pull-requests") == "write", (- "update lost pull-requests:write — it can no longer create the PR."+ assert perms == {"contents": "read"}, (+ f"update legs must hold only contents:read; got {perms!r}.")def test_update_legs_do_not_fail_fast(self, workflow):@@ -232,36 +245,128 @@ class TestWorkflowStructure:"failure cancel all the others (run #36 lost 5 of 8 legs).")- def test_pr_branch_is_unique_per_directory(self, workflow):- # With a branch name shared across legs, concurrent legs race on the- # same ref ("Reference cannot be updated") and sequential legs- # force-overwrite each other's commits, silently dropping updates —- # both observed in run #36. Pin a REGEX match, not a bare substring:- # a mutation test showed a brace typo like- # ``${ matrix.npm_directory.slug }}`` still contains many of the- # same substrings (e.g. "matrix.npm_directory.slug") but is not a- # well-formed GitHub Actions expression and would not expand,- # silently breaking branch uniqueness while a substring check stays- # green.- slug_expr = re.compile(r"\$\{\{\s*matrix\.npm_directory\.slug\s*\}\}")+ def test_update_legs_do_not_create_pull_requests(self, workflow):for step in workflow["jobs"]["update"]["steps"]:- if str(step.get("uses", "")).startswith(+ assert not str(step.get("uses", "")).startswith("peter-evans/create-pull-request@"- ):- branch = step["with"]["branch"]- assert slug_expr.search(branch), (- "create-pull-request branch does not contain a "- "well-formed ${{ matrix.npm_directory.slug }} "- f"expression; got {branch!r}. All matrix legs would "- "write the same branch and clobber each other."- )- assert "${{ github.run_number }}" in branch, (- "create-pull-request branch no longer expands "- f"github.run_number; got {branch!r}. Two runs touching "- "the same directory would collide on one branch."- )- return- raise AssertionError("update has no create-pull-request step")+ ), (+ "an update leg creates a pull request again — that is one "+ "PR per lockfile dir. Legs upload an artifact; the pr job "+ "opens the single combined PR."+ )++ def test_update_legs_upload_one_artifact_named_by_slug(self, workflow):+ steps = workflow["jobs"]["update"]["steps"]+ uploads = [+ s+ for s in steps+ if str(s.get("uses", "")).startswith("actions/upload-artifact@")+ ]+ assert len(uploads) == 1, uploads+ upload = uploads[0]+ assert upload["uses"] == (+ "actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9"+ )+ # Regex, not a substring: a brace typo such as+ # ``${ matrix.npm_directory.slug }}`` still contains the substring+ # but does not expand, so every leg would upload the same name.+ assert re.fullmatch(+ r"npm-update-\$\{\{\s*matrix\.npm_directory\.slug\s*\}\}",+ upload["with"]["name"],+ ), upload["with"]["name"]+ assert upload["with"]["if-no-files-found"] == "error"+ assert int(upload["with"]["retention-days"]) <= 7+ # The upload must sit directly after the pack step so it runs only+ # when update, install, build and test all passed (no if: always()).+ pack_index = next(+ i for i, s in enumerate(steps) if s.get("id") == "pack"+ )+ assert steps[pack_index + 1] is upload+ for step in steps[pack_index:]:+ assert "always()" not in str(step.get("if", "")), step++ def test_pack_step_only_packs_the_two_manifests(self, workflow):+ run = _step_run(workflow, "update", "pack")+ assert "for name in package.json package-lock.json; do" in run+ assert "--no-recursion" in run, (+ "pack must not recurse — a dir member would pull in arbitrary "+ "files such as node_modules."+ )++ def test_pr_job_waits_for_legs_and_survives_leg_failures(self, workflow):+ job = workflow["jobs"]["pr"]+ assert set(job["needs"]) == {"discover", "update"}+ condition = job["if"].replace(" ", "")+ # A failed leg must not block the other dirs' updates, so the job+ # needs an always()-style status function; without one a single+ # failed leg skips the whole PR.+ assert "!cancelled()" in condition or "always()" in condition, condition+ assert "needs.discover.result=='success'" in condition, condition++ def test_pr_job_alone_holds_write_permissions(self, workflow):+ assert workflow["jobs"]["pr"]["permissions"] == {+ "contents": "write",+ "pull-requests": "write",+ }+ for name, job in workflow["jobs"].items():+ if name == "pr":+ continue+ for scope, level in (job.get("permissions") or {}).items():+ assert level != "write", (name, scope)++ def test_pr_job_opens_one_pr_per_run(self, workflow):+ steps = workflow["jobs"]["pr"]["steps"]+ creates = [+ s+ for s in steps+ if str(s.get("uses", "")).startswith(+ "peter-evans/create-pull-request@"+ )+ ]+ assert len(creates) == 1, creates+ create = creates[0]+ branch = create["with"]["branch"]+ # Two runs must not reuse one branch; nothing per-directory may be+ # in the name any more.+ assert branch == "update-npm-dependencies-${{ github.run_number }}", (+ branch+ )+ assert create["if"] == "steps.apply.outputs.updated == 'true'"+ add_paths = set(create["with"]["add-paths"].split())+ assert add_paths == {+ "package.json",+ "package-lock.json",+ "**/package.json",+ "**/package-lock.json",+ }, add_paths+ assert create["with"]["sign-commits"] is True+ assert create["with"]["base"] == "main"+ # The body is built in a file from validated data, never by+ # interpolating expressions into the PR body.+ assert "body" not in create["with"]+ assert "body-path" in create["with"]++ def test_pr_job_downloads_and_validates_before_extracting(self, workflow):+ steps = workflow["jobs"]["pr"]["steps"]+ assert "harden-runner" in steps[0]["uses"]+ download_index, download = next(+ (i, s)+ for i, s in enumerate(steps)+ if str(s.get("uses", "")).startswith("actions/download-artifact@")+ )+ assert download["uses"] == (+ "actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333"+ )+ assert download["with"]["pattern"] == "npm-update-*"+ apply_index = next(+ i for i, s in enumerate(steps) if s.get("id") == "apply"+ )+ assert download_index < apply_index+ run = _step_run(workflow, "pr", "apply")+ assert "disallowed member" in run and "non-regular member" in run+ assert "--quoting-style=escape" in run+ for step in steps:+ assert "${{" not in (step.get("run") or ""), step.get("name")# ---------------------------------------------------------------------------@@ -302,7 +407,11 @@ def _matrix_from_output(tmp_path: Path) -> list[dict]:def _assert_branch_safe_slug(slug: str, context) -> None:- """Assert ``slug`` yields a valid git ref when appended to the branch.+ """Assert ``slug`` meets discover's conservative slug policy.++ Slugs now name each leg's ``npm-update-<slug>`` artifact rather than a+ PR branch, but the policy is still Git-ref shaped (see the comment+ above discover's invalid-slug guard), so it is checked as a ref suffix.Pure Python on purpose — it lets the test run without invoking``git`` for every candidate slug. This encodes the subset of its@@ -311,8 +420,8 @@ def _assert_branch_safe_slug(slug: str, context) -> None:component's first character (a leading ``-`` or ``.``) cannot apply,but ``..``, a trailing ``.``, and a ``.lock`` suffix all can — and allthree pass a bare ``[A-Za-z0-9._-]+`` charset check. A dir named- ``tests/foo.lock`` or ``tests/a..b`` would slug cleanly and then fail- in create-pull-request. Git's syntax checker also permits a branch that+ ``tests/foo.lock`` or ``tests/a..b`` would slug cleanly yet make an+ invalid ref. Git's syntax checker also permits a branch thatis too long for the runner filesystem to create with its temporary``.lock`` suffix, so the policy caps slugs at 200 ASCII bytes.@@ -470,8 +579,8 @@ class TestPipelineBehavior:def test_colliding_slugs_fail_loudly(self, workflow, tmp_path):# tests/a-b and tests/a/b both gsub("/", "-") to "tests-a-b" — two- # dirs would share one PR branch, reintroducing the concurrent-ref- # race fixed in PR #5090. Both are under tests/, so they pass the+ # dirs would upload one artifact name and the pr job could not map+ # it back to a single directory. Both are under tests/, so they pass the# unknown-path guard cleanly; only the collision guard should fire.# tests/a.b is also included: an interleaving path is what separated# the duplicates under a locale-collating sort.@@ -487,12 +596,11 @@ class TestPipelineBehavior:)proc = _run_pipeline(_discover_run(workflow), root, tmp_path)assert proc.returncode != 0, (- "colliding branch slugs must fail discovery, not silently enter "- "the matrix"+ "colliding slugs must fail discovery, not silently enter the matrix")# Pin the SPECIFIC failure mode so an unrelated shell error can't# satisfy this test accidentally.- assert "Colliding branch slugs" in proc.stdout, (+ assert "Colliding directory slugs" in proc.stdout, (f"expected the slug-collision guard; got stdout={proc.stdout!r} "f"stderr={proc.stderr!r}")@@ -529,10 +637,10 @@ class TestPipelineBehavior:)proc = _run_pipeline(_discover_run(workflow), root, tmp_path)assert proc.returncode != 0, (- "an invalid branch slug must fail discovery, not reach "- f"create-pull-request: dir={invalid_dir!r}"+ "an invalid slug must fail discovery, not reach the update "+ f"legs: dir={invalid_dir!r}")- assert "Invalid branch slug" in proc.stdout, (+ assert "Invalid directory slug" in proc.stdout, (f"expected the invalid-slug guard; got stdout={proc.stdout!r} "f"stderr={proc.stderr!r}")@@ -726,3 +834,323 @@ class TestSlugBehavior:# anyway; asserted explicitly so a regression names the cause.assert "/" not in slug, (path, slug)_assert_branch_safe_slug(slug, path)+++# ---------------------------------------------------------------------------+# Hand-off tests — the legs' real pack script and the pr job's real+# validate-and-apply script, run against fixture artifacts+# ---------------------------------------------------------------------------+++def _gnu_tar_available() -> bool:+ try:+ proc = subprocess.run(+ ["tar", "--version"], capture_output=True, text=True, timeout=5+ )+ return proc.returncode == 0 and "GNU tar" in proc.stdout+ except (OSError, subprocess.SubprocessError):+ return False+++_REQUIRES_GNU_TAR = pytest.mark.skipif(+ sys.platform != "linux"+ or not shutil.which("jq")+ or not _gnu_tar_available(),+ reason="pack/apply scripts need GNU tar and jq (ubuntu-latest)",+)++_HANDOFF_MATRIX = [+ {"path": ".", "slug": "root"},+ {"path": "tests/a", "slug": "tests-a"},+ {"path": "tests/b", "slug": "tests-b"},+ {"path": "tests/c", "slug": "tests-c"},+]+++def _run_script(script: str, cwd: Path, tmp_path: Path, env: dict):+ script_file = tmp_path / f"script-{len(list(tmp_path.iterdir()))}.sh"+ script_file.write_text(script)+ return subprocess.run(+ ["bash", str(script_file)],+ cwd=str(cwd),+ env={**os.environ, "GITHUB_OUTPUT": str(tmp_path / "gh_output"), **env},+ capture_output=True,+ text=True,+ )+++def _pack(workflow, checkout: Path, tmp_path: Path, npm_dir: str, slug: str):+ """Run the leg's pack step; return the artifact directory it filled."""+ out_dir = tmp_path / "artifacts" / f"npm-update-{slug}"+ proc = _run_script(+ _step_run(workflow, "update", "pack"),+ checkout,+ tmp_path,+ {"NPM_DIR": npm_dir, "CHANGED": "true", "OUT_DIR": str(out_dir)},+ )+ assert proc.returncode == 0, proc.stderr+ return out_dir+++def _checkout(tmp_path: Path) -> Path:+ checkout = tmp_path / "checkout"+ for d in ("", "tests/a", "tests/b", "tests/c"):+ (checkout / d).mkdir(parents=True, exist_ok=True)+ (checkout / d / "package.json").write_text('{"v": "old"}')+ (checkout / d / "package-lock.json").write_text('{"v": "old"}')+ return checkout+++def _apply(workflow, checkout: Path, tmp_path: Path, artifacts: Path):+ body = tmp_path / "body.md"+ (tmp_path / "gh_output").write_text("")+ proc = _run_script(+ _step_run(workflow, "pr", "apply"),+ checkout,+ tmp_path,+ {+ "MATRIX": json.dumps(_HANDOFF_MATRIX),+ "UPDATE_RESULT": "failure",+ "ARTIFACTS_DIR": str(artifacts),+ "BODY_FILE": str(body),+ "RUN_URL": "https://example.invalid/run",+ "GITHUB_STEP_SUMMARY": str(tmp_path / "summary.md"),+ },+ )+ output = (tmp_path / "gh_output").read_text()+ return proc, output, body.read_text() if body.exists() else ""+++def _write_tar(target: Path, members):+ """Write a tar with ``members``: (name, kind, payload) tuples."""+ import io+ import tarfile++ target.parent.mkdir(parents=True, exist_ok=True)+ with tarfile.open(target, "w", format=tarfile.GNU_FORMAT) as tar:+ for name, kind, payload in members:+ info = tarfile.TarInfo(name)+ if kind == "file":+ data = payload.encode()+ info.size = len(data)+ tar.addfile(info, io.BytesIO(data))+ elif kind == "symlink":+ info.type = tarfile.SYMTYPE+ info.linkname = payload+ tar.addfile(info)+ elif kind == "hardlink":+ info.type = tarfile.LNKTYPE+ info.linkname = payload+ tar.addfile(info)+ elif kind == "dir":+ info.type = tarfile.DIRTYPE+ tar.addfile(info)+++@_REQUIRES_GNU_TAR+class TestArtifactHandoff:+ """Pack in the legs, validate and apply in the pr job — for real."""++ def test_round_trip_applies_updates_and_names_failed_dirs(+ self, workflow, tmp_path+ ):+ leg = tmp_path / "leg"+ for d in ("", "tests/a"):+ (leg / d).mkdir(parents=True, exist_ok=True)+ (leg / d / "package.json").write_text(f'{{"v": "new {d}"}}')+ (leg / d / "package-lock.json").write_text(f'{{"v": "new {d}"}}')+ (leg / d / "node_modules").mkdir()+ (leg / d / "stray.js").write_text("not packed")+ _pack(workflow, leg, tmp_path, ".", "root")+ _pack(workflow, leg, tmp_path, "tests/a", "tests-a")+ unchanged = tmp_path / "artifacts" / "npm-update-tests-b"+ unchanged.mkdir()+ (unchanged / "unchanged").write_text("unchanged\n")+ # tests/c uploaded nothing: its leg failed.++ checkout = _checkout(tmp_path)+ proc, output, body = _apply(+ workflow, checkout, tmp_path, tmp_path / "artifacts"+ )+ assert proc.returncode == 0, proc.stdout + proc.stderr+ assert "updated=true" in output+ assert (checkout / "package.json").read_text() == '{"v": "new "}'+ assert (checkout / "tests/a/package-lock.json").read_text() == (+ '{"v": "new tests/a"}'+ )+ assert (checkout / "tests/b/package.json").read_text() == (+ '{"v": "old"}'+ )+ assert not (checkout / "stray.js").exists()+ assert not (checkout / "tests/a/stray.js").exists()+ updated, _, rest = body.partition("**Not included")+ assert "- `.`" in updated and "- `tests/a`" in updated+ assert "tests/b" not in body+ assert "- `tests/c`" in rest++ def test_no_artifacts_skips_pr_cleanly(self, workflow, tmp_path):+ checkout = _checkout(tmp_path)+ proc, output, body = _apply(+ workflow, checkout, tmp_path, tmp_path / "missing"+ )+ assert proc.returncode == 0, proc.stdout + proc.stderr+ assert "updated=false" in output+ for entry in _HANDOFF_MATRIX:+ assert f"- `{entry['path']}`" in body++ @pytest.mark.parametrize(+ ("members", "message"),+ [+ pytest.param(+ [+ ("tests/a/package.json", "file", "{}"),+ ("../x", "file", "pwned"),+ ],+ "disallowed member",+ id="parent-traversal",+ ),+ pytest.param(+ [("tests/a/../../x", "file", "pwned")],+ "disallowed member",+ id="embedded-traversal",+ ),+ pytest.param(+ [("/tmp/x", "file", "pwned")],+ "disallowed member",+ id="absolute-path",+ ),+ pytest.param(+ [+ ("tests/a/package.json", "file", "{}"),+ ("tests/a/evil.js", "file", "pwned"),+ ],+ "disallowed member",+ id="extra-file",+ ),+ pytest.param(+ [("tests/b/package.json", "file", "{}")],+ "disallowed member",+ id="other-directory",+ ),+ pytest.param(+ [("package.json", "file", "{}")],+ "disallowed member",+ id="root-file-from-subdir-leg",+ ),+ pytest.param(+ [("tests/a/package.json", "symlink", "/etc/passwd")],+ "non-regular member",+ id="symlink",+ ),+ pytest.param(+ [+ ("tests/a/package-lock.json", "file", "{}"),+ (+ "tests/a/package.json",+ "hardlink",+ "tests/a/package-lock.json",+ ),+ ],+ "non-regular member",+ id="hardlink",+ ),+ pytest.param(+ [("tests/a/package.json", "dir", None)],+ "non-regular member",+ id="directory",+ ),+ pytest.param(+ [+ (+ "tests/a/package.json\ntests/a/package-lock.json",+ "file",+ "{}",+ )+ ],+ "disallowed member",+ id="newline-in-name",+ ),+ pytest.param(+ [+ ("tests/a/package.json", "file", "{}"),+ ("tests/a/package.json", "file", "{}"),+ ],+ "repeats a member",+ id="duplicate-member",+ ),+ pytest.param([], "empty or unreadable", id="empty-archive"),+ ],+ )+ def test_malicious_archive_is_rejected_before_extraction(+ self, workflow, tmp_path, members, message+ ):+ artifacts = tmp_path / "artifacts"+ _write_tar(artifacts / "npm-update-tests-a" / "update.tar", members)+ checkout = _checkout(tmp_path)+ proc, output, _ = _apply(workflow, checkout, tmp_path, artifacts)+ assert proc.returncode != 0, proc.stdout+ assert message in proc.stdout, proc.stdout + proc.stderr+ assert "updated=" not in output+ assert not (tmp_path / "x").exists()+ assert not (checkout / "tests/a/evil.js").exists()+ assert (checkout / "tests/a/package.json").read_text() == (+ '{"v": "old"}'+ )+ assert not (checkout / "tests/a/package.json").is_symlink()++ @pytest.mark.parametrize(+ ("layout", "message"),+ [+ pytest.param(+ {"npm-update-evil/unchanged": "x"},+ "Unexpected artifact entry",+ id="unknown-slug",+ ),+ pytest.param(+ {"stray/unchanged": "x"},+ "Unexpected artifact entry",+ id="not-an-npm-update-artifact",+ ),+ pytest.param(+ {+ "npm-update-tests-a/unchanged": "x",+ "npm-update-tests-a/evil.js": "x",+ },+ "exactly one regular file",+ id="extra-file-beside-marker",+ ),+ pytest.param(+ {"npm-update-tests-a/.hidden": "x"},+ "Unexpected file in artifact",+ id="hidden-file",+ ),+ pytest.param(+ {"npm-update-tests-a/package.json": "{}"},+ "Unexpected file in artifact",+ id="loose-manifest",+ ),+ ],+ )+ def test_malformed_artifact_layout_is_rejected(+ self, workflow, tmp_path, layout, message+ ):+ artifacts = tmp_path / "artifacts"+ for rel, content in layout.items():+ (artifacts / rel).parent.mkdir(parents=True, exist_ok=True)+ (artifacts / rel).write_text(content)+ checkout = _checkout(tmp_path)+ proc, output, _ = _apply(workflow, checkout, tmp_path, artifacts)+ assert proc.returncode != 0, proc.stdout+ assert message in proc.stdout, proc.stdout + proc.stderr+ assert "updated=" not in output++ def test_symlinked_artifact_file_is_rejected(self, workflow, tmp_path):+ artifacts = tmp_path / "artifacts"+ (artifacts / "npm-update-tests-a").mkdir(parents=True)+ (artifacts / "npm-update-tests-a" / "update.tar").symlink_to(+ "/etc/passwd"+ )+ checkout = _checkout(tmp_path)+ proc, _, _ = _apply(workflow, checkout, tmp_path, artifacts)+ assert proc.returncode != 0, proc.stdout+ assert "exactly one regular file" in proc.stdout