Skip to content

Commit 63a421e

Browse files
authored
Merge 62a395e into 4236dca
2 parents 4236dca + 62a395e commit 63a421e

5 files changed

Lines changed: 68 additions & 65 deletions

File tree

.github/workflows/_lambda-do-release-runners.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,11 +131,64 @@ jobs:
131131
if-no-files-found: error
132132
retention-days: 1
133133

134+
build-greenlight-lambda:
135+
name: Build greenlight lambda
136+
runs-on: ubuntu-latest
137+
# greenlight builds on its own mise/uv/just toolchain (cp313) rather than the
138+
# `make deployment.zip` convention, so it gets its own job. Non-blocking for the
139+
# same reason as the advisor-coverage leg: a greenlight build failure must not
140+
# block publishing the shared lambda release (pytorch-auto-revert et al.). A
141+
# failed continue-on-error job reports success to `release`'s `needs`, and simply
142+
# omits its zip.
143+
continue-on-error: true
144+
permissions:
145+
contents: read
146+
steps:
147+
- name: Checkout code
148+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
149+
with:
150+
ref: ${{ inputs.tag }}
151+
152+
- uses: jdx/mise-action@dad1bfd3df957f44999b559dd69dc1671cb4e9ea # v4.2.1
153+
with:
154+
working_directory: greenlight
155+
156+
- name: Sync dependencies
157+
working-directory: greenlight
158+
run: just setup
159+
160+
- name: Package lambda zip
161+
working-directory: greenlight
162+
run: just package
163+
164+
- name: Smoke-test the built zip imports on Python 3.13
165+
# -S drops site-packages so imports resolve only from the extracted zip, not the
166+
# project .venv that mise puts on sys.path; the test exercises the artifact itself.
167+
working-directory: greenlight
168+
run: |
169+
set -euo pipefail
170+
smoke_dir="$(mktemp -d)"
171+
unzip -q dist/greenlight-scan.zip -d "${smoke_dir}"
172+
PYTHONPATH="${smoke_dir}" mise exec -- python -S -c \
173+
"import greenlight.lambda_handler, greenlight.cli, boto3, github, clickhouse_connect, yaml"
174+
175+
- name: Copy greenlight-scan.zip to root
176+
run: cp greenlight/dist/greenlight-scan.zip greenlight-scan.zip
177+
178+
- name: Stage greenlight-scan zip
179+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
180+
with:
181+
name: lambda-greenlight-scan
182+
path: greenlight-scan.zip
183+
if-no-files-found: error
184+
retention-days: 1
185+
134186
release:
135187
name: Publish release
136188
needs:
137189
- build-runner-lambdas
138190
- build-python-lambdas
191+
- build-greenlight-lambda
139192
runs-on: ubuntu-latest
140193
permissions:
141194
contents: write

.github/workflows/greenlight-lambda-release.yml

Lines changed: 0 additions & 57 deletions
This file was deleted.

.github/workflows/lambda-release-tag-runners.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ on:
88
paths:
99
- 'terraform-aws-github-runner/**'
1010
- 'aws/lambda/**'
11+
- 'greenlight/**'
1112
pull_request: # Generate tag when PR modifies this workflow file
1213
paths:
1314
- '.github/workflows/lambda-release-tag-runners.yml'

greenlight/CHEATSHEET.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,10 @@ just package # build dist/greenlight-scan.zip (linux x86_64 / cp313 wheels) fo
121121

122122
In production the scheduled scan runs as the `greenlight-scan` AWS Lambda
123123
(`pytorch-gha-infra-2`, `us-east-1`, EventBridge `rate(5 minutes)`), not via the CLI or a GHA
124-
workflow. Ship a new build with `just package` -> run the `greenlight-lambda-release.yml`
125-
workflow (publishes a `greenlight-lambda-v<timestamp>` Release with the zip) -> pin that tag in
126-
the `pytorch-gha-infra-2` `runners/common/Terrafile` -> `terraform apply` in
127-
`runners/regions/us-east-1`.
124+
workflow. The zip ships in test-infra's shared lambda release: a push to `main` touching
125+
`greenlight/**` cuts a `v<timestamp>` tag whose Release carries `greenlight-scan.zip` alongside
126+
the other lambda zips -> pin that tag in the `pytorch-gha-infra-2` `runners/common/Terrafile`
127+
-> `terraform apply` in `runners/regions/us-east-1`.
128128

129129
## Simulate a run
130130

greenlight/README.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -164,15 +164,21 @@ hang-guard layers off (the SIGALRM soft timeout and the `os._exit` hard watchdog
164164
under the Lambda runtime); single-instance and hang-bounding come from
165165
`reserved_concurrent_executions = 1` and the Lambda function timeout instead.
166166

167-
Shipping a new version is a manual four-step flow:
167+
The zip ships in test-infra's shared lambda release alongside every other lambda:
168168

169-
1. `just package` builds `dist/greenlight-scan.zip` (linux x86_64 / cp313 wheels).
170-
2. The `greenlight-lambda-release.yml` workflow (test-infra, manual `workflow_dispatch`) builds
171-
the zip and publishes a `greenlight-lambda-v<timestamp>` GitHub Release with it.
169+
1. `just package` builds `dist/greenlight-scan.zip` (linux x86_64 / cp313 wheels); the
170+
`build-greenlight-lambda` job in `_lambda-do-release-runners.yml` runs the same recipe.
171+
2. Any push to `main` touching `greenlight/**` makes `lambda-release-tag-runners.yml` cut a
172+
`v<timestamp>` tag, which publishes one GitHub Release carrying `greenlight-scan.zip` next to
173+
the other lambda zips. `workflow_dispatch` on that workflow cuts a release on demand.
172174
3. An operator pins that release tag in `pytorch-gha-infra-2`'s `runners/common/Terrafile` (the
173175
`greenlight-scan` entry).
174176
4. `terraform apply` in `runners/regions/us-east-1` rolls it out.
175177

178+
The greenlight build leg is `continue-on-error`, so a broken package step omits
179+
`greenlight-scan.zip` from the release rather than blocking the other lambdas — check that the
180+
asset is present before pinning a tag.
181+
176182
## Reviewer checkout sanitizing
177183

178184
The reviewer workflow (`greenlight-pr-review.yml`) checks the PR's `pytorch/pytorch` tree

0 commit comments

Comments
 (0)