microsoft/hve-core
Publicmirrored fromhttps://github.com/microsoft/hve-coreAvailable
.github/workflows/copilot-setup-steps.yml
146lines · modecode
| 1 | # Copyright (c) Microsoft Corporation. |
| 2 | # SPDX-License-Identifier: MIT |
| 3 | # |
| 4 | # copilot-setup-steps.yml |
| 5 | # Pre-install tools and dependencies for GitHub Copilot Coding Agent |
| 6 | # Reference: https://docs.github.com/en/copilot/how-tos/use-copilot-agents/coding-agent/customize-the-agent-environment |
| 7 | |
| 8 | name: "Copilot Setup Steps" |
| 9 | |
| 10 | # Copilot coding agent runs these steps internally before starting work. |
| 11 | # Use workflow_dispatch to manually validate the setup when desired. |
| 12 | on: |
| 13 | workflow_dispatch: |
| 14 | |
| 15 | # Minimal permissions |
| 16 | permissions: |
| 17 | contents: read |
| 18 | |
| 19 | concurrency: |
| 20 | group: ${{ github.workflow }}-${{ github.ref }} |
| 21 | cancel-in-progress: false |
| 22 | |
| 23 | jobs: |
| 24 | # Job MUST be named 'copilot-setup-steps' to be recognized by Copilot |
| 25 | copilot-setup-steps: |
| 26 | runs-on: ubuntu-latest |
| 27 | |
| 28 | # Minimal permissions; Copilot receives its own token for operations |
| 29 | permissions: |
| 30 | contents: read |
| 31 | |
| 32 | steps: |
| 33 | - name: Checkout code |
| 34 | uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| 35 | with: |
| 36 | persist-credentials: false |
| 37 | |
| 38 | - name: Set up Node.js |
| 39 | uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0 |
| 40 | with: |
| 41 | node-version: "24" |
| 42 | cache: "npm" |
| 43 | |
| 44 | # continue-on-error allows Copilot to start work even if dependencies fail, |
| 45 | # so it can fix package.json/package-lock.json issues itself |
| 46 | - name: Install JavaScript dependencies |
| 47 | continue-on-error: true |
| 48 | run: npm ci |
| 49 | |
| 50 | - name: Set up Python |
| 51 | uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0 |
| 52 | with: |
| 53 | python-version: "3.11" |
| 54 | |
| 55 | - name: Install actionlint |
| 56 | env: |
| 57 | ACTIONLINT_VERSION: '1.7.10' |
| 58 | ACTIONLINT_AMD64_SHA256: 'f4c76b71db5755a713e6055cbb0857ed07e103e028bda117817660ebadb4386f' |
| 59 | ACTIONLINT_ARM64_SHA256: 'cd3dfe5f66887ec6b987752d8d9614e59fd22f39415c5ad9f28374623f41773a' |
| 60 | GITHUB_RELEASES_URL: ${{ vars.HVE_GITHUB_RELEASES_URL || 'https://github.com' }} |
| 61 | run: | |
| 62 | ARCH=$(uname -m) |
| 63 | if [[ "${ARCH}" == "x86_64" ]]; then |
| 64 | ACTIONLINT_ARCH="amd64" |
| 65 | ACTIONLINT_SHA256="${ACTIONLINT_AMD64_SHA256}" |
| 66 | elif [[ "${ARCH}" == "aarch64" ]]; then |
| 67 | ACTIONLINT_ARCH="arm64" |
| 68 | ACTIONLINT_SHA256="${ACTIONLINT_ARM64_SHA256}" |
| 69 | else |
| 70 | echo "ERROR: Unsupported architecture for actionlint: ${ARCH}" >&2 |
| 71 | exit 1 |
| 72 | fi |
| 73 | curl -sSfL "${GITHUB_RELEASES_URL}/rhysd/actionlint/releases/download/v${ACTIONLINT_VERSION}/actionlint_${ACTIONLINT_VERSION}_linux_${ACTIONLINT_ARCH}.tar.gz" -o /tmp/actionlint.tar.gz |
| 74 | echo "${ACTIONLINT_SHA256} /tmp/actionlint.tar.gz" | sha256sum -c - |
| 75 | tar -xzf /tmp/actionlint.tar.gz actionlint |
| 76 | sudo install actionlint /usr/local/bin/actionlint |
| 77 | rm actionlint /tmp/actionlint.tar.gz |
| 78 | actionlint --version |
| 79 | |
| 80 | - name: Install PowerShell modules |
| 81 | shell: pwsh |
| 82 | env: |
| 83 | HVE_PSGALLERY_REPOSITORY: ${{ vars.HVE_PSGALLERY_REPOSITORY || '' }} |
| 84 | HVE_PSGALLERY_SOURCE_URL: ${{ vars.HVE_PSGALLERY_SOURCE_URL || '' }} |
| 85 | run: | |
| 86 | $repo = if ($env:HVE_PSGALLERY_REPOSITORY) { $env:HVE_PSGALLERY_REPOSITORY } else { 'PSGallery' } |
| 87 | if ($env:HVE_PSGALLERY_SOURCE_URL) { |
| 88 | Register-PSRepository -Name $repo -SourceLocation $env:HVE_PSGALLERY_SOURCE_URL -InstallationPolicy Trusted -ErrorAction SilentlyContinue |
| 89 | } |
| 90 | Install-Module -Name PowerShell-Yaml -Force -Scope CurrentUser -Repository $repo |
| 91 | Install-Module -Name PSScriptAnalyzer -Force -Scope CurrentUser -Repository $repo |
| 92 | Install-Module -Name Pester -RequiredVersion 5.7.1 -Force -Scope CurrentUser -Repository $repo |
| 93 | |
| 94 | - name: Install uv package manager |
| 95 | env: |
| 96 | UV_VERSION: '0.10.8' |
| 97 | UV_X86_64_SHA256: 'f0c566b55683395a62fefb9261a060fa09824914b5682c3b9629fa154762ae2f' |
| 98 | UV_AARCH64_SHA256: '661860e954f87dcd823251191866af3486484d1a9df60eed56f4586ed7559e3d' |
| 99 | GITHUB_RELEASES_URL: ${{ vars.HVE_GITHUB_RELEASES_URL || 'https://github.com' }} |
| 100 | run: | |
| 101 | ARCH=$(uname -m) |
| 102 | if [[ "${ARCH}" == "x86_64" ]]; then |
| 103 | UV_ARCH="x86_64-unknown-linux-gnu" |
| 104 | UV_SHA256="${UV_X86_64_SHA256}" |
| 105 | elif [[ "${ARCH}" == "aarch64" ]]; then |
| 106 | UV_ARCH="aarch64-unknown-linux-gnu" |
| 107 | UV_SHA256="${UV_AARCH64_SHA256}" |
| 108 | else |
| 109 | echo "ERROR: Unsupported architecture for uv: ${ARCH}" >&2 |
| 110 | exit 1 |
| 111 | fi |
| 112 | curl -sSfL "${GITHUB_RELEASES_URL}/astral-sh/uv/releases/download/${UV_VERSION}/uv-${UV_ARCH}.tar.gz" -o /tmp/uv.tar.gz |
| 113 | echo "${UV_SHA256} /tmp/uv.tar.gz" | sha256sum -c - |
| 114 | sudo tar -xzf /tmp/uv.tar.gz -C /usr/local/bin --strip-components=1 "uv-${UV_ARCH}/uv" "uv-${UV_ARCH}/uvx" |
| 115 | rm /tmp/uv.tar.gz |
| 116 | uv --version |
| 117 | uvx --version |
| 118 | echo "Syncing Python environments for skills..." |
| 119 | failed=0 |
| 120 | while IFS= read -r -d '' f; do |
| 121 | dir="$(dirname "${f}")" |
| 122 | echo "Installing dependencies in ${dir}" |
| 123 | if ! (cd "${dir}" && uv sync); then |
| 124 | echo "::error::uv sync failed in ${dir}" |
| 125 | failed=1 |
| 126 | fi |
| 127 | done < <(find .github/skills -name pyproject.toml -type f -print0) |
| 128 | if [[ "${failed}" -ne 0 ]]; then |
| 129 | echo "::error::One or more skill dependency installations failed" |
| 130 | exit 1 |
| 131 | fi |
| 132 | |
| 133 | - name: Verify tool availability |
| 134 | run: | |
| 135 | echo "=== Tool Versions ===" |
| 136 | node --version |
| 137 | npm --version |
| 138 | python3 --version |
| 139 | pwsh --version |
| 140 | shellcheck --version |
| 141 | actionlint --version |
| 142 | uv --version |
| 143 | uvx --version |
| 144 | echo "" |
| 145 | echo "=== npm Scripts Available ===" |
| 146 | npm run --list |