Skip to content

Commit f2c6cbe

Browse files
authored
[BE][lambdas] Use matrix for python lambda release to dedup code (#6809)
The python lambda releases are mostly the same, so convert them into a matrix to reduce code duplication and the chance of copy paste error Notes: * oss_ci_cur wasn't the list of jobs needed for the finish release job * benchmark-results-uploader was using ncipollo/release-action@v1 but the matrix strategy uses a specific commit that is supposedly v1.16.0 Testing: Ran https://github.com/pytorch/test-infra/actions/workflows/lambda-release-tag-runners.yml from this branch https://github.com/pytorch/test-infra/actions/runs/15786667588 Created release: https://github.com/pytorch/test-infra/releases/tag/v20250620-194933 I will update the README to explain how to use the matrix strategy if this gets approved Also can I also petition to have the tag to include part of the commit sha?
1 parent b37ca68 commit f2c6cbe

File tree

1 file changed

+16
-145
lines changed

1 file changed

+16
-145
lines changed

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

Lines changed: 16 additions & 145 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,18 @@ jobs:
8080
tag: ${{ inputs.tag }}
8181
updateOnlyUnreleased: true
8282

83-
# lambda/ci-queue-pct
84-
release-ci-queue-pct:
85-
name: Upload Release for ci-queue-pct lambda
83+
release-python-lambdas:
84+
strategy:
85+
fail-fast: false
86+
matrix:
87+
include: [
88+
{ dir-name: 'ci-queue-pct', zip-name: 'ci-queue-pct' },
89+
{ dir-name: 'oss_ci_job_queue_time', zip-name: 'oss-ci-job-queue-time' },
90+
{ dir-name: 'oss_ci_cur', zip-name: 'oss-ci-cur' },
91+
{ dir-name: 'benchmark-results-uploader', zip-name: 'benchmark-results-uploader' },
92+
{ dir-name: 'pytorch-auto-revert', zip-name: 'pytorch-auto-revert' }
93+
]
94+
name: Upload Release for ${{ matrix.dir-name }} lambda
8695
runs-on: ubuntu-latest
8796
permissions:
8897
contents: write
@@ -99,150 +108,15 @@ jobs:
99108
python-version: '3.10'
100109

101110
- name: Build deployment.zip
102-
working-directory: aws/lambda/ci-queue-pct
111+
working-directory: aws/lambda/${{ matrix.dir-name }}
103112
run: make deployment.zip
104113

105114
- name: Copy deployment.zip to root
106-
run: cp aws/lambda/ci-queue-pct/deployment.zip ci-queue-pct.zip
115+
run: cp aws/lambda/${{ matrix.dir-name }}/deployment.zip ${{ matrix.zip-name }}.zip
107116

108117
- uses: ncipollo/release-action@440c8c1cb0ed28b9f43e4d1d670870f059653174 # v1.16.0
109118
with:
110-
artifacts: "ci-queue-pct.zip"
111-
allowUpdates: true
112-
draft: true
113-
name: ${{ inputs.tag }}
114-
tag: ${{ inputs.tag }}
115-
updateOnlyUnreleased: true
116-
117-
# lambda/oss_ci_job_queue_time
118-
release-oss-ci-job-queue-time:
119-
name: Upload Release for oss-ci-job-queue-time lambda
120-
runs-on: ubuntu-latest
121-
permissions:
122-
contents: write
123-
env:
124-
REF: ${{ inputs.tag }}
125-
steps:
126-
- name: Checkout code
127-
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
128-
with:
129-
ref: ${{ inputs.tag }}
130-
131-
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
132-
with:
133-
python-version: '3.10'
134-
135-
- name: Build deployment.zip
136-
working-directory: aws/lambda/oss_ci_job_queue_time
137-
run: make deployment.zip
138-
139-
- name: Copy deployment.zip to root
140-
run: cp aws/lambda/oss_ci_job_queue_time/deployment.zip oss-ci-job-queue-time.zip
141-
142-
- uses: ncipollo/release-action@440c8c1cb0ed28b9f43e4d1d670870f059653174 # v1.16.0
143-
with:
144-
artifacts: "oss-ci-job-queue-time.zip"
145-
allowUpdates: true
146-
draft: true
147-
name: ${{ inputs.tag }}
148-
tag: ${{ inputs.tag }}
149-
updateOnlyUnreleased: true
150-
151-
# lambda/oss_ci_cur
152-
release-oss-ci-cur:
153-
name: Upload Release for oss-ci-cur lambda
154-
runs-on: ubuntu-latest
155-
permissions:
156-
contents: write
157-
env:
158-
REF: ${{ inputs.tag }}
159-
steps:
160-
- name: Checkout code
161-
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
162-
with:
163-
ref: ${{ inputs.tag }}
164-
165-
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
166-
with:
167-
python-version: '3.10'
168-
169-
- name: Build deployment.zip
170-
working-directory: aws/lambda/oss_ci_cur
171-
run: make deployment.zip
172-
173-
- name: Copy deployment.zip to root
174-
run: cp aws/lambda/oss_ci_cur/deployment.zip oss-ci-cur.zip
175-
176-
- uses: ncipollo/release-action@440c8c1cb0ed28b9f43e4d1d670870f059653174 # v1.16.0
177-
with:
178-
artifacts: "oss-ci-cur.zip"
179-
allowUpdates: true
180-
draft: true
181-
name: ${{ inputs.tag }}
182-
tag: ${{ inputs.tag }}
183-
updateOnlyUnreleased: true
184-
185-
# lambda/benchmark-results-uploader
186-
release-benchmark-results-uploader:
187-
name: Upload Release for benchmark-results-uploader lambda
188-
runs-on: ubuntu-latest
189-
permissions:
190-
contents: write
191-
env:
192-
REF: ${{ inputs.tag }}
193-
steps:
194-
- name: Checkout code
195-
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
196-
with:
197-
ref: ${{ inputs.tag }}
198-
199-
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
200-
with:
201-
python-version: '3.10'
202-
203-
- name: Build deployment.zip
204-
working-directory: aws/lambda/benchmark-results-uploader
205-
run: make deployment.zip
206-
207-
- name: Copy deployment.zip to root
208-
run: cp aws/lambda/benchmark-results-uploader/deployment.zip benchmark-results-uploader.zip
209-
210-
- uses: ncipollo/release-action@v1
211-
with:
212-
artifacts: "benchmark-results-uploader.zip"
213-
allowUpdates: true
214-
draft: true
215-
name: ${{ inputs.tag }}
216-
tag: ${{ inputs.tag }}
217-
updateOnlyUnreleased: true
218-
219-
# lambda/pytorch-auto-revert
220-
release-pytorch-auto-revert:
221-
name: Upload Release for pytorch-auto-revert lambda
222-
runs-on: ubuntu-latest
223-
permissions:
224-
contents: write
225-
env:
226-
REF: ${{ inputs.tag }}
227-
steps:
228-
- name: Checkout code
229-
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
230-
with:
231-
ref: ${{ inputs.tag }}
232-
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
233-
with:
234-
python-version: '3.10'
235-
236-
- name: Build deployment.zip
237-
working-directory: aws/lambda/pytorch-auto-revert
238-
run: make deployment.zip
239-
240-
- name: Copy deployment.zip to root
241-
run: cp aws/lambda/pytorch-auto-revert/deployment.zip pytorch-auto-revert.zip
242-
243-
- uses: ncipollo/release-action@440c8c1cb0ed28b9f43e4d1d670870f059653174 # v1.16.0
244-
with:
245-
artifacts: "pytorch-auto-revert.zip"
119+
artifacts: "${{ matrix.zip-name }}.zip"
246120
allowUpdates: true
247121
draft: true
248122
name: ${{ inputs.tag }}
@@ -251,11 +125,8 @@ jobs:
251125

252126
finish-release:
253127
needs:
254-
- release-benchmark-results-uploader
255-
- release-ci-queue-pct
256128
- release-lambdas
257-
- release-oss-ci-job-queue-time
258-
- release-pytorch-auto-revert
129+
- release-python-lambdas
259130
name: Mark the release as final and publish it
260131
runs-on: ubuntu-latest
261132
permissions:

0 commit comments

Comments
 (0)