From c0424bbb6ab77d0c48eab822ec6908af24e5887d Mon Sep 17 00:00:00 2001 From: brady gaster Date: Fri, 17 Apr 2026 22:07:01 -0700 Subject: [PATCH 1/9] =?UTF-8?q?chore:=20CI=20cleanup=20=E2=80=94=20delete?= =?UTF-8?q?=20ci-rerun.yml=20and=20streamline=20squad-ci.yml?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Delete redundant ci-rerun.yml (GitHub Approve and Run handles fork PRs natively) - Update setup-squad-node comment (remove ci-rerun reference) - Streamline squad-ci.yml: merge exports-map-check + export-smoke-test into sdk-exports-validation, fold publish-policy + scope-check into policy-gates, add workflow path filtering, trim verbose comments (852 → 585 lines, 9 → 6 jobs) Closes #1000 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .github/actions/setup-squad-node/action.yml | 2 +- .github/workflows/ci-rerun.yml | 153 ----- .github/workflows/squad-ci.yml | 611 ++++++-------------- 3 files changed, 173 insertions(+), 593 deletions(-) delete mode 100644 .github/workflows/ci-rerun.yml diff --git a/.github/actions/setup-squad-node/action.yml b/.github/actions/setup-squad-node/action.yml index b1bc0d54a..569d01a5b 100644 --- a/.github/actions/setup-squad-node/action.yml +++ b/.github/actions/setup-squad-node/action.yml @@ -1,6 +1,6 @@ # Composite action: Setup Node.js with npm cache and retry logic # Created to DRY up the repeated setup-node + npm install retry pattern -# used across squad-ci.yml, ci-rerun.yml, squad-npm-publish.yml, +# used across squad-ci.yml, squad-npm-publish.yml, # and squad-insider-publish.yml. # # Usage: diff --git a/.github/workflows/ci-rerun.yml b/.github/workflows/ci-rerun.yml deleted file mode 100644 index 3652ce909..000000000 --- a/.github/workflows/ci-rerun.yml +++ /dev/null @@ -1,153 +0,0 @@ -# CI Rerun — Manual workflow for re-running CI on fork PRs or PRs that need -# a fresh CI pass without push. Useful when: -# - Fork PRs don't trigger CI automatically (security restriction) -# - A PR needs re-testing after an infrastructure flake -# - You need to validate a PR against current base branch state -# Usage: Actions → CI Rerun (Manual) → enter PR number → Run workflow -name: CI Rerun (Manual) - -on: - workflow_dispatch: - inputs: - pr_number: - description: 'PR number to test' - required: true - type: string - -permissions: - contents: read - statuses: write - -jobs: - test: - runs-on: ubuntu-latest - timeout-minutes: 15 - steps: - - name: Fetch PR metadata - id: pr - env: - GH_TOKEN: ${{ github.token }} - run: | - PR_DATA=$(gh api repos/${{ github.repository }}/pulls/${{ inputs.pr_number }}) - HEAD_SHA=$(echo "$PR_DATA" | jq -r '.head.sha') - HEAD_REF=$(echo "$PR_DATA" | jq -r '.head.ref') - HEAD_REPO=$(echo "$PR_DATA" | jq -r '.head.repo.full_name') - BASE_REF=$(echo "$PR_DATA" | jq -r '.base.ref') - echo "head_sha=$HEAD_SHA" >> "$GITHUB_OUTPUT" - echo "head_ref=$HEAD_REF" >> "$GITHUB_OUTPUT" - echo "head_repo=$HEAD_REPO" >> "$GITHUB_OUTPUT" - echo "base_ref=$BASE_REF" >> "$GITHUB_OUTPUT" - echo "Testing PR #${{ inputs.pr_number }}: $HEAD_REPO/$HEAD_REF → $BASE_REF (SHA: $HEAD_SHA)" - - - name: Set pending status - env: - GH_TOKEN: ${{ github.token }} - run: | - gh api repos/${{ github.repository }}/statuses/${{ steps.pr.outputs.head_sha }} \ - --method POST \ - --field state=pending \ - --field context="Squad CI / rerun" \ - --field description="Running CI rerun..." \ - --field target_url="${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" - - - uses: actions/checkout@v4 - with: - ref: refs/pull/${{ inputs.pr_number }}/merge - continue-on-error: true - id: checkout_merge - - - name: Fallback — checkout PR head directly - if: steps.checkout_merge.outcome == 'failure' - uses: actions/checkout@v4 - with: - repository: ${{ steps.pr.outputs.head_repo }} - ref: ${{ steps.pr.outputs.head_ref }} - - - uses: actions/setup-node@v4 - with: - node-version: 22 - cache: 'npm' - - - name: Fix stale lockfile entries - run: | - node -e " - const fs = require('fs'); - const lock = JSON.parse(fs.readFileSync('package-lock.json', 'utf8')); - const pkgs = lock.packages || {}; - const stale = Object.keys(pkgs).filter(k => - k.includes('/node_modules/@bradygaster/squad-') && - pkgs[k].resolved && pkgs[k].resolved.startsWith('https://') - ); - if (stale.length) { - stale.forEach(k => { console.log('Removing: ' + k); delete pkgs[k]; }); - fs.writeFileSync('package-lock.json', JSON.stringify(lock, null, 2) + '\n'); - } else { - console.log('Lockfile clean'); - } - " - - - name: Install dependencies - run: | - success=false - for i in 1 2 3; do - if npm install; then - success=true - break - fi - echo "Retry $i/3 — npm install failed, retrying in 5s..." - sleep 5 - done - if [ "$success" = false ]; then - echo "::error::npm install failed after 3 attempts" - exit 1 - fi - - - name: Install docs dependencies - run: | - success=false - for i in 1 2 3; do - if npm ci; then - success=true - break - fi - echo "Retry $i/3 — npm ci failed, retrying in 5s..." - sleep 5 - done - if [ "$success" = false ]; then - echo "::error::npm ci failed after 3 attempts" - exit 1 - fi - working-directory: docs - - - name: Install Playwright browsers - run: npx playwright install chromium --with-deps - - - name: Build - run: npm run build - - - name: Run tests - run: npm test - - - name: Set success status - if: success() - env: - GH_TOKEN: ${{ github.token }} - run: | - gh api repos/${{ github.repository }}/statuses/${{ steps.pr.outputs.head_sha }} \ - --method POST \ - --field state=success \ - --field context="Squad CI / rerun" \ - --field description="All checks passed" \ - --field target_url="${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" - - - name: Set failure status - if: failure() - env: - GH_TOKEN: ${{ github.token }} - run: | - gh api repos/${{ github.repository }}/statuses/${{ steps.pr.outputs.head_sha }} \ - --method POST \ - --field state=failure \ - --field context="Squad CI / rerun" \ - --field description="CI rerun failed — check logs" \ - --field target_url="${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" diff --git a/.github/workflows/squad-ci.yml b/.github/workflows/squad-ci.yml index 0dffd2f1f..7a13b6042 100644 --- a/.github/workflows/squad-ci.yml +++ b/.github/workflows/squad-ci.yml @@ -10,21 +10,20 @@ on: permissions: contents: read -# CI Hardening Phase 3 item A1: Prevent parallel runs from competing for resources +# Prevent parallel runs from competing for resources concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true jobs: # ── Path filter for conditional job execution ────────────────────────── - # Detects which areas of the repo changed so downstream jobs can skip - # when their inputs haven't changed (e.g., skip docs-quality on code-only PRs). changes: runs-on: ubuntu-latest timeout-minutes: 3 outputs: docs: ${{ steps.filter.outputs.docs }} code: ${{ steps.filter.outputs.code }} + workflows: ${{ steps.filter.outputs.workflows }} steps: - uses: actions/checkout@v4 with: @@ -45,12 +44,16 @@ jobs: else echo "docs=false" >> "$GITHUB_OUTPUT" fi - # Detect non-docs changes (code, config, workflows, etc.) if echo "$CHANGED" | grep -qvE '^(docs/|README\.md|\.markdownlint|\.cspell|cspell\.json)'; then echo "code=true" >> "$GITHUB_OUTPUT" else echo "code=false" >> "$GITHUB_OUTPUT" fi + if echo "$CHANGED" | grep -qE '^\.github/workflows/'; then + echo "workflows=true" >> "$GITHUB_OUTPUT" + else + echo "workflows=false" >> "$GITHUB_OUTPUT" + fi docs-quality: needs: changes @@ -59,30 +62,19 @@ jobs: timeout-minutes: 5 steps: - uses: actions/checkout@v4 - - uses: actions/setup-node@v4 with: node-version: 22 - - name: Install docs tools run: | success=false for i in 1 2 3; do - if npm install --no-save markdownlint-cli2 cspell; then - success=true - break - fi - echo "Retry $i/3 — npm install failed, retrying in 5s..." - sleep 5 + if npm install --no-save markdownlint-cli2 cspell; then success=true; break; fi + echo "Retry $i/3 — npm install failed, retrying in 5s..."; sleep 5 done - if [ "$success" = false ]; then - echo "::error::npm install failed after 3 attempts" - exit 1 - fi - + [ "$success" = true ] || { echo "::error::npm install failed after 3 attempts"; exit 1; } - name: Lint docs markdown run: npx markdownlint-cli2 - - name: Spell check docs run: npx cspell --no-progress --dot "docs/src/content/**/*.md" "README.md" @@ -98,12 +90,10 @@ jobs: timeout-minutes: 15 steps: - uses: actions/checkout@v4 - - uses: actions/setup-node@v4 with: node-version: 22 cache: 'npm' - - name: Fix stale lockfile entries run: | node -e " @@ -121,46 +111,27 @@ jobs: console.log('Lockfile clean'); } " - - name: Install dependencies run: | success=false for i in 1 2 3; do - if npm install; then - success=true - break - fi - echo "Retry $i/3 — npm install failed, retrying in 5s..." - sleep 5 + if npm install; then success=true; break; fi + echo "Retry $i/3 — npm install failed, retrying in 5s..."; sleep 5 done - if [ "$success" = false ]; then - echo "::error::npm install failed after 3 attempts" - exit 1 - fi - + [ "$success" = true ] || { echo "::error::npm install failed after 3 attempts"; exit 1; } - name: Install docs dependencies run: | success=false for i in 1 2 3; do - if npm ci; then - success=true - break - fi - echo "Retry $i/3 — npm ci failed, retrying in 5s..." - sleep 5 + if npm ci; then success=true; break; fi + echo "Retry $i/3 — npm ci failed, retrying in 5s..."; sleep 5 done - if [ "$success" = false ]; then - echo "::error::npm ci failed after 3 attempts" - exit 1 - fi + [ "$success" = true ] || { echo "::error::npm ci failed after 3 attempts"; exit 1; } working-directory: docs - - name: Install Playwright browsers run: npx playwright install chromium --with-deps - - name: "🔒 Source tree canary check" run: | - echo "Verifying critical source files exist..." MISSING=0 for f in \ "packages/squad-sdk/src/index.ts" \ @@ -177,7 +148,6 @@ jobs: exit 1 fi echo "✅ All critical source files present" - - name: "🔒 Large deletion guard" if: github.event_name == 'pull_request' run: | @@ -194,37 +164,17 @@ jobs: fi env: GH_TOKEN: ${{ github.token }} - - name: Build run: npm run build - - name: Run tests run: npm test - # ════════════════════════════════════════════════════════════════════════ - # Skip Labels Reference - # ──────────────────────────────────────────────────────────────────────── - # The following PR labels can be used to bypass specific health gates. - # Add them via the GitHub UI or `gh pr edit --add-label