Skip to content

Commit 9fb8703

Browse files
ci: replace poetry with uv
1 parent a3255e9 commit 9fb8703

18 files changed

+4263
-5893
lines changed

.github/boring-cyborg.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ labelPRBasedOnFilePath:
8585

8686
dependencies:
8787
- pyproject.toml
88-
- poetry.lock
88+
- uv.lock
8989

9090
tests:
9191
- tests/*

.github/workflows/publish_v3_layer.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,10 @@ jobs:
118118
integrity_hash: ${{ inputs.source_code_integrity_hash }}
119119
artifact_name: ${{ inputs.source_code_artifact_name }}
120120

121-
- name: Install poetry
122-
run: |
123-
pipx install git+https://github.com/python-poetry/poetry@bd500dd3bdfaec3de6894144c9cedb3a9358be84 # v2.0.1
124-
pipx inject poetry git+https://github.com/python-poetry/poetry-plugin-export@8c83d26603ca94f2e203bfded7b6d7f530960e06 # v1.8.0
121+
- name: Install uv
122+
uses: astral-sh/setup-uv@6b9c6063abd6010835644d4c2e1bef4cf5cd0fca # v6.0.1
123+
with:
124+
enable-cache: true
125125
- name: Setup Node.js
126126
uses: actions/setup-node@395ad3262231945c25e8478fd5baf05154b1d79f # v6.1.0
127127
with:
@@ -135,7 +135,7 @@ jobs:
135135
# CDK spawns system python when compiling stack
136136
# therefore it ignores both activated virtual env and cached interpreter by GH
137137
run: |
138-
poetry export --format requirements.txt --output requirements.txt
138+
uv export --format requirements-txt --output-file requirements.txt
139139
pip install --require-hashes -r requirements.txt
140140
141141
- name: Set up QEMU

.github/workflows/quality_check.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ on:
2222
- "tests/**"
2323
- "examples/**"
2424
- "pyproject.toml"
25-
- "poetry.lock"
25+
- "uv.lock"
2626
- "mypy.ini"
2727
branches:
2828
- develop
@@ -32,7 +32,7 @@ on:
3232
- "tests/**"
3333
- "examples/**"
3434
- "pyproject.toml"
35-
- "poetry.lock"
35+
- "uv.lock"
3636
- "mypy.ini"
3737
branches:
3838
- develop
@@ -53,8 +53,10 @@ jobs:
5353
contents: read # checkout code only
5454
steps:
5555
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
56-
- name: Install poetry
57-
run: pipx install poetry
56+
- name: Install uv
57+
uses: astral-sh/setup-uv@6b9c6063abd6010835644d4c2e1bef4cf5cd0fca # v6.0.1
58+
with:
59+
enable-cache: true
5860
- name: Set up Python ${{ matrix.python-version }}
5961
uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0
6062
with:

.github/workflows/quality_code_cdk_constructor.yml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,14 @@ jobs:
4343
working-directory: ./layer_v3/layer_constructors
4444
steps:
4545
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
46-
- name: Install poetry
47-
run: pipx install poetry
46+
- name: Install uv
47+
uses: astral-sh/setup-uv@6b9c6063abd6010835644d4c2e1bef4cf5cd0fca # v6.0.1
48+
with:
49+
enable-cache: true
4850
- name: Set up Python ${{ matrix.python-version }}
4951
uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0
5052
with:
5153
python-version: ${{ matrix.python-version }}
52-
cache: "poetry"
5354
- name: Set up QEMU
5455
uses: docker/setup-qemu-action@c7c53464625b32c7a7e944ae62b3e17d2b600130 # v2.0.0
5556
with:
@@ -64,7 +65,7 @@ jobs:
6465
platforms: linux/amd64,linux/arm64
6566
- name: Install dependencies
6667
run: |
67-
pip install --upgrade pip pre-commit poetry
68-
poetry install
68+
pip install --upgrade pip pre-commit uv
69+
uv sync
6970
- name: Test with pytest
70-
run: poetry run pytest tests
71+
run: uv run pytest tests

.github/workflows/release-v3.yml

Lines changed: 20 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,6 @@ permissions:
6969

7070
jobs:
7171

72-
# This job bumps the package version to the release version
73-
# creates an integrity hash from the source code
74-
# uploads the artifact with the integrity hash as the key name
75-
# so subsequent jobs can restore from a trusted point in time to prevent tampering
7672
seal:
7773
runs-on: ubuntu-latest
7874
permissions:
@@ -93,37 +89,24 @@ jobs:
9389
with:
9490
ref: ${{ env.RELEASE_COMMIT }}
9591

96-
# We use a pinned version of Poetry to be certain it won't modify source code before we create a hash
97-
- name: Install poetry
98-
run: |
99-
pipx install git+https://github.com/python-poetry/poetry@bd500dd3bdfaec3de6894144c9cedb3a9358be84 # v2.0.1
100-
pipx inject poetry git+https://github.com/monim67/poetry-bumpversion@348de6f247222e2953d649932426e63492e0a6bf # v0.3.3
92+
- name: Update version in pyproject.toml
93+
run: sed -i 's/^version = ".*"/version = "${{ steps.release_version.outputs.RELEASE_VERSION }}"/' pyproject.toml
10194

102-
- name: Bump package version
103-
id: versioning
104-
run: poetry version "${RELEASE_VERSION}"
105-
env:
106-
RELEASE_VERSION: ${{ steps.release_version.outputs.RELEASE_VERSION}}
95+
- name: Update version in version.py
96+
run: sed -i 's/^VERSION = ".*"/VERSION = "${{ steps.release_version.outputs.RELEASE_VERSION }}"/' aws_lambda_powertools/shared/version.py
10797

10898
- name: Seal and upload
10999
id: seal_source_code
110100
uses: ./.github/actions/seal
111101
with:
112102
artifact_name_prefix: "source"
113103

114-
# This job runs our automated test suite, complexity and security baselines
115-
# it ensures previously merged have been tested as part of the pull request process
116-
#
117-
# NOTE
118-
#
119-
# we don't upload the artifact after testing to prevent any tampering of our source code dependencies
120104
quality_check:
121105
needs: seal
122106
runs-on: ubuntu-latest
123107
permissions:
124108
contents: read
125109
steps:
126-
# NOTE: we need actions/checkout to configure git first (pre-commit hooks in make dev)
127110
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
128111
with:
129112
ref: ${{ env.RELEASE_COMMIT }}
@@ -137,23 +120,19 @@ jobs:
137120
- name: Debug cache restore
138121
run: cat pyproject.toml
139122

140-
- name: Install poetry
141-
run: pipx install git+https://github.com/python-poetry/poetry@bd500dd3bdfaec3de6894144c9cedb3a9358be84 # v2.0.1
123+
- name: Install uv
124+
uses: astral-sh/setup-uv@6b9c6063abd6010835644d4c2e1bef4cf5cd0fca # v6.0.1
125+
with:
126+
enable-cache: true
142127
- name: Set up Python
143128
uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0
144129
with:
145130
python-version: "3.14"
146-
cache: "poetry"
147131
- name: Install dependencies
148132
run: make dev
149133
- name: Run all tests, linting and baselines
150134
run: make pr
151135

152-
# This job creates a release artifact (tar.gz, wheel)
153-
# it checks out code from release commit for custom actions to work
154-
# then restores the sealed source code (overwrites any potential tampering)
155-
# it's done separately from release job to enforce least privilege.
156-
# We export just the final build artifact for release
157136
build:
158137
runs-on: ubuntu-latest
159138
needs: [quality_check, seal]
@@ -164,7 +143,6 @@ jobs:
164143
artifact_name: ${{ steps.seal_build.outputs.artifact_name }}
165144
attestation_hashes: ${{ steps.encoded_hash.outputs.attestation_hashes }}
166145
steps:
167-
# NOTE: we need actions/checkout to configure git first (pre-commit hooks in make dev)
168146
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
169147
with:
170148
ref: ${{ env.RELEASE_COMMIT }}
@@ -175,16 +153,17 @@ jobs:
175153
integrity_hash: ${{ needs.seal.outputs.integrity_hash }}
176154
artifact_name: ${{ needs.seal.outputs.artifact_name }}
177155

178-
- name: Install poetry
179-
run: pipx install git+https://github.com/python-poetry/poetry@bd500dd3bdfaec3de6894144c9cedb3a9358be84 # v2.0.1
156+
- name: Install uv
157+
uses: astral-sh/setup-uv@6b9c6063abd6010835644d4c2e1bef4cf5cd0fca # v6.0.1
158+
with:
159+
enable-cache: true
180160
- name: Set up Python
181161
uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0
182162
with:
183163
python-version: "3.14"
184-
cache: "poetry"
185164

186165
- name: Build python package and wheel
187-
run: poetry build
166+
run: uv build
188167

189168
- name: Seal and upload
190169
id: seal_build
@@ -193,47 +172,31 @@ jobs:
193172
artifact_name_prefix: "build"
194173
files: "dist/"
195174

196-
# NOTE: SLSA retraces our build to its artifact to ensure it wasn't tampered
197-
# coupled with GitHub OIDC, SLSA can then confidently sign it came from this release pipeline+commit+branch+org+repo+actor+integrity hash
198175
- name: Create attestation encoded hash for provenance
199176
id: encoded_hash
200177
working-directory: dist
201178
run: echo "attestation_hashes=$(sha256sum ./* | base64 -w0)" >> "$GITHUB_OUTPUT"
202179

203-
# This job creates a provenance file that describes how our release was built (all steps)
204-
# after it verifies our build is reproducible within the same pipeline
205-
# it confirms that its own software and the CI build haven't been tampered with (Trust but verify)
206-
# lastly, it creates and sign an attestation (multiple.intoto.jsonl) that confirms
207-
# this build artifact came from this GitHub org, branch, actor, commit ID, inputs that triggered this pipeline, and matches its integrity hash
208-
# NOTE: supply chain threats review (we protect against all of them now): https://slsa.dev/spec/v1.0/threats-overview
209180
provenance:
210181
needs: [seal, build]
211182
permissions:
212-
contents: write # nested job explicitly require despite upload assets being set to false
213-
actions: read # To read the workflow path.
214-
id-token: write # To sign the provenance.
215-
# NOTE: provenance fails if we use action pinning... it's a Github limitation
216-
# because SLSA needs to trace & attest it came from a given branch; pinning doesn't expose that information
217-
# https://github.com/slsa-framework/slsa-github-generator/blob/main/internal/builders/generic/README.md#referencing-the-slsa-generator
183+
contents: write
184+
actions: read
185+
id-token: write
218186
uses: slsa-framework/slsa-github-generator/.github/workflows/generator_generic_slsa3.yml@v2.1.0
219187
with:
220188
base64-subjects: ${{ needs.build.outputs.attestation_hashes }}
221-
upload-assets: false # we upload its attestation in create_tag job, otherwise it creates a new release
189+
upload-assets: false
222190

223-
# This job uses release artifact to publish to PyPi
224-
# it exchanges JWT tokens with GitHub to obtain PyPi credentials
225-
# since it's already registered as a Trusted Publisher.
226-
# It uses the sealed build artifact (.whl, .tar.gz) to release it
227191
release:
228192
needs: [build, seal, provenance]
229193
environment: release
230194
runs-on: ubuntu-latest
231195
permissions:
232-
id-token: write # OIDC for PyPi Trusted Publisher feature
196+
id-token: write
233197
env:
234198
RELEASE_VERSION: ${{ needs.seal.outputs.RELEASE_VERSION }}
235199
steps:
236-
# NOTE: we need actions/checkout in order to use our local actions (e.g., ./.github/actions)
237200
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
238201
with:
239202
ref: ${{ env.RELEASE_COMMIT }}
@@ -248,26 +211,12 @@ jobs:
248211
if: ${{ !inputs.skip_pypi }}
249212
uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e # v1.13.0
250213

251-
# PyPi test maintenance affected us numerous times, leaving for history purposes
252-
# - name: Upload to PyPi test
253-
# if: ${{ !inputs.skip_pypi }}
254-
# uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e # v1.13.0
255-
# with:
256-
# repository-url: https://test.pypi.org/legacy/
257-
258-
# We create a Git Tag using our release version (e.g., v3.16.0)
259-
# using our sealed source code we created earlier.
260-
# Because we bumped version of our project as part of CI
261-
# we need to add this into git before pushing the tag
262-
# otherwise the release commit will be used as the basis for the tag.
263-
# Later, we create a PR to update trunk with our newest release version (e.g., bump_version job)
264214
create_tag:
265215
needs: [release, seal, provenance]
266216
runs-on: ubuntu-latest
267217
permissions:
268218
contents: write
269219
steps:
270-
# NOTE: we need actions/checkout to authenticate and configure git first
271220
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
272221
with:
273222
ref: ${{ env.RELEASE_COMMIT }}
@@ -302,16 +251,13 @@ jobs:
302251
provenance_name: ${{needs.provenance.outputs.provenance-name}}
303252
github_token: ${{ secrets.GITHUB_TOKEN }}
304253

305-
# Creates a PR with the latest version we've just released
306-
# since our trunk is protected against any direct pushes from automation
307254
bump_version:
308255
needs: [release, seal]
309256
permissions:
310-
contents: write # create-pr action creates a temporary branch
311-
pull-requests: write # create-pr action creates a PR using the temporary branch
257+
contents: write
258+
pull-requests: write
312259
runs-on: ubuntu-latest
313260
steps:
314-
# NOTE: we need actions/checkout to authenticate and configure git first
315261
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
316262
with:
317263
ref: ${{ env.RELEASE_COMMIT }}
@@ -331,15 +277,6 @@ jobs:
331277
pull_request_title: "chore(ci): bump version to ${{ needs.seal.outputs.RELEASE_VERSION }}"
332278
github_token: ${{ secrets.GITHUB_TOKEN }}
333279

334-
# This job compiles a Lambda Layer optimized for space and speed (e.g., Cython)
335-
# It then deploys to Layer's Beta and Prod account, including SAR Beta and Prod account.
336-
# It uses canaries to attest Layers can be used and imported between stages.
337-
# Lastly, it updates our documentation with the latest Layer ARN for all regions
338-
#
339-
# NOTE
340-
#
341-
# Watch out for the depth limit of 4 nested workflow_calls.
342-
# publish_layer -> publish_3_layer -> reusable_deploy_v3_layer_stack
343280
publish_layer:
344281
needs: [seal, release, create_tag]
345282
secrets: inherit

.github/workflows/reusable_deploy_v3_layer_stack.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -156,10 +156,10 @@ jobs:
156156
integrity_hash: ${{ inputs.source_code_integrity_hash }}
157157
artifact_name: ${{ inputs.source_code_artifact_name }}
158158

159-
- name: Install poetry
160-
run: |
161-
pipx install git+https://github.com/python-poetry/poetry@bd500dd3bdfaec3de6894144c9cedb3a9358be84 # v2.0.1
162-
pipx inject poetry git+https://github.com/python-poetry/poetry-plugin-export@8c83d26603ca94f2e203bfded7b6d7f530960e06 # v1.8.0
159+
- name: Install uv
160+
uses: astral-sh/setup-uv@6b9c6063abd6010835644d4c2e1bef4cf5cd0fca # v6.0.1
161+
with:
162+
enable-cache: true
163163
- name: Configure AWS credentials
164164
uses: aws-actions/configure-aws-credentials@61815dcd50bd041e203e49132bacad1fd04d2708 # v4.3.0
165165
with:
@@ -179,15 +179,15 @@ jobs:
179179
# CDK spawns system python when compiling stack
180180
# therefore it ignores both activated virtual env and cached interpreter by GH
181181
run: |
182-
poetry export --format requirements.txt --output requirements.txt
182+
uv export --format requirements-txt --output-file requirements.txt
183183
pip install --require-hashes -r requirements.txt
184184
- name: install cdk and deps
185185
working-directory: ./
186186
run: |
187187
npm ci
188188
npx cdk --version
189189
- name: install deps
190-
run: poetry install
190+
run: uv sync
191191
- name: Download artifact
192192
uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7.0.0
193193
with:

.github/workflows/run-e2e-tests.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ on:
2424
- "aws_lambda_powertools/**"
2525
- "tests/e2e/**"
2626
- "pyproject.toml"
27-
- "poetry.lock"
27+
- "uv.lock"
2828
- "mypy.ini"
2929
- "parallel_run_e2e.py"
3030

@@ -53,14 +53,15 @@ jobs:
5353
steps:
5454
- name: "Checkout"
5555
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
56-
- name: Install poetry
57-
run: pipx install poetry
56+
- name: Install uv
57+
uses: astral-sh/setup-uv@6b9c6063abd6010835644d4c2e1bef4cf5cd0fca # v6.0.1
58+
with:
59+
enable-cache: true
5860
- name: "Use Python"
5961
uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0
6062
with:
6163
python-version: ${{ matrix.version }}
6264
architecture: "x64"
63-
cache: "poetry"
6465
- name: Setup Node.js
6566
uses: actions/setup-node@395ad3262231945c25e8478fd5baf05154b1d79f # v6.1.0
6667
with:

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ This happens when:
176176
- You did not install the local dev environment yet
177177
- You can install dev deps with `make dev` command
178178
- The code in the repository is raising an exception while the `pdoc` is scanning the codebase
179-
- Unfortunately, this exception is not shown to you, but if you run, `poetry run pdoc --pdf aws_lambda_powertools`, the exception is shown and you can prevent the exception from being raised
179+
- Unfortunately, this exception is not shown to you, but if you run, `uv run pdoc --pdf aws_lambda_powertools`, the exception is shown and you can prevent the exception from being raised
180180
- Once resolved the documentation should load correctly again
181181

182182
## Licensing

0 commit comments

Comments
 (0)