Skip to content

Commit f5980cb

Browse files
Centralize the list of supported Python runtimes (#892)
* centralize version list * reducing diff * clean diff
1 parent 541cd50 commit f5980cb

16 files changed

Lines changed: 160 additions & 299 deletions

‎.github/workflows/build.yml‎

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,26 @@ jobs:
3838
source venv/bin/activate
3939
flake8 datadog_lambda/
4040
41+
python-versions:
42+
runs-on: ubuntu-24.04
43+
outputs:
44+
versions: ${{ steps.load.outputs.versions }}
45+
steps:
46+
- name: Checkout
47+
uses: actions/checkout@v4
48+
49+
- name: Load Python versions
50+
id: load
51+
run: |
52+
echo "versions=$(yq -o=json -I=0 '[.versions[] | .version]' python_versions.yaml)" >> "$GITHUB_OUTPUT"
53+
4154
unit-test:
55+
needs: python-versions
4256
runs-on: ubuntu-24.04
4357
strategy:
4458
max-parallel: 4
4559
matrix:
46-
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13', '3.14', '3.15']
60+
python-version: ${{ fromJSON(needs.python-versions.outputs.versions) }}
4761

4862
steps:
4963
- name: Checkout

‎.github/workflows/build_layer.yml‎

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,30 @@ on:
88
- "main"
99

1010
jobs:
11+
python-versions:
12+
runs-on: ubuntu-latest
13+
outputs:
14+
versions: ${{ steps.load.outputs.versions }}
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v4
18+
19+
- name: Load Python versions
20+
id: load
21+
run: |
22+
# system_tests: false versions are skipped. dd-trace-py main no longer
23+
# publishes wheels for them (currently 3.8).
24+
echo "versions=$(yq -o=json -I=0 '[.versions[] | select(.system_tests != false) | .version]' python_versions.yaml)" >> "$GITHUB_OUTPUT"
25+
1126
build:
27+
needs: python-versions
1228
runs-on: ${{ matrix.arch == 'arm64' && 'ubuntu-24.04-arm' || 'ubuntu-latest' }}
1329

1430
strategy:
1531
fail-fast: false
1632
matrix:
1733
arch: [arm64, amd64]
18-
python_version: ["3.9", "3.10", "3.11", "3.12", "3.13", "3.14", "3.15"]
34+
python_version: ${{ fromJSON(needs.python-versions.outputs.versions) }}
1935

2036
steps:
2137
- name: Checkout

‎ci/config.yaml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ outputFiles:
55
- ci/build-pipeline.yaml
66

77
datasources:
8-
runtimes:
9-
url: ci/datasources/runtimes.yaml
8+
python_versions:
9+
url: python_versions.yaml
1010
regions:
1111
url: ci/datasources/regions.yaml
1212
environments:

‎ci/datasources/runtimes.yaml‎

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

‎ci/input_files/build.yaml.tpl‎

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
{{- $e2e_region := "us-west-2" -}}
2+
{{- $runtimes := coll.Slice -}}
3+
{{- range $py := (ds "python_versions").versions }}{{ range $arch := coll.Slice "amd64" "arm64" }}
4+
{{- $runtimes = $runtimes | coll.Append (dict "name" (printf "python%s" ($py.version | strings.ReplaceAll "." "")) "python_version" $py.version "arch" $arch "image" $py.image) }}
5+
{{- end }}{{ end -}}
26

37
stages:
48
- build
@@ -26,7 +30,7 @@ default:
2630
- apt-get install nodejs -y
2731
- npm install --global yarn
2832

29-
{{ range $runtime := (ds "runtimes").runtimes }}
33+
{{ range $runtime := $runtimes }}
3034

3135
# TODO(astuyve) - figure out python build cache
3236
.{{ $runtime.name }}-{{ $runtime.arch }}-cache: &{{ $runtime.name }}-{{ $runtime.arch }}-cache
@@ -208,7 +212,7 @@ publish-pypi-package:
208212
rules:
209213
- if: '$CI_COMMIT_TAG =~ /^v.*/'
210214
when: manual
211-
needs: {{ range $runtime := (ds "runtimes").runtimes }}
215+
needs: {{ range $runtime := $runtimes }}
212216
- sign-layer ({{ $runtime.name }}-{{ $runtime.arch}})
213217
{{- end }}
214218
script:
@@ -219,11 +223,11 @@ layer bundle:
219223
tags: ["arch:amd64"]
220224
image: registry.ddbuild.io/images/docker:20.10
221225
needs:
222-
{{ range (ds "runtimes").runtimes }}
226+
{{ range $runtimes }}
223227
- build-layer ({{ .name }}-{{ .arch }})
224228
{{ end }}
225229
dependencies:
226-
{{ range (ds "runtimes").runtimes }}
230+
{{ range $runtimes }}
227231
- build-layer ({{ .name }}-{{ .arch }})
228232
{{ end }}
229233
artifacts:
@@ -243,11 +247,11 @@ signed layer bundle:
243247
rules:
244248
- if: '$CI_COMMIT_TAG =~ /^v.*/'
245249
needs:
246-
{{ range (ds "runtimes").runtimes }}
250+
{{ range $runtimes }}
247251
- sign-layer ({{ .name }}-{{ .arch }})
248252
{{ end }}
249253
dependencies:
250-
{{ range (ds "runtimes").runtimes }}
254+
{{ range $runtimes }}
251255
- sign-layer ({{ .name }}-{{ .arch }})
252256
{{ end }}
253257
artifacts:
@@ -272,13 +276,13 @@ e2e-test:
272276
variables:
273277
LANGUAGES_SUBSET: python
274278
# These env vars are inherited from the dotenv reports of the publish-layer jobs
275-
{{- range (ds "runtimes").runtimes }}
279+
{{- range $runtimes }}
276280
{{- if eq .arch "amd64" }}
277281
{{- $version := print (.name | strings.Trim "python") }}
278282
PYTHON_{{ $version }}_VERSION: $PYTHON_{{ $version }}_VERSION
279283
{{- end }}
280284
{{- end }}
281-
needs: {{ range (ds "runtimes").runtimes }}
285+
needs: {{ range $runtimes }}
282286
{{- if eq .arch "amd64" }}
283287
- "publish-layer-sandbox ({{ .name }}-{{ .arch }}): [{{ $e2e_region }}]"
284288
{{- end }}

‎ci/publish_layers.sh‎

Lines changed: 4 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -10,78 +10,10 @@
1010
set -e
1111

1212
# Available runtimes: https://docs.aws.amazon.com/lambda/latest/dg/lambda-runtimes.html
13-
AWS_CLI_PYTHON_VERSIONS=(
14-
"python3.8"
15-
"python3.8"
16-
"python3.9"
17-
"python3.9"
18-
"python3.10"
19-
"python3.10"
20-
"python3.11"
21-
"python3.11"
22-
"python3.12"
23-
"python3.12"
24-
"python3.13"
25-
"python3.13"
26-
"python3.14"
27-
"python3.14"
28-
"python3.15"
29-
"python3.15"
30-
)
31-
PYTHON_VERSIONS=(
32-
"3.8-amd64"
33-
"3.8-arm64"
34-
"3.9-amd64"
35-
"3.9-arm64"
36-
"3.10-amd64"
37-
"3.10-arm64"
38-
"3.11-amd64"
39-
"3.11-arm64"
40-
"3.12-amd64"
41-
"3.12-arm64"
42-
"3.13-amd64"
43-
"3.13-arm64"
44-
"3.14-amd64"
45-
"3.14-arm64"
46-
"3.15-amd64"
47-
"3.15-arm64"
48-
)
49-
LAYER_PATHS=(
50-
".layers/datadog_lambda_py-amd64-3.8.zip"
51-
".layers/datadog_lambda_py-arm64-3.8.zip"
52-
".layers/datadog_lambda_py-amd64-3.9.zip"
53-
".layers/datadog_lambda_py-arm64-3.9.zip"
54-
".layers/datadog_lambda_py-amd64-3.10.zip"
55-
".layers/datadog_lambda_py-arm64-3.10.zip"
56-
".layers/datadog_lambda_py-amd64-3.11.zip"
57-
".layers/datadog_lambda_py-arm64-3.11.zip"
58-
".layers/datadog_lambda_py-amd64-3.12.zip"
59-
".layers/datadog_lambda_py-arm64-3.12.zip"
60-
".layers/datadog_lambda_py-amd64-3.13.zip"
61-
".layers/datadog_lambda_py-arm64-3.13.zip"
62-
".layers/datadog_lambda_py-amd64-3.14.zip"
63-
".layers/datadog_lambda_py-arm64-3.14.zip"
64-
".layers/datadog_lambda_py-amd64-3.15.zip"
65-
".layers/datadog_lambda_py-arm64-3.15.zip"
66-
)
67-
LAYERS=(
68-
"Datadog-Python38"
69-
"Datadog-Python38-ARM"
70-
"Datadog-Python39"
71-
"Datadog-Python39-ARM"
72-
"Datadog-Python310"
73-
"Datadog-Python310-ARM"
74-
"Datadog-Python311"
75-
"Datadog-Python311-ARM"
76-
"Datadog-Python312"
77-
"Datadog-Python312-ARM"
78-
"Datadog-Python313"
79-
"Datadog-Python313-ARM"
80-
"Datadog-Python314"
81-
"Datadog-Python314-ARM"
82-
"Datadog-Python315"
83-
"Datadog-Python315-ARM"
84-
)
13+
source "$(dirname "${BASH_SOURCE[0]}")/../scripts/python_versions.sh"
14+
AWS_CLI_PYTHON_VERSIONS=("${LAYER_RUNTIMES[@]}")
15+
LAYERS=("${LAYER_NAMES[@]}")
16+
PYTHON_VERSIONS=("${LAYER_KEYS[@]}")
8517
STAGES=('prod', 'sandbox', 'staging', 'gov-staging', 'gov-prod')
8618

8719
printf "Starting script...\n\n"

‎python_versions.yaml‎

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Supported Python versions for the Lambda library.
2+
#
3+
# Layer builds, publish scripts, tests, and CI read this file. Add a version
4+
# here and those pick it up. The README and the pyproject.toml classifiers are
5+
# the lists still maintained by hand.
6+
#
7+
# version: CPython minor version.
8+
# image: GitLab CI image tag (registry.ddbuild.io/images/mirror/python).
9+
# preview: AWS has not published a SAM build image yet. Layer builds use
10+
# public.ecr.aws/lambda/python:<version>-preview. Default false.
11+
# system_tests: Set false to skip the GitHub system-tests layer build. That
12+
# job installs a dd-trace-py main-branch wheel, which no longer
13+
# publishes 3.8 wheels. Default true.
14+
versions:
15+
- version: "3.8"
16+
image: "3.8"
17+
system_tests: false
18+
- version: "3.9"
19+
image: "3.9"
20+
- version: "3.10"
21+
image: "3.10"
22+
- version: "3.11"
23+
image: "3.11.6"
24+
- version: "3.12"
25+
image: "3.12.0"
26+
- version: "3.13"
27+
image: "3.13.0"
28+
- version: "3.14"
29+
image: "3.14.0"
30+
- version: "3.15"
31+
image: "3.15.0"

‎scripts/add_new_region.sh‎

Lines changed: 2 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -12,42 +12,8 @@ set -e
1212

1313
OLD_REGION='us-east-1'
1414

15-
LAYER_NAMES=(
16-
"Datadog-Python38"
17-
"Datadog-Python38-ARM"
18-
"Datadog-Python39"
19-
"Datadog-Python39-ARM"
20-
"Datadog-Python310"
21-
"Datadog-Python310-ARM"
22-
"Datadog-Python311"
23-
"Datadog-Python311-ARM"
24-
"Datadog-Python312"
25-
"Datadog-Python312-ARM"
26-
"Datadog-Python313"
27-
"Datadog-Python313-ARM"
28-
"Datadog-Python314"
29-
"Datadog-Python314-ARM"
30-
"Datadog-Python315"
31-
"Datadog-Python315-ARM"
32-
)
33-
PYTHON_VERSIONS_FOR_AWS_CLI=(
34-
"python3.8"
35-
"python3.8"
36-
"python3.9"
37-
"python3.9"
38-
"python3.10"
39-
"python3.10"
40-
"python3.11"
41-
"python3.11"
42-
"python3.12"
43-
"python3.12"
44-
"python3.13"
45-
"python3.13"
46-
"python3.14"
47-
"python3.14"
48-
"python3.15"
49-
"python3.15"
50-
)
15+
source "$(dirname "${BASH_SOURCE[0]}")/python_versions.sh"
16+
PYTHON_VERSIONS_FOR_AWS_CLI=("${LAYER_RUNTIMES[@]}")
5117
NEW_REGION=$1
5218

5319
publish_layer() {

0 commit comments

Comments
 (0)