Skip to content

Commit 6f37b78

Browse files
authored
github-status-test: build the package for python3.12 (#8523)
python3.9 is past upstream EOL. **Do not merge until the function's runtime is python3.12.** If merged early, the deploy job fails the new runtime check and production is left untouched — a red build rather than an outage. Verified the dependency jump this pulls in (cryptography 43.0.3 → 50.0.0) against the real API on 3.12: token minting, the uninstalled-repo 404, and the bad-key path all behave as before. ### Rollout The deployed package is 3.9-built and stops loading the moment the runtime changes, so the gap between the two steps is a live outage — API Gateway invokes `$LATEST` unqualified, there is no staged rollout. 1. Change the function runtime to `python3.12`. **Production breaks here.** 2. Merge this PR so main matches what is deployed. Rollback: set the runtime back to `python3.9` and redeploy from main.
1 parent 25f6e6e commit 6f37b78

3 files changed

Lines changed: 32 additions & 9 deletions

File tree

.github/workflows/github-status-test-lambda.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
2424
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
2525
with:
26-
python-version: '3.11'
26+
python-version: '3.12'
2727
cache: pip
2828
- run: pip3 install -r requirements.txt pytest
2929
- run: pytest -v test_lambda_function.py
Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,25 @@
11
ZIP := github-status-test-deployment.zip
2+
FUNCTION := github-status-test
3+
# Must match the deployed runtime. The package contains version-specific
4+
# compiled wheels (cffi), so a package built for one python on a function
5+
# running another fails at import on every single invocation. `deploy` checks
6+
# this against the live function rather than trusting the two to stay in sync.
7+
PYTHON_VERSION := 3.12
28
# Third-party modules lambda_function.py imports. The built zip is checked for
39
# these before it can be deployed: a package missing a dependency fails at
410
# import, which drops every event the webhook sends -- not just the log
511
# download -- and update-function-code publishes straight to $LATEST, which is
612
# what API Gateway invokes.
713
VENDORED := boto3 requests github
814

9-
# The lambda runs on python3.9/x86_64. cryptography ships compiled wheels, so
10-
# pin the target platform rather than inheriting whatever python the CI runner
11-
# happens to default to -- otherwise the zip gets wheels the runtime can't load.
15+
# The lambda runs on x86_64. cryptography ships compiled wheels, so pin the
16+
# target platform rather than inheriting whatever python the CI runner happens
17+
# to default to -- otherwise the zip gets wheels the runtime can't load.
1218
# Starts from clean so a stale packages/ or zip can't leak into the artifact.
1319
prepare: clean
1420
mkdir -p ./packages
1521
pip install --target ./packages \
16-
--platform manylinux2014_x86_64 --python-version 3.9 \
22+
--platform manylinux2014_x86_64 --python-version $(PYTHON_VERSION) \
1723
--implementation cp --only-binary=:all: --no-compile \
1824
-r requirements.txt
1925
cd packages && zip -r ../$(ZIP) .
@@ -27,8 +33,21 @@ verify:
2733
done
2834
@echo "verified: $(ZIP) contains $(VENDORED)"
2935

30-
deploy: prepare
31-
aws lambda update-function-code --function-name github-status-test --zip-file fileb://$(ZIP)
36+
# Refuse to publish a package built for a different python than the function
37+
# actually runs. Without this the two can drift silently and the first symptom
38+
# is Runtime.ImportModuleError on every webhook event.
39+
check-runtime:
40+
@live=$$(aws lambda get-function-configuration --function-name $(FUNCTION) \
41+
--query Runtime --output text); \
42+
if [ "$$live" != "python$(PYTHON_VERSION)" ]; then \
43+
echo "ERROR: $(FUNCTION) runs $$live but this package targets python$(PYTHON_VERSION)."; \
44+
echo " Change the function runtime first, or set PYTHON_VERSION to $${live#python}."; \
45+
exit 1; \
46+
fi; \
47+
echo "runtime check: $(FUNCTION) runs $$live, package targets python$(PYTHON_VERSION)"
48+
49+
deploy: check-runtime prepare
50+
aws lambda update-function-code --function-name $(FUNCTION) --zip-file fileb://$(ZIP)
3251

3352
clean:
3453
rm -rf $(ZIP) packages

aws/lambda/github-status-test/README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,12 @@ Notes on the app path:
3535
> the new code on `$LATEST` and every webhook hits it right away. The publish-a-version steps below are
3636
> stale — they describe pinning the integration to a numbered version, which is not how it is wired
3737
> today, and the resource id is now `xtmtzj` rather than `clc02o`. Until that is fixed, treat any deploy
38-
> as a direct production change: `make prepare` verifies the zip contains every vendored module before
39-
> `make deploy` will run, but there is no staged rollout behind it.
38+
> as a direct production change: `make prepare` verifies the zip contains every vendored module and
39+
> `make deploy` refuses to publish a package built for a different python than the function runs, but
40+
> there is no staged rollout behind it.
41+
>
42+
> `PYTHON_VERSION` in the Makefile must match the function's runtime. Changing one without the other
43+
> breaks every invocation, so the two have to move together — see the rollout order when bumping.
4044
4145
A new version of the lambda can be deployed using `make deploy` and it will be done so automatically by the workflow
4246
`github-status-test-lambda` when a change is committed to main. We have limited capacity for testing this lambda at

0 commit comments

Comments
 (0)