singularity-forge/.github/workflows/ci.yml
Tom Boucher c1c7f8b6b0 perf(ci): reduce pipeline minutes with shallow clones, npm caching, and exponential backoff (#1700)
CI workflow:
- Replace fetch-depth: 0 with shallow clones (depth 1-2) in lint and
  build jobs — saves ~30-60s per job
- Remove fetch-depth: 0 from build and windows-portability (default
  depth 1 is sufficient for build/test)

Pipeline workflow:
- Add cache: 'npm' to dev-publish, test-verify, and prod-release
  setup-node steps — saves ~1-2 min per job on npm ci
- Move ${{ }} expressions from run: blocks to env: variables in
  prod-release and update-builder to prevent command injection vectors
- Use fetch-depth: 2 in update-builder (only needs parent diff)

Build-native workflow:
- Replace hardcoded sleep 30 + single verification with exponential
  backoff polling (5s → 10s → 20s → 30s cap, max 5 attempts)
- Replace fixed 15s retry intervals in post-publish smoke test with
  exponential backoff (5s → 10s → 20s → 30s cap, 8 attempts)
- Replace fixed 15s dist-tag verification loop with exponential
  backoff (6 attempts vs 10 × 15s)

Estimated savings: ~5-10 min per full CI+pipeline run, ~1-3 min per
native build publish.

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-authored-by: TÂCHES <afromanguy@me.com>
2026-03-21 08:43:56 -06:00

158 lines
4.1 KiB
YAML

name: CI
on:
push:
branches: [main]
paths-ignore:
- '.github/workflows/ai-triage.yml'
- '.github/workflows/build-native.yml'
- '.github/workflows/cleanup-dev-versions.yml'
- '.github/workflows/pipeline.yml'
- 'LICENSE'
pull_request:
branches: [main]
paths-ignore:
- '.github/workflows/ai-triage.yml'
- '.github/workflows/build-native.yml'
- '.github/workflows/cleanup-dev-versions.yml'
- '.github/workflows/pipeline.yml'
- 'LICENSE'
concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true
jobs:
detect-changes:
runs-on: ubuntu-latest
outputs:
docs-only: ${{ steps.check.outputs.docs-only }}
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Check if only documentation changed
id: check
env:
PR_BASE_SHA: ${{ github.event.pull_request.base.sha }}
PUSH_BEFORE_SHA: ${{ github.event.before }}
EVENT_NAME: ${{ github.event_name }}
HEAD_SHA: ${{ github.sha }}
run: |
if [ "$EVENT_NAME" = "pull_request" ]; then
BASE="$PR_BASE_SHA"
else
BASE="$PUSH_BEFORE_SHA"
fi
FILES=$(git diff --name-only "$BASE" "$HEAD_SHA" 2>/dev/null || git diff --name-only HEAD~1)
echo "Changed files:"
echo "$FILES"
NON_DOCS=$(echo "$FILES" | grep -vE '\.(md|markdown)$' | grep -vE '^docs/' | grep -vE '^LICENSE$' || true)
if [ -z "$NON_DOCS" ]; then
echo "docs-only=true" >> "$GITHUB_OUTPUT"
echo "::notice::Only documentation files changed — skipping build/test"
else
echo "docs-only=false" >> "$GITHUB_OUTPUT"
echo "Non-docs files changed:"
echo "$NON_DOCS"
fi
docs-check:
runs-on: ubuntu-latest
needs: detect-changes
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Scan documentation for prompt injection
run: bash scripts/docs-prompt-injection-scan.sh --diff origin/main
lint:
needs: detect-changes
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 2
- name: Scan for hardcoded secrets
run: bash scripts/secret-scan.sh --diff origin/main
- name: Ensure .gsd/ is not checked in
run: |
if [ -d ".gsd" ]; then
echo "::error::.gsd/ directory must not be checked in"
exit 1
fi
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: '24'
- name: Validate skill references
run: node scripts/check-skill-references.mjs
build:
needs: detect-changes
if: needs.detect-changes.outputs.docs-only != 'true'
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: '24'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Build
run: npm run build
- name: Typecheck extensions
run: npm run typecheck:extensions
- name: Validate package is installable
run: npm run validate-pack
- name: Run unit tests
run: npm run test:unit
- name: Run integration tests
run: npm run test:integration
windows-portability:
needs: detect-changes
if: >-
needs.detect-changes.outputs.docs-only != 'true' &&
github.event_name == 'push' && github.ref == 'refs/heads/main'
runs-on: windows-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: '24'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Build
run: npm run build
- name: Typecheck extensions
run: npm run typecheck:extensions
- name: Run unit tests
run: npm run test:unit