diff --git a/.github/workflows/copilot-setup-steps.yml b/.github/workflows/copilot-setup-steps.yml new file mode 100644 index 00000000..a7a21d4c --- /dev/null +++ b/.github/workflows/copilot-setup-steps.yml @@ -0,0 +1,95 @@ +# ───────────────────────────────────────────────────────────────────────────── +# SOURCE OF TRUTH: petry-projects/.github/standards/workflows/copilot-setup-steps.yml +# Standard: petry-projects/.github/standards/ci-standards.md#11-copilot-cloud-agent-setup +# +# ADOPTING THIS WORKFLOW: +# 1. Copy this file to .github/workflows/copilot-setup-steps.yml in your repo. +# 2. Keep every REQUIRED section — do NOT remove the checkout or verify steps. +# 3. Uncomment and adapt the stack blocks that match your repo's tech stack. +# 4. Delete (not just comment out) stacks that do not apply after initial setup. +# 5. Merge to the default branch — the workflow only triggers from the default branch. +# 6. Run manually from Actions → "Copilot Setup Steps" → "Run workflow" to verify. +# +# WHAT THIS FILE DOES: +# Bootstraps Copilot cloud agent's ephemeral environment BEFORE the agent starts +# working on your repo. Pre-installing dependencies deterministically: +# • Speeds up every agent session (no trial-and-error dependency discovery) +# • Makes private/internal packages available (impossible for the agent alone) +# • Ensures exact tool versions that match your CI pipeline +# Without this file the agent installs dependencies itself — slower, non-deterministic, +# and unreliable for repos with private packages or complex build graphs. +# +# SEE ALSO: +# AGENTS.md — authoritative development standards for this repo +# .github/copilot-instructions.md — always-on Copilot instructions (summary of AGENTS.md) +# .github/instructions/ — path-scoped instruction files per language +# +# CONSTRAINTS (enforced by GitHub, documented at docs.github.com): +# • Job MUST be named `copilot-setup-steps` to be recognized by Copilot cloud agent +# • timeout-minutes maximum: 59 (hard limit) +# • Customizable fields: steps, permissions, runs-on, services, snapshot, timeout-minutes +# • All other job-level settings are silently ignored by GitHub +# • fetch-depth on checkout is always overridden by the agent — do not rely on it here +# • This file MUST be present on the default branch to take effect +# +# STACK: documentation / scripts only — no build dependencies to install +# ───────────────────────────────────────────────────────────────────────────── + +name: "Copilot Setup Steps" + +on: + workflow_dispatch: + push: + paths: + - .github/workflows/copilot-setup-steps.yml + pull_request: + paths: + - .github/workflows/copilot-setup-steps.yml + +permissions: {} + +jobs: + copilot-setup-steps: + # Skip on fork-origin pull requests — forks cannot access org secrets required for private packages. + if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.fork == false + + runs-on: ubuntu-latest + timeout-minutes: 10 + + permissions: + contents: read + + steps: + - name: Checkout code + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + + - name: Verify environment + run: | + echo "=== petry-projects Copilot cloud agent environment ===" + echo "Repository : ${{ github.repository }}" + echo "Ref : ${{ github.ref }}" + echo "Runner : ${{ runner.os }} / ${{ runner.arch }}" + echo "" + echo "--- Installed tool versions ---" + git --version + gh --version 2>/dev/null | head -1 || echo "gh: not installed" + echo "" + echo "--- Agent instruction files ---" + if [ -f "AGENTS.md" ]; then + echo "✅ AGENTS.md ($(wc -l < AGENTS.md) lines)" + else + echo "❌ AGENTS.md — MISSING. Add this file per agent-standards.md." + exit 1 + fi + if [ -f ".github/copilot-instructions.md" ]; then + echo "✅ .github/copilot-instructions.md" + else + echo "ℹ️ .github/copilot-instructions.md — not present (optional but recommended)" + fi + INSTR_COUNT=0 + if [ -d ".github/instructions" ]; then + INSTR_COUNT=$(find .github/instructions -name "*.instructions.md" | wc -l) + fi + echo "ℹ️ .github/instructions/: ${INSTR_COUNT} file(s)" + echo "" + echo "✅ Setup complete — Copilot cloud agent is ready to work"