diff options
| author | Bryan Thompson <bthompson@anthropic.com> | 2026-06-22 20:03:36 -0500 |
|---|---|---|
| committer | Bryan Thompson <bthompson@anthropic.com> | 2026-06-22 20:03:36 -0500 |
| commit | 7bc909dc203c249bfed698dc5095c956483cc80e (patch) | |
| tree | 9683cb5c05e4a9494e9c8054cd09036940389cd0 /.github/workflows | |
| parent | 286eb1e2178e64571fe339576b06ea03b7754ece (diff) | |
| parent | b8c05307dbdfcc8bc4ba48e44dbae5a87e30512d (diff) | |
Merge main into add-hana-cli (refresh 991-commit-stale branch)add-hana-cli
Diffstat (limited to '.github/workflows')
| -rw-r--r-- | .github/workflows/bump-plugin-shas.yml | 88 | ||||
| -rw-r--r-- | .github/workflows/scan-plugins.yml | 165 | ||||
| -rw-r--r-- | .github/workflows/validate-plugins.yml | 16 |
3 files changed, 239 insertions, 30 deletions
diff --git a/.github/workflows/bump-plugin-shas.yml b/.github/workflows/bump-plugin-shas.yml index dab017ea..371a4f17 100644 --- a/.github/workflows/bump-plugin-shas.yml +++ b/.github/workflows/bump-plugin-shas.yml @@ -2,25 +2,24 @@ name: Bump Plugin SHAs # Nightly sweep: for each external entry whose upstream HEAD has moved past # its pinned SHA, validate at the new SHA with `claude plugin validate` -# inline, then open one PR with all passing bumps. Each run force-resets the -# bump/plugin-shas branch, so a previous night's unmerged PR is replaced (and -# its review state discarded) — review and merge same-day to avoid churn. +# inline, then open one PR per bumped plugin on branch `bump/<slug>`. +# Failing entries stay isolated in their own PR; passing bumps merge +# independently. # # Bot-free — uses the default GITHUB_TOKEN. PRs opened with GITHUB_TOKEN don't -# trigger on:pull_request workflows, so the policy scan (`Scan Plugins`, a -# required status check on main) would never run and the bump PR could never -# merge. workflow_dispatch is exempt from that recursion guard, so we dispatch -# the scan ourselves on the bump branch after the PR is opened. The check run -# lands on the branch HEAD — the same SHA as the PR head — and satisfies the -# required check. +# trigger on:pull_request workflows, so the required status checks on main +# (`scan` from Scan Plugins, `check` from Check MCP URLs, `validate` from +# Validate Plugins) would never run and the bump PR could never merge. +# workflow_dispatch is exempt from that recursion guard, so we dispatch all +# three ourselves against each per-entry bump branch after its PR is opened. +# Each check run lands on the branch HEAD — the same SHA as the PR head — and +# satisfies the corresponding required check. (Each of those workflows runs +# its job unconditionally on workflow_dispatch, so a dispatch always reports.) # -# max-bumps is set above the external-entry count so a single run can clear -# any backlog. The cost-control mechanisms are downstream: -# - scan-plugins.yml caches verdicts by (plugin, sha) so an unchanged SHA -# is never re-scanned across nightly force-resets. -# - revert-failed-bumps.yml drops policy-failing entries from the bump PR -# so one bad upstream can't block the rest. -# See those files for details. +# max-bumps caps the per-night work for cost control. Per-entry scans are +# more expensive than a single batched scan, so the cap is conservative. +# The composite action skips entries that already have an open bump PR, so +# re-dispatches don't pile up duplicate work. on: schedule: @@ -30,12 +29,18 @@ on: max_bumps: description: Cap on plugins bumped this run required: false - default: '130' + default: '30' + plugin: + description: >- + Bump ONLY this plugin name (exact entry name; empty = all stale). A + frozen/sha-exempt target is still skipped (same as a full run). + required: false + default: '' permissions: contents: write pull-requests: write - actions: write # gh workflow run scan-plugins.yml on the bump branch + actions: write # gh workflow run {scan-plugins,check-mcp-urls,validate-plugins}.yml per bump branch concurrency: group: bump-plugin-shas @@ -43,8 +48,8 @@ concurrency: jobs: bump: runs-on: ubuntu-latest - # Per-bump cost is ~2s (ls-remote + shallow clone + validate); 130 entries - # is ~5 min. The 60 min ceiling absorbs slow upstreams without letting a + # Per-bump cost is ~2s (ls-remote + shallow clone + validate); 30 entries + # is ~1-2 min. The 60 min ceiling absorbs slow upstreams without letting a # pathological run consume the default 360 min budget. timeout-minutes: 60 steps: @@ -52,18 +57,45 @@ jobs: # createCommitOnBranch-based bump so commits are signed by GitHub and # satisfy the org-level required_signatures ruleset on main. - - uses: anthropics/claude-plugins-community/.github/actions/bump-plugin-shas@c41c6911de0afffd2bc5cd8b21fb1e06444ee13b + - uses: anthropics/claude-plugins-community/.github/actions/bump-plugin-shas@426e469f322952061102b286b378c0c9733a0934 id: bump with: marketplace-path: .claude-plugin/marketplace.json - max-bumps: ${{ inputs.max_bumps || '130' }} + max-bumps: ${{ inputs.max_bumps || '30' }} + only: ${{ inputs.plugin }} + pr-mode: per-entry claude-cli-version: latest - # `bump/plugin-shas` is the action's default `pr-branch`. The scan diffs - # the branch against origin/main (the action's base-ref fallback when - # there's no pull_request event) and scans only the bumped entries. - - name: Dispatch policy scan on bump branch - if: steps.bump.outputs.pr-url != '' + # Per-entry fan-out: dispatch the three required checks against each bump + # branch. `pr-urls` is a JSON array of {name, old_sha, new_sha, branch, + # pr_url} entries emitted by the composite action when pr-mode is + # per-entry. All three (scan / check / validate) are required on main and + # none fire on the GITHUB_TOKEN-opened PR, so each must be dispatched. + # A single failed dispatch (transient API error / rate limit) must not + # strand the remaining branches, so we attempt every dispatch, then fail + # the step if any failed: a missing required check would otherwise leave + # its bump PR silently blocked behind a green run, and the composite + # action skips slugs with an open PR so it would never be retried. + - name: Dispatch required checks per per-entry PR + if: steps.bump.outputs.pr-urls != '' && steps.bump.outputs.pr-urls != '[]' env: GH_TOKEN: ${{ github.token }} - run: gh workflow run scan-plugins.yml --ref bump/plugin-shas + PR_URLS: ${{ steps.bump.outputs.pr-urls }} + run: | + set -euo pipefail + dispatch_failures="$(mktemp)" + jq -c '.[]' <<<"$PR_URLS" | while read -r entry; do + branch=$(jq -r '.branch' <<<"$entry") + name=$(jq -r '.name' <<<"$entry") + for wf in scan-plugins check-mcp-urls validate-plugins; do + echo "Dispatching ${wf}.yml against $branch ($name)" + if ! gh workflow run "${wf}.yml" --ref "$branch"; then + echo "::error::Failed to dispatch ${wf}.yml against $branch ($name) — required check will be missing; re-dispatch with: gh workflow run ${wf}.yml --ref $branch" + echo "${wf} ${branch}" >> "$dispatch_failures" + fi + done + done + if [ -s "$dispatch_failures" ]; then + echo "::error::$(wc -l < "$dispatch_failures" | tr -d ' ') required-check dispatch(es) failed; the affected bump PR(s) are blocked until re-dispatched (see annotations above)." + exit 1 + fi diff --git a/.github/workflows/scan-plugins.yml b/.github/workflows/scan-plugins.yml index ab075e47..28369843 100644 --- a/.github/workflows/scan-plugins.yml +++ b/.github/workflows/scan-plugins.yml @@ -196,7 +196,7 @@ jobs: continue-on-error: true # Pinned to claude-plugins-community#34 (WIF input support). # TODO: re-pin to a main-branch SHA once #34 merges. - uses: anthropics/claude-plugins-community/.github/actions/scan-plugins@e85f0d65b4fc87f07862e1dcdc467950514414ec + uses: anthropics/claude-plugins-community/.github/actions/scan-plugins@426e469f322952061102b286b378c0c9733a0934 with: # Anthropic auth via Workload Identity Federation — the action # mints a GitHub OIDC token (id-token: write above) and the claude @@ -381,3 +381,166 @@ jobs: echo "::error::Scan step failed without a parseable policy verdict (likely an infra error)." exit 1 fi + + # ───────────────────────────────────────────────────────────────────────────── + # emit-verdict: post a sticky comment per entry to the bump PR with the + # structured verdict, so downstream tooling (label automation, delist + # authoring) can read verdicts directly instead of scraping job logs. + # Sticky comment marker: `<!-- bump-pr-verdict:<name> -->`. + # + # Mirrors the schema_v1 contract from + # anthropics/claude-plugins-community-internal#3908 so the triage scripts + # in mcp-local-directory/scripts/triage/ work uniformly across both repos. + # -official doesn't run per-entry static checks (zombie, schema, binaries, + # etc.) so the `scan.*` axes are emitted as "skipped". The granular policy + # booleans (`has_broad_scope_hooks`, `has_undisclosed_telemetry`, + # `description_matches_behavior`) aren't surfaced by this workflow's + # per-entry artifact yet, so they're emitted as null; the triage + # `triage_bool_to_str` helper maps null → "?" so display is graceful. + # Status describes the execution state, not the outcome — `ran` when the + # scan action evaluated this SHA fresh, `cached` when a prior verdict was + # reused (cf. run-verdicts.json's `source` field). Outcome lives in + # `policy.passes`. policy-sweep.sh dispatches on this exact vocabulary. + # + # PR resolution: pull_request events carry the PR number directly. The + # bump workflow creates bump PRs via GITHUB_TOKEN (which doesn't fire + # pull_request triggers — recursion guard) and dispatches this scan via + # workflow_dispatch on the bump branch. In that case we look up the + # open PR by head ref. No PR (scan_all dispatch on main, etc.) → no-op. + # + # continue-on-error at the job level: emit failure must NOT block the + # `scan` required check. Consumers fall back to log-scraping if the + # comment is absent (gradual migration; no flag day). + # ───────────────────────────────────────────────────────────────────────────── + emit-verdict: + needs: [scan] + if: always() && needs.scan.result != 'skipped' && needs.scan.result != 'cancelled' + runs-on: ubuntu-latest + continue-on-error: true + permissions: + contents: read + pull-requests: write + steps: + - name: Download scan verdicts + uses: actions/download-artifact@v4 + with: + name: scan-verdicts + path: /tmp/scan-verdicts + continue-on-error: true + + - name: Resolve PR number for this ref + id: pr + env: + GH_TOKEN: ${{ github.token }} + EVENT_NAME: ${{ github.event_name }} + PR_FROM_EVENT: ${{ github.event.pull_request.number }} + REF: ${{ github.ref_name }} + REPO: ${{ github.repository }} + run: | + set -euo pipefail + if [[ "$EVENT_NAME" == "pull_request" && -n "$PR_FROM_EVENT" ]]; then + echo "number=$PR_FROM_EVENT" >> "$GITHUB_OUTPUT" + exit 0 + fi + # workflow_dispatch on the bump branch: find the open PR for it. + # head filter takes the form owner:branch. + owner="${REPO%%/*}" + pr=$(gh api "/repos/${REPO}/pulls?state=open&head=${owner}:${REF}&per_page=1" \ + --jq '.[0].number // ""') + if [[ -z "$pr" ]]; then + echo "::notice::No open PR for ref ${REF} — sticky comments skipped (verdicts still in scan-verdicts artifact)" + fi + echo "number=$pr" >> "$GITHUB_OUTPUT" + + - name: Build and post sticky comments + if: steps.pr.outputs.number != '' + env: + GH_TOKEN: ${{ github.token }} + REPO: ${{ github.repository }} + PR: ${{ steps.pr.outputs.number }} + RUN_ID: ${{ github.run_id }} + run: | + set -euo pipefail + + verdicts_path=/tmp/scan-verdicts/run-verdicts.json + # Missing/empty artifact: scan job ran but didn't produce verdicts + # (e.g. the relevance gate said "no changes"). Nothing to comment; + # exit clean. + if [[ ! -s "$verdicts_path" ]]; then + echo "::notice::No run-verdicts.json artifact — nothing to emit" + exit 0 + fi + count=$(jq 'length' "$verdicts_path") + if [[ "$count" == "0" ]]; then + echo "::notice::run-verdicts.json is empty — nothing to emit" + exit 0 + fi + + ran_at=$(date -u +%Y-%m-%dT%H:%M:%SZ) + + # scan.* axes: -official doesn't run per-entry static checks; emit + # "skipped" for each so the schema is shape-compatible with -internal. + scan_stub='{"clone":"skipped","subpath_missing":"skipped","schema":"skipped","zombie":"skipped","tool_allowlist":"skipped","binaries":"skipped","unique":"skipped","mcp":"skipped"}' + + # Pre-fetch all PR comments once (paginated) for the marker lookup. + gh api --paginate "/repos/$REPO/issues/$PR/comments" \ + --jq '.[] | {id, body}' > /tmp/comments.ndjson + + jq -c '.[]' "$verdicts_path" | while read -r entry; do + name=$(jq -r '.name' <<< "$entry") + passes=$(jq -r '.passes' <<< "$entry") + summary=$(jq -r '.summary // ""' <<< "$entry") + violations=$(jq -r '.violations // ""' <<< "$entry") + source=$(jq -r '.source // "scan"' <<< "$entry") + + # status = execution state (cf. -internal#3908 vocabulary). + # Outcome is in `passes`. Map source → status: scan-action-run + # → "ran"; cache-served → "cached". Anything else falls through + # as "ran" (only those two values appear in run-verdicts.json). + case "$source" in + cache) status="cached" ;; + scan) status="ran" ;; + *) status="ran" ;; + esac + + policy=$(jq -n \ + --argjson passes "$passes" \ + --arg summary "$summary" \ + --arg violations "$violations" \ + --arg source "$source" \ + --arg status "$status" \ + '{passes: $passes, + has_broad_scope_hooks: null, + has_undisclosed_telemetry: null, + description_matches_behavior: null, + summary: $summary, + violations: $violations, + source: $source, + status: $status}') + + verdict=$(jq -n \ + --argjson scan "$scan_stub" \ + --argjson policy "$policy" \ + --arg ran_at "$ran_at" \ + --arg run_id "$RUN_ID" \ + '{schema_version: 1, ran_at: $ran_at, run_id: $run_id, scan: $scan, policy: $policy}') + + marker="<!-- bump-pr-verdict:$name -->" + body=$(printf '%s\n```json\n%s\n```' "$marker" "$verdict") + + # jq's first() short-circuits and avoids SIGPIPE under pipefail if + # duplicate markers exist (shouldn't, but a prior buggy run could + # double-post). -s slurps NDJSON; `// empty` yields no output when + # no match. + existing=$(jq -rs --arg m "$marker" \ + 'first(.[] | select(.body | startswith($m)) | .id) // empty' \ + /tmp/comments.ndjson) + + if [[ -n "$existing" ]]; then + gh api -X PATCH "/repos/$REPO/issues/comments/$existing" -f body="$body" >/dev/null + echo "Updated comment $existing for $name" + else + gh api -X POST "/repos/$REPO/issues/$PR/comments" -f body="$body" >/dev/null + echo "Created comment for $name" + fi + done diff --git a/.github/workflows/validate-plugins.yml b/.github/workflows/validate-plugins.yml index b297bdea..da9bdf2f 100644 --- a/.github/workflows/validate-plugins.yml +++ b/.github/workflows/validate-plugins.yml @@ -8,10 +8,24 @@ on: - '*/agents/**' - '*/skills/**' - '*/commands/**' + # `validate` is a required status check, so a PR that touches ONLY workflow + # files (e.g. an action-SHA re-pin) would otherwise never trigger validate + # and sit "Expected — Waiting for status to be reported" forever (workflow_dispatch + # check runs aren't associated with the PR, so they don't satisfy it). Run + # validate on workflow changes too so those PRs can clear the gate in-context. + - '.github/workflows/**' push: branches: [main] paths: - '.claude-plugin/**' + # `validate` is a required status check on main. Bump PRs are opened with + # GITHUB_TOKEN, which doesn't fire on:pull_request (recursion guard), so the + # path-filtered trigger above never reports on them and the PR would be + # blocked forever. The bump workflow dispatches this against each per-entry + # bump branch instead; the check run lands on the branch HEAD (= PR head) + # and satisfies the required check. The validate job runs unconditionally, + # so a dispatch always reports. + workflow_dispatch: permissions: contents: read @@ -24,7 +38,7 @@ jobs: with: fetch-depth: 0 - - uses: anthropics/claude-plugins-community/.github/actions/validate-plugins@f846a0bcb0e721b1f93d60e8b73e91dafc4a1e87 + - uses: anthropics/claude-plugins-community/.github/actions/validate-plugins@426e469f322952061102b286b378c0c9733a0934 with: marketplace-path: .claude-plugin/marketplace.json # Official curated marketplace: SHA-pin (I5) is a HARD error. |
