|
| 1 | +# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. |
| 2 | +# |
| 3 | +# SPDX-License-Identifier: Apache-2.0 |
| 4 | + |
| 5 | +# Scheduled (and on-demand) pixi lockfile refresh. Each workspace gets its own |
| 6 | +# PR so a benchmark or docs environment cannot drag unrelated package churn |
| 7 | +# into review. See #2298. |
| 8 | + |
| 9 | +name: "CI: pixi lockfile refresh" |
| 10 | + |
| 11 | +on: |
| 12 | + schedule: |
| 13 | + # Monday 03:17 Eastern. GitHub handles the DST offset for the IANA zone, |
| 14 | + # and a non-zero minute avoids the start-of-hour window where GitHub |
| 15 | + # documents scheduled runs being delayed or dropped. |
| 16 | + - cron: "17 3 * * 1" |
| 17 | + timezone: "America/New_York" |
| 18 | + workflow_dispatch: |
| 19 | + inputs: |
| 20 | + package: |
| 21 | + description: > |
| 22 | + Pixi workspace id to refresh, or "all". Valid ids come from |
| 23 | + ci/tools/list_pixi_workspaces.py; an unknown id fails the run. |
| 24 | + type: string |
| 25 | + default: all |
| 26 | + |
| 27 | +defaults: |
| 28 | + run: |
| 29 | + shell: bash --noprofile --norc -xeuo pipefail {0} |
| 30 | + |
| 31 | +env: |
| 32 | + # Keep in sync with ci-pixi-source-test.yml. |
| 33 | + PIXI_VERSION: "v0.73.0" |
| 34 | + |
| 35 | +permissions: {} |
| 36 | + |
| 37 | +jobs: |
| 38 | + # Job-level `if` cannot use `matrix` (evaluated before expansion), and the |
| 39 | + # workspace list must not drift from the committed manifests, so resolve the |
| 40 | + # requested workspaces here and pass them to refresh as a dynamic matrix. |
| 41 | + plan: |
| 42 | + name: Select workspaces |
| 43 | + if: ${{ github.repository_owner == 'nvidia' }} |
| 44 | + runs-on: ubuntu-latest |
| 45 | + timeout-minutes: 5 |
| 46 | + permissions: |
| 47 | + contents: read |
| 48 | + outputs: |
| 49 | + matrix: ${{ steps.select.outputs.matrix }} |
| 50 | + steps: |
| 51 | + - name: Checkout ${{ github.event.repository.name }} |
| 52 | + uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 |
| 53 | + with: |
| 54 | + fetch-depth: 1 |
| 55 | + persist-credentials: false |
| 56 | + |
| 57 | + - name: Select workspaces to refresh |
| 58 | + id: select |
| 59 | + env: |
| 60 | + PACKAGE: ${{ inputs.package || 'all' }} |
| 61 | + run: | |
| 62 | + workspaces="$(python3 ci/tools/list_pixi_workspaces.py --select "${PACKAGE}")" |
| 63 | + echo "matrix=$(jq -c '{include: .}' <<<"${workspaces}")" >> "${GITHUB_OUTPUT}" |
| 64 | +
|
| 65 | + refresh: |
| 66 | + name: "pixi update (${{ matrix.id }})" |
| 67 | + needs: plan |
| 68 | + runs-on: ubuntu-latest |
| 69 | + timeout-minutes: 30 |
| 70 | + permissions: |
| 71 | + contents: write |
| 72 | + pull-requests: write |
| 73 | + concurrency: |
| 74 | + group: pixi-lock-refresh-${{ matrix.id }} |
| 75 | + cancel-in-progress: false |
| 76 | + strategy: |
| 77 | + fail-fast: false |
| 78 | + matrix: ${{ fromJSON(needs.plan.outputs.matrix) }} |
| 79 | + steps: |
| 80 | + - name: Checkout ${{ github.event.repository.name }} |
| 81 | + uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 |
| 82 | + with: |
| 83 | + fetch-depth: 0 |
| 84 | + ref: ${{ github.event.repository.default_branch }} |
| 85 | + |
| 86 | + # GitHub suppresses workflow-triggering events for pushes and PRs made |
| 87 | + # with GITHUB_TOKEN, so a refresh PR opened with the default token cannot |
| 88 | + # reach a green required-check state on its own. An App token restores |
| 89 | + # normal event delivery; without one the PR needs a manual nudge, which |
| 90 | + # the PR body and a run warning spell out. |
| 91 | + - name: Mint App token for the refresh PR |
| 92 | + id: app-token |
| 93 | + if: ${{ vars.PIXI_LOCK_REFRESH_APP_ID != '' }} |
| 94 | + uses: actions/create-github-app-token@fee1f7d63c2ff003460e3d139729b119787bc349 # v2.2.2 |
| 95 | + with: |
| 96 | + app-id: ${{ vars.PIXI_LOCK_REFRESH_APP_ID }} |
| 97 | + private-key: ${{ secrets.PIXI_LOCK_REFRESH_APP_PRIVATE_KEY }} |
| 98 | + |
| 99 | + - name: Setup pixi |
| 100 | + # Pinned to a commit SHA; install logic lives in the action and is |
| 101 | + # auditable/pinned (vs. a curl|bash of an unverified installer). |
| 102 | + uses: prefix-dev/setup-pixi@5185adfbffb4bd703da3010310260805d89ebb11 # v0.9.6 |
| 103 | + with: |
| 104 | + pixi-version: ${{ env.PIXI_VERSION }} |
| 105 | + run-install: false |
| 106 | + |
| 107 | + - name: Update lockfile without installing |
| 108 | + run: pixi update --no-install --manifest-path "${{ matrix.manifest }}" |
| 109 | + |
| 110 | + - name: Compose PR body |
| 111 | + id: pr-body |
| 112 | + env: |
| 113 | + WORKSPACE_ID: ${{ matrix.id }} |
| 114 | + MANIFEST: ${{ matrix.manifest }} |
| 115 | + HAS_APP_TOKEN: ${{ steps.app-token.outputs.token != '' }} |
| 116 | + run: | |
| 117 | + body_path="${RUNNER_TEMP}/pixi-lock-refresh-body.md" |
| 118 | + { |
| 119 | + echo "Automated lockfile refresh for \`${WORKSPACE_ID}\`" \ |
| 120 | + "(\`pixi update --no-install --manifest-path ${MANIFEST}\`)." |
| 121 | + echo |
| 122 | + echo "This PR is workspace-scoped so other packages are not forced to review" |
| 123 | + echo "unrelated solver churn. See #2298." |
| 124 | + echo |
| 125 | + if [ "${HAS_APP_TOKEN}" != "true" ]; then |
| 126 | + echo "> [!IMPORTANT]" |
| 127 | + echo "> No refresh App token is configured, so this PR was opened with" |
| 128 | + echo "> \`GITHUB_TOKEN\` and GitHub will not deliver its \`pull_request\` events." |
| 129 | + echo "> Required checks stay pending until a maintainer nudges the branch, by" |
| 130 | + echo "> closing and reopening the PR or pushing an empty commit to it." |
| 131 | + echo |
| 132 | + fi |
| 133 | + echo "If the diff looks wrong, close this PR and leave the branch deleted; the" |
| 134 | + echo "next scheduled run opens a fresh one if an update is still needed." |
| 135 | + } > "${body_path}" |
| 136 | + echo "path=${body_path}" >> "${GITHUB_OUTPUT}" |
| 137 | +
|
| 138 | + if [ "${HAS_APP_TOKEN}" != "true" ]; then |
| 139 | + echo "::warning::Opened with GITHUB_TOKEN; the refresh PR's checks must be triggered manually." |
| 140 | + fi |
| 141 | +
|
| 142 | + - name: Open or update a lockfile-only PR |
| 143 | + id: cpr |
| 144 | + uses: peter-evans/create-pull-request@5f6978faf089d4d20b00c7766989d076bb2fc7f1 # v8.1.1 |
| 145 | + with: |
| 146 | + token: ${{ steps.app-token.outputs.token || github.token }} |
| 147 | + add-paths: ${{ matrix.lockfile }} |
| 148 | + commit-message: | |
| 149 | + chore: refresh pixi.lock for ${{ matrix.id }} |
| 150 | +
|
| 151 | + Scheduled pixi update --no-install for this workspace only. |
| 152 | + signoff: true |
| 153 | + sign-commits: true |
| 154 | + branch: ci/pixi-lock-refresh/${{ matrix.id }} |
| 155 | + delete-branch: true |
| 156 | + title: "chore: refresh pixi.lock (${{ matrix.id }})" |
| 157 | + labels: | |
| 158 | + CI/CD |
| 159 | + dependencies |
| 160 | + body-path: ${{ steps.pr-body.outputs.path }} |
| 161 | + author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> |
| 162 | + committer: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> |
| 163 | + |
| 164 | + - name: Summarize |
| 165 | + run: | |
| 166 | + { |
| 167 | + echo "### pixi lock refresh (${{ matrix.id }})" |
| 168 | + echo "" |
| 169 | + echo "- Manifest: \`${{ matrix.manifest }}\`" |
| 170 | + echo "- Lockfile: \`${{ matrix.lockfile }}\`" |
| 171 | + echo "- Operation: \`${{ steps.cpr.outputs.pull-request-operation }}\`" |
| 172 | + if [ -n "${{ steps.cpr.outputs.pull-request-url }}" ]; then |
| 173 | + echo "- PR: ${{ steps.cpr.outputs.pull-request-url }}" |
| 174 | + else |
| 175 | + echo "- No lockfile diff; PR not opened." |
| 176 | + fi |
| 177 | + } >> "$GITHUB_STEP_SUMMARY" |
0 commit comments