From 557161c4740a164fc56b736de3fca68c9bd5814f Mon Sep 17 00:00:00 2001 From: Heo Hao <130041734+Shelden-Hao@users.noreply.github.com> Date: Tue, 17 Nov 2026 09:51:17 +0800 Subject: [PATCH] fix(ci): give a Helm chart change an area label (#8285) * fix(ci): give a Helm chart change an area label deploy/ holds the Helm chart and nothing else. No AREA_RULES entry matched that tree, so a PR touching only the chart -- and the backend/tests/test_helm_*.py that comes with it -- arrived with no area label at all: #8123 reached merge with just its size and risk labels, and #8161 only carried area:docs because it happened to touch a README. Nothing routes those PRs to a reviewer who owns the chart. The chart is release/deploy tooling in the same sense as scripts/: bump_version.sh rewrites its versions, verify_versions.sh and the chart workflow gate its rendering, and area:ci already owns scripts/. Add deploy/ to that rule. The offline replay in tests/test_label_declarations.py already proves the labels the workflow would apply; it only covered the backend package trees. Move its Node harness into a shared helper, reuse it, and add the chart cases so this gap cannot reopen. * Update CI area label matching for helm directory Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Willem Jiang Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- .github/workflows/triage.yml | 7 ++++- backend/tests/test_label_declarations.py | 40 ++++++++++++++++++++++-- 2 files changed, 43 insertions(+), 4 deletions(-) diff --git a/.github/workflows/triage.yml b/.github/workflows/triage.yml index 1d2d5e3d75..e569cf064c 100644 --- a/.github/workflows/triage.yml +++ b/.github/workflows/triage.yml @@ -66,7 +66,12 @@ jobs: ['area:sandbox', [/^docker\//, /^backend\/packages\/harness\/deerflow\/sandbox\//, /(^|\/)Dockerfile$/]], ['area:skills', [/^skills\//, /^backend\/packages\/harness\/deerflow\/skills\//, /^frontend\/src\/core\/skills\//]], ['area:mcp', [/^backend\/packages\/harness\/deerflow\/mcp\//, /^frontend\/src\/core\/mcp\//]], - ['area:ci', [/^\.github\//, /^scripts\//]], + // deploy/ holds the Helm chart, which is release/deploy tooling like + // scripts/: bump_version.sh rewrites its versions, verify_versions.sh + // and the chart workflow gate its rendering. Without this entry a PR + // that touches only deploy/ (plus its backend/tests/test_helm_*.py) + // matches no rule at all and arrives with no area label. + ['area:ci', [/^\.github\//, /^scripts\//, /^deploy\/helm\//]], ['area:docs', [/^docs\//, /\.mdx?$/]], ['area:deps', [/(^|\/)(pyproject\.toml|uv\.lock|package\.json|pnpm-lock\.yaml)$/]], ]; diff --git a/backend/tests/test_label_declarations.py b/backend/tests/test_label_declarations.py index b1fa06b74c..ec0133d68d 100644 --- a/backend/tests/test_label_declarations.py +++ b/backend/tests/test_label_declarations.py @@ -226,6 +226,41 @@ def test_pr_area_labels_cover_backend_packages(): area = specific_areas.get(directory.name, "area:backend") cases.append(([f"{path}/example.py"], {area})) + for (paths, expected), labels in zip(cases, replay_area_labels([paths for paths, _ in cases]), strict=True): + assert sorted(labels) == sorted(expected), paths + + +@pytest.mark.skipif(shutil.which("node") is None, reason="Workflow replay requires Node.js") +def test_pr_area_labels_cover_the_helm_chart(): + """A chart-only change is release/deploy tooling, so it must carry an area. + + ``deploy/`` holds the Helm chart and nothing else: ``scripts/bump_version.sh`` + rewrites its versions, and ``scripts/verify_versions.sh`` plus the chart + workflow gate its rendering. A PR that touches the chart and its + ``backend/tests/test_helm_*.py`` proves nothing about the product areas, so + before this rule it matched no entry at all and arrived with no area label + (for example #8123, which reached merge with only its size and risk labels). + """ + cases = [ + ( + ["deploy/helm/deer-flow/templates/nginx-deployment.yaml", "backend/tests/test_helm_image_pull_secrets.py"], + {"area:ci"}, + ), + (["deploy/helm/deer-flow/Chart.yaml"], {"area:ci"}), + (["deploy/helm/deer-flow/README.md", "deploy/helm/deer-flow/values.yaml"], {"area:ci", "area:docs"}), + ] + + for (paths, expected), labels in zip(cases, replay_area_labels([paths for paths, _ in cases]), strict=True): + assert sorted(labels) == sorted(expected), paths + + +def replay_area_labels(changes: list[list[str]]) -> list[list[str]]: + """Run the workflow's own ``AREA_RULES`` over each path list, using Node. + + The area labels are produced by JavaScript inside the workflow, so a Python + copy of the rules would only prove itself. The workflow body is evaluated + with a stub client that records the ``addLabels`` batches instead. + """ scripts = checker.workflow_scripts(checker.TRIAGE_WORKFLOW.read_text(encoding="utf-8")) (script,) = (source for source in scripts if "const AREA_RULES =" in source) result = subprocess.run( @@ -258,12 +293,11 @@ async function replay(paths) { Promise.all(changes.map(replay)).then(labels => console.log(JSON.stringify(labels))); """, ], - input=json.dumps({"script": script, "changes": [paths for paths, _ in cases]}), + input=json.dumps({"script": script, "changes": changes}), capture_output=True, encoding="utf-8", check=False, timeout=10, ) assert result.returncode == 0, result.stderr - for (paths, expected), labels in zip(cases, json.loads(result.stdout), strict=True): - assert sorted(labels) == sorted(expected), paths + return json.loads(result.stdout)