Files
market/.github/workflows/upstream-health.yml
T
yige 1ced701714 fix: 上游巡检允许已审查暂缓覆盖集合新增子技能 (#230)
## Why

`upstream-health-hold.json` could only cover `upstream-path-change` and
`outdated`. When the upstream head of a held collection adds children
that `children` does not declare, the `new-skill` finding stays
actionable even after maintainers have reviewed those children and
decided not to declare them, so the tracking issue (#213) can never
close. `skills/marketingskills` is in this state today: its two new
upstream children were reviewed in the 2026-10-27 round (#227), but
nothing can hold the finding.

## What changes

- `new-skill` is now a holdable status (`HOLDABLE =
("upstream-path-change", "new-skill", "outdated")`).
- A hold that lists `new-skill` also checks the undeclared children:
- the set of undeclared child paths at branch head must equal the set at
the reviewed `head`; otherwise `stale-hold: undeclared children changed
since <head> (added …; removed …)`;
- the staleness diff adds those undeclared child paths to the installed
scope (declared children plus root `LICENSE*`/`NOTICE*`/`COPYING*`), so
any change inside them gives `stale-hold: upstream changed within the
installed scope or undeclared children since <head>`;
- a network error while listing children at the reviewed head is
`unreachable`, not a stale hold.
- Holds without `new-skill` compare the same scope and keep every
existing message. The only wording change for them is the validation
error for an unholdable status, which now lists `new-skill` among the
holdable statuses.
- The discovery filter moves into `undeclared_children()`, which the
`new-skill` finding and the hold check share, so both always agree on
what is undeclared.
- The checker docstring, the tracking-issue guidance in
`.github/workflows/upstream-health.yml`, `README.md` and
`README.zh-CN.md` describe the extended hold.

## Tests

New cases in `scripts/catalog/test_check_upstream_health.py`:

- a valid `new-skill` hold is reported as `held`, and stays held after
an unrelated upstream change;
- a newly added undeclared child, and later the removal of the reviewed
ones, make the hold stale;
- a content change inside a held undeclared child makes the hold stale;
- an `outdated`-only hold on a collection still ignores changes to
undeclared children (existing behaviour);
- a network error while listing children at the reviewed head stays
`unreachable`.

The validation test now accepts `new-skill` and still rejects broken,
`unreachable`, `unpinned`, `held`, `stale-hold` and `ok`.

## Validation

- `scripts/i18n/test_validate_i18n.py`: 19 tests pass.
- `scripts/catalog/test_validate_catalog_metadata.py`: 51 tests pass.
- `scripts/catalog/test_collection_generator.py`: 10 tests pass.
- `scripts/catalog/test_check_upstream_health.py`: 47 tests pass (5
new).
- `validate_catalog_metadata.py --require-complete` and
`validate-i18n.py`: 0 errors, 103 existing warnings. `translate.py
--check`, `actionlint` and `git diff --check` are clean.
- Live run on `marketingskills` (entry and hold as on `main`, in a
scratch copy, not committed):
- with `new-skill` added to the 2026-10-27 hold, the result is
`stale-hold`, because upstream has since moved from `17772c7` to
`0cd9b3a` and changed declared children. The same hold without
`new-skill` is also stale, so this is not caused by the new check. The
two undeclared children are unchanged between those heads.
- with the reviewed head set to a commit whose tree equals the current
head, `new-skill` and `outdated` are both `held` and the summary reports
`actionable: false`.

## Follow-up

After this lands, the `marketingskills` hold can add `new-skill` to its
`statuses`. Its reviewed head needs a fresh review first, because
upstream has changed declared children since `17772c7`.

The pre-publication sensitive-token scan was run privately by the
maintainer and passed.

Refs #213.
2026-10-28 20:08:36 +08:00

95 lines
3.7 KiB
YAML

name: Upstream Health
# Weekly check that every external pointer (skills/agents/teams entry.json)
# still resolves upstream. Results go to one tracking issue labelled
# `upstream-health`, which is updated in place and closed once nothing is
# actionable. Fixing an entry stays a normal reviewed PR; this workflow never
# rewrites catalog files.
on:
schedule:
- cron: "23 1 * * 1" # Mondays 01:23 UTC
workflow_dispatch:
permissions:
contents: read
issues: write
concurrency:
group: upstream-health
cancel-in-progress: false
jobs:
check:
if: github.repository == 'desirecore/market'
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v3
- name: Check upstreams
id: check
run: |
set +e
uv run --quiet scripts/catalog/check_upstream_health.py --format markdown --summary-file summary.json > report.md
code=$?
set -e
if [ "$code" -gt 1 ]; then
echo "health check crashed with exit code $code" >&2
exit "$code"
fi
python3 - <<'PY' >> "$GITHUB_OUTPUT"
import json
from pathlib import Path
summary = json.loads(Path("summary.json").read_text())
for key in ("broken", "actionable", "unknown", "held"):
print(f"{key}={str(summary[key]).lower()}")
PY
cat report.md >> "$GITHUB_STEP_SUMMARY"
- name: Update tracking issue
env:
GH_TOKEN: ${{ github.token }}
ACTIONABLE: ${{ steps.check.outputs.actionable }}
UNKNOWN: ${{ steps.check.outputs.unknown }}
HELD: ${{ steps.check.outputs.held }}
RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
run: |
set -euo pipefail
label=upstream-health
gh label create "$label" --color D93F0B \
--description "Upstream availability of external catalog entries" 2>/dev/null || true
{
echo "_Updated by [Upstream Health]($RUN_URL) on $(date -u +%Y-%m-%d)._"
echo
echo "Fix entries through a normal PR: repoint or remove \`gone\` entries, correct \`bad-*\` paths, and review upstream changes before bumping \`source.ref\` for \`outdated\` entries (rerun \`scripts/gen-collection-children.py\` for collections); a reviewed decision to keep the current pin or to leave new upstream children undeclared can be recorded in \`<kind>/<id>/upstream-health-hold.json\`. \`unreachable\` means a network error, not a confirmed failure."
echo
cat report.md
} > body.md
issue=$(gh issue list --label "$label" --state open --limit 1 --json number --jq '.[0].number // empty')
if [ "$ACTIONABLE" = "true" ] || [ "$UNKNOWN" = "true" ]; then
if [ -n "$issue" ]; then
gh issue edit "$issue" --body-file body.md
else
gh issue create --title "Upstream health report" --label "$label" --body-file body.md
fi
elif [ -n "$issue" ]; then
closing="All external entries resolve upstream and are current as of $RUN_URL."
if [ "${HELD:-0}" -gt 0 ]; then
closing="All external entries resolve upstream as of $RUN_URL; $HELD finding(s) remain under reviewed holds (see the run summary)."
fi
gh issue comment "$issue" --body "$closing Closing."
gh issue close "$issue"
fi
- name: Fail when an entry is broken
if: steps.check.outputs.broken == 'true'
run: |
echo "::error::At least one external entry no longer resolves upstream; see the upstream-health issue."
exit 1