~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
fix(ci): give each npm-update matrix leg its own PR branch (#5090)
LearningCircuit010c7a652768
diff --git a/.github/workflows/update-npm-dependencies.yml b/.github/workflows/update-npm-dependencies.ymlindex dcf2abcf43..ac3055bcf0 100644--- a/.github/workflows/update-npm-dependencies.yml+++ b/.github/workflows/update-npm-dependencies.yml@@ -55,14 +55,18 @@ jobs:ref: main# jq is preinstalled on ubuntu-latest; no install step needed.- # -prune avoids descending into node_modules / .claude / .github- # (filtering with -not -path would still traverse them).+ # -prune avoids descending into excluded trees (filtering with+ # -not -path would still traverse them). './.*' prunes every+ # root-level dot-dir (.git, .github, .claude, and a local .venv —+ # site-packages can ship npm lockfiles, which would otherwise trip+ # the unknown-dir guard when the test suite runs this script on a+ # dev checkout).- name: List package-lock.json dirsid: listrun: |set -euo pipefailMATRIX=$(find . \- \( -path '*/node_modules' -o -path './.claude' -o -path './.github' \) -prune \+ \( -path '*/node_modules' -o -path './.*' \) -prune \-o -name package-lock.json -printf '%h\n' \| sed 's|^\./||' \| sort -u \@@ -93,6 +97,9 @@ jobs:contents: write # Required for creating PRspull-requests: write # Required for creating PRsstrategy:+ # 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).+ fail-fast: falsematrix:npm_directory: ${{ fromJson(needs.discover.outputs.matrix) }}continue-on-error: false@@ -186,18 +193,26 @@ jobs:if git diff --quiet package.json package-lock.json; thenecho "changed=false" >> "$GITHUB_OUTPUT"else- echo "changed=true" >> "$GITHUB_OUTPUT"- # 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"+ # 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"+ # Branch-name slug: "." -> "root", "/" -> "-". Every leg MUST+ # get its own branch — with a shared name, concurrent legs race+ # on the same ref (run #36 failed on "Reference cannot be+ # updated") and sequential legs force-overwrite each other's+ # commits, silently dropping updates.+ echo "slug=$(echo "$NPM_DIR" | sed 's|^\.$|root|; s|/|-|g')"+ } >> "$GITHUB_OUTPUT"fi- name: 📝 Create pull requestuses: peter-evans/create-pull-request@5f6978faf089d4d20b00c7766989d076bb2fc7f1 # v8.1.1if: steps.verify-changed-files.outputs.changed == 'true'with:- branch: update-npm-dependencies-${{ github.run_number }}- title: 🤖 Update dependencies+ branch: update-npm-dependencies-${{ github.run_number }}-${{ steps.verify-changed-files.outputs.slug }}+ title: 🤖 Update dependencies (${{ steps.verify-changed-files.outputs.path }})body: |This PR updates dependencies to their latest compatible versions.diff --git a/changelog.d/+npm-update-per-dir-branches.misc.md b/changelog.d/+npm-update-per-dir-branches.misc.mdnew file mode 100644index 0000000000..9960da6e66--- /dev/null+++ b/changelog.d/+npm-update-per-dir-branches.misc.md@@ -0,0 +1 @@+Fixed the npm-update workflow's create-PR race: all matrix legs shared one branch name (`update-npm-dependencies-<run>`), so concurrent legs failed with "Reference cannot be updated" and sequential legs silently force-overwrote each other's dependency updates (observed in run #36: corrupted PR whose body and diff named different directories, plus 5 of 8 legs cancelled by fail-fast). Each leg now pushes to a per-directory branch, PR titles name the updated directory, and `fail-fast: false` keeps independent legs alive.diff --git a/tests/ci/test_npm_update_matrix.py b/tests/ci/test_npm_update_matrix.pyindex 6bb229f391..c8da9b1b30 100644--- a/tests/ci/test_npm_update_matrix.py+++ b/tests/ci/test_npm_update_matrix.py@@ -83,6 +83,33 @@ def _discover_run(workflow: dict) -> str:)+def _slug_line(workflow: dict) -> str:+ """Return the ``echo "slug=..."`` line from verify-changed-files."""+ for step in workflow["jobs"]["update"]["steps"]:+ if step.get("id") == "verify-changed-files":+ for line in step["run"].splitlines():+ if line.strip().startswith('echo "slug='):+ return line.strip()+ raise AssertionError(+ "update job's verify-changed-files step emits no slug= line — "+ "cannot exercise the branch-slug transform"+ )+++def _slug_for(slug_line: str, npm_dir: str) -> str:+ """Execute the real slug line with NPM_DIR set; return the slug."""+ proc = subprocess.run(+ ["bash", "-euo", "pipefail", "-c", slug_line],+ env={**os.environ, "NPM_DIR": npm_dir},+ capture_output=True,+ text=True,+ )+ assert proc.returncode == 0, proc.stderr+ out = proc.stdout.strip()+ assert out.startswith("slug="), out+ return out[len("slug=") :]++# ---------------------------------------------------------------------------# Structural ("guardian") tests — pin the wiring, prevent silent removal# ---------------------------------------------------------------------------@@ -177,6 +204,40 @@ class TestWorkflowStructure:"update lost pull-requests:write — it can no longer create the PR.")+ def test_update_legs_do_not_fail_fast(self, workflow):+ strategy = workflow["jobs"]["update"]["strategy"]+ assert strategy.get("fail-fast") is False, (+ "update.strategy.fail-fast must be false — the legs are "+ "independent per-directory sweeps, and fail-fast lets one dir's "+ "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 both full expressions: the slug makes+ # the branch unique per directory, run_number unique per run.+ for step in workflow["jobs"]["update"]["steps"]:+ if str(step.get("uses", "")).startswith(+ "peter-evans/create-pull-request@"+ ):+ branch = step["with"]["branch"]+ assert (+ "${{ steps.verify-changed-files.outputs.slug }}" in branch+ ), (+ "create-pull-request branch no longer expands the "+ f"per-directory slug; 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")+# ---------------------------------------------------------------------------# Behavioral tests — execute the REAL pipeline from the YAML (zero drift)@@ -228,8 +289,12 @@ class TestPipelineBehavior:"tests/alpha/package-lock.json", # test dir -> skip"tests/beta/package-lock.json", # test dir -> skip"node_modules/evil/package-lock.json", # excluded- ".claude/evil/package-lock.json", # excluded- ".github/evil/package-lock.json", # excluded+ ".claude/evil/package-lock.json", # excluded (dot-dir)+ ".github/evil/package-lock.json", # excluded (dot-dir)+ # excluded (dot-dir): site-packages can ship npm lockfiles+ # — a repo-root .venv must not trip the unknown-dir guard+ # on dev checkouts.+ ".venv/lib/pkg/js/package-lock.json",],)proc = _run_pipeline(_discover_run(workflow), root, tmp_path)@@ -247,9 +312,10 @@ class TestPipelineBehavior:for d in ("tests/alpha", "tests/beta"):assert by_path[d]["build_cmd"] == "", dassert by_path[d]["test_cmd"].startswith("echo"), d- # Excluded dirs never appear in the matrix.+ # Excluded dirs (node_modules anywhere, dot-dirs at root) never+ # appear in the matrix. The repo root "." is not a dot-dir.assert not any(- "node_modules" in p or p.startswith((".claude", ".github"))+ "node_modules" in p or (p != "." and p.startswith("."))for p in paths), paths# Every entry carries the keys the update job dereferences.@@ -375,3 +441,54 @@ class TestPipelineAgainstRealRepo:f"expected root + >=1 tests dir, got {len(real_repo_matrix)}: "f"{[e['path'] for e in real_repo_matrix]}")+++@_REQUIRES_GNU+class TestSlugBehavior:+ """Execute the real branch-slug transform from the update job.++ The per-directory branch name is the whole race fix (run #36): these+ run the actual ``echo "slug=..."`` line extracted from the YAML, so a+ broken sed, an emptied slug, or a slug collision cannot pass unnoticed.+ """++ def test_slug_maps_fixture_dirs_to_unique_valid_refs(self, workflow):+ slug_line = _slug_line(workflow)+ dirs = [+ ".",+ "tests",+ "tests/ui_tests",+ "tests/ui_tests/playwright",+ "tests/api_tests_with_login",+ ]+ slugs = {d: _slug_for(slug_line, d) for d in dirs}+ assert slugs["."] == "root", slugs+ assert len(set(slugs.values())) == len(dirs), (+ f"slug collision — two dirs would share a branch: {slugs}"+ )+ for d, slug in slugs.items():+ assert slug and "/" not in slug, (d, slug)+ branch = f"update-npm-dependencies-36-{slug}"+ proc = subprocess.run(+ ["git", "check-ref-format", "--branch", branch],+ capture_output=True,+ text=True,+ )+ assert proc.returncode == 0, (+ f"{d!r} slugs to invalid branch {branch!r}: {proc.stderr}"+ )++ def test_real_repo_dirs_slug_to_unique_branches(+ self, workflow, real_repo_matrix+ ):+ # The '/'->'-' mapping is not injective (tests/foo-bar and+ # tests/foo/bar both slug to tests-foo-bar, silently sharing a+ # branch). No such pair exists today; this invariant keeps it that+ # way as lockfile dirs are added.+ slug_line = _slug_line(workflow)+ slugs = {+ e["path"]: _slug_for(slug_line, e["path"]) for e in real_repo_matrix+ }+ assert len(set(slugs.values())) == len(slugs), (+ f"two live dirs slug to the same branch: {slugs}"+ )