Skip to content

Commit 6c93bdf

Browse files
authored
Add prod (whl) S3 dependency updates gated behind promote-env (#8260)
## What `update-s3-dependencies.yml` currently updates the S3 HTML dependency listings for **nightly** and **test** only. This adds an opt-in path to also update **prod** (`whl`), gated behind the protected `promote-env` (mirroring `release-download-pytorch-org.yml`). ## Changes - **Workflow**: new `include-prod` input (choice, default `disabled`) and a new `update-prod` job that: - runs `environment: promote-env` (so prod updates require the environment's approval/protection rules), - assumes `arn:aws:iam::749337293305:role/gha_workflow_promote_wheels` and uses the prod R2 secrets (`R2_ACCOUNT_ID` / `R2_ACCESS_KEY_ID` / `R2_SECRET_ACCESS_KEY`), matching `release-download-pytorch-org.yml`, - only runs in `update-packages` mode when `include-prod == enabled`. - **`s3_management/update_dependencies.py`**: new `--stable-only` flag so the prod job updates only the `whl` prefix rather than redundantly rewriting `whl/nightly` and `whl/test` under the protected environment. Default behavior (nightly + test, and `--include-stable`) is unchanged. ## Behavior - Default dispatch: unchanged — the existing `update` job updates nightly + test under `pytorchbot-env`. - With `include-prod=enabled`: the `update-prod` job additionally updates the prod `whl` index for the selected package, subject to `promote-env` approval. - Honors the existing `dryrun` input. ## Not a duplicate No existing open PR adds prod dependency updates / promote-env gating to `update-s3-dependencies.yml`. ## Test plan - `python -c "import ast; ast.parse(...)"` on `update_dependencies.py` (OK). - YAML parses; jobs are `update` + `update-prod`; `update-prod.environment == promote-env`; `include-prod` input present. - Recommend a `dryrun=enabled`, `include-prod=enabled` dispatch to confirm the prod job only touches the `whl` prefix. AI assistance (Claude) was used for this change. --------- Signed-off-by: Andrey Talman <atalman@users.noreply.github.com> Co-authored-by: Andrey Talman <atalman@users.noreply.github.com>
1 parent f75bb0d commit 6c93bdf

2 files changed

Lines changed: 70 additions & 3 deletions

File tree

.github/workflows/update-s3-dependencies.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,24 @@ on:
3535
description: 'Target to create (e.g., rocm7.2, cu130) - only for create-target mode'
3636
required: false
3737
type: string
38+
include-prod:
39+
description: 'Update prod (whl) dependencies only, via promote-env (skips nightly/test; update-packages mode only)'
40+
required: false
41+
type: choice
42+
default: disabled
43+
options:
44+
- disabled
45+
- enabled
3846

3947
permissions:
4048
id-token: write
4149
contents: read
4250

4351
jobs:
52+
# Nightly + test updates. Skipped when include-prod is enabled, so a prod
53+
# run only touches prod (the update-prod job below) and never nightly/test.
4454
update:
55+
if: ${{ github.event.inputs.include-prod != 'enabled' }}
4556
runs-on: ubuntu-22.04
4657
environment: pytorchbot-env
4758
container:
@@ -139,3 +150,50 @@ jobs:
139150
140151
# shellcheck disable=SC2086
141152
python3 s3_management/update_dependencies.py ${ARGS}
153+
154+
# Prod (whl) dependency updates are gated behind the protected promote-env,
155+
# mirroring release-download-pytorch-org.yml. Opt-in via the include-prod
156+
# input; runs only in update-packages mode.
157+
update-prod:
158+
if: ${{ github.event.inputs.mode == 'update-packages' && github.event.inputs.include-prod == 'enabled' }}
159+
runs-on: ubuntu-22.04
160+
environment: promote-env
161+
container:
162+
image: continuumio/miniconda3:23.10.0-1
163+
steps:
164+
- name: Configure AWS credentials
165+
uses: aws-actions/configure-aws-credentials@50ac8dd1e1b10d09dac7b8727528b91bed831ac0 # v3.0.2
166+
with:
167+
role-to-assume: arn:aws:iam::749337293305:role/gha_workflow_promote_wheels
168+
aws-region: us-east-1
169+
170+
- name: Checkout repository test-infra
171+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
172+
with:
173+
repository: pytorch/test-infra
174+
ref: ${{ github.ref }}
175+
176+
- name: Install dependencies
177+
run: |
178+
pip install -r s3_management/requirements.txt
179+
180+
- name: Update prod (stable) packages
181+
shell: bash
182+
env:
183+
DRYRUN: ${{ github.event.inputs.dryrun }}
184+
PACKAGE: ${{ github.event.inputs.package || 'torch' }}
185+
R2_ACCOUNT_ID: ${{ secrets.R2_ACCOUNT_ID }}
186+
R2_ACCESS_KEY_ID: ${{ secrets.R2_ACCESS_KEY_ID }}
187+
R2_SECRET_ACCESS_KEY: ${{ secrets.R2_SECRET_ACCESS_KEY }}
188+
R2_BUCKET_NAME: "pytorch-downloads"
189+
run: |
190+
set -ex
191+
192+
ARGS="--package ${PACKAGE} --stable-only"
193+
194+
if [[ "${DRYRUN}" == "enabled" ]]; then
195+
ARGS="${ARGS} --dry-run"
196+
fi
197+
198+
# shellcheck disable=SC2086
199+
python3 s3_management/update_dependencies.py ${ARGS}

s3_management/update_dependencies.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1329,6 +1329,11 @@ def main() -> None:
13291329
parser.add_argument("--package", choices=project_paths, default="torch")
13301330
parser.add_argument("--dry-run", action="store_true")
13311331
parser.add_argument("--include-stable", action="store_true")
1332+
parser.add_argument(
1333+
"--stable-only",
1334+
action="store_true",
1335+
help="Update only the stable/prod prefix (whl), skipping nightly and test",
1336+
)
13321337

13331338
# Arguments for target creation
13341339
parser.add_argument(
@@ -1407,9 +1412,13 @@ def main() -> None:
14071412
return
14081413

14091414
# Original behavior: update all dependencies for specified package
1410-
SUBFOLDERS = ["whl/nightly", "whl/test"]
1411-
if args.include_stable:
1412-
SUBFOLDERS.append("whl")
1415+
if args.stable_only:
1416+
# Prod-only update (gated behind the promote-env in CI).
1417+
SUBFOLDERS = ["whl"]
1418+
else:
1419+
SUBFOLDERS = ["whl/nightly", "whl/test"]
1420+
if args.include_stable:
1421+
SUBFOLDERS.append("whl")
14131422

14141423
for prefix in SUBFOLDERS:
14151424
# Process each package and its multiple configurations

0 commit comments

Comments
 (0)