Skip to content

Commit 5dbaa1d

Browse files
authored
Merge pull request #531 from NHSDigital/APIM-6679-Python-Update
Updated the python and dependencies to latest stable versions to support python 3.13
2 parents 9abc559 + 96c8fc9 commit 5dbaa1d

File tree

16 files changed

+785
-939
lines changed

16 files changed

+785
-939
lines changed

.github/workflows/publish.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ jobs:
1212
with:
1313
fetch-depth: 0 # This causes all history to be fetched, which is required for calculate-version to function
1414

15-
- name: Install Python 3.8
15+
- name: Install Python 3.13
1616
uses: actions/setup-python@v5
1717
with:
18-
python-version: 3.8
18+
python-version: 3.13
1919

2020
- name: Install poetry
2121
run: pip install poetry

README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,25 @@
11
# api-management-utils
22
Scripts and utilities used across API managment platform and services
33

4+
5+
################################################################################
6+
########### Python upgrade to 3.13 ###########
7+
########### Utils Repo has been updated to python 3.13 ###########
8+
################################################################################
9+
10+
########### We are continuing to support python 3.8/9(which are currently out of support) until January 26th 2026 ###########
11+
########### After the deadline your pipelines will fail if you are using python version 3.8/9 ###########
12+
13+
Python upgrade related changes
14+
###############################
15+
Projects using Python versions older than 3.13 and extending their pipeline with the utils repository must update their pipelines to ensure compatibility with the latest changes.
16+
For detailed guidance, please refer to the APIM FAQ page:
17+
https://nhsd-confluence.digital.nhs.uk/spaces/APM/pages/1226682275/Pipeline+Queries
18+
19+
Note: Projects running Python version 3.13 or later do not need any pipeline modifications.
20+
21+
22+
423
## Scripts
524
* `template.py` - cli for basic jinja templating
625
* `test_pull_request_deployments.py` - cli for testing utils against other repositories

ansible/collections/ansible_collections/nhsd/apigee/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ update-schema:
44
@PYTHONPATH=../../../ poetry run python scripts/update_schema.py
55

66
unit-test:
7-
@poetry run ansible-test units --python=3.8
7+
@poetry run ansible-test units --python=3.13
88

99
integration-test:
10-
@poetry run ansible-test integration --python=3.8
10+
@poetry run ansible-test integration --python=3.13
1111

1212
test: unit-test integration-test
1313

ansible/collections/ansible_collections/nhsd/apigee/plugins/module_utils/utils.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import typing
66

77
from ansible_collections.nhsd.apigee.plugins.module_utils import constants
8+
from ansible.utils.unsafe_proxy import AnsibleUnsafeText
89

910

1011
def exclude_keys(dict_, keys_to_ignore):
@@ -19,7 +20,7 @@ def delta(before, after, keys_to_ignore=None):
1920
before,
2021
after,
2122
ignore_order=True,
22-
ignore_type_in_groups=[(ansible.utils.unsafe_proxy.AnsibleUnsafeText,str)],
23+
ignore_type_in_groups=[(AnsibleUnsafeText,str)],
2324
exclude_paths=[f"root['{key}']" for key in keys_to_ignore],
2425
).to_json()
2526
)

ansible/collections/ansible_collections/nhsd/apigee/roles/deploy_manifest/tasks/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
# since products can only be created if they reference proxies
5555
# that exist. This safety check can be removed when the
5656
# manifest manages proxies too.
57-
when: item.name | regex_search('^' + SERVICE_NAME + '-' + PULL_REQUEST | default(APIGEE_ENVIRONMENT))
57+
when: (item.name is match('^' ~ SERVICE_NAME ~ '-' ~ (PULL_REQUEST | default(APIGEE_ENVIRONMENT))))
5858

5959
# - name: deploy apigee specs
6060
# nhsd.apigee.deploy_spec:

ansible/collections/ansible_collections/nhsd/apigee/tests/integration/targets/test_validate_manifest/tasks/main.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
- name: validate test manifest files
1818
include_role:
1919
name: validate_manifest
20-
vars_from: "{{ DIST_DIR }}/vars.yml"
2120
loop: "{{ DIST_DIRS }}"
2221
loop_control:
2322
loop_var: DIST_DIR

ansible/deploy-apigee-proxy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
APIGEE_ORGANIZATION: "{{ lookup('env', 'APIGEE_ORGANIZATION') }}"
1111
APIGEE_ACCESS_TOKEN: "{{ lookup('env', 'APIGEE_ACCESS_TOKEN') }}"
1212
PROXY_DIR: "{{ lookup('env', 'PROXY_DIR') }}"
13-
PING: "{{ (lookup('env', 'PING') | length > 0) | ternary(lookup('env', 'PING'), 'true') }}"
13+
PING: "{{ (lookup('env', 'PING') | default('true')) | bool }}"
1414

1515
pre_tasks:
1616
- name: check FULLY_QUALIFIED_SERVICE_NAME

ansible/roles/build-ecs-proxies/tasks/build-container.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
- name: pull latest if exists - to ensure cache {{ item }}
1313
ansible.builtin.command:
14-
cmd: "docker pull {{ ecr_registry }}/{{ item }}:{{ describe_images.stdout }}"
14+
cmd: "docker pull {{ ecr_registry }}/{{ service_id }}_{{ item }}:{{ describe_images.stdout }}"
1515
when: describe_images.stdout != 'None'
1616
ignore_errors: true
1717
no_log: true

ansible/roles/build-ecs-proxies/tasks/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,5 @@
3535
changed_when: no
3636

3737
- name: build and push ecr images
38-
include: build-container.yml
38+
include_tasks: build-container.yml
3939
with_items: "{{ containers }}"

azure/build-prereqs.yml

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,31 @@ parameters:
44
default: 'utils'
55

66
steps:
7+
# - bash: |
8+
# echo "Setting python tool cache path"
9+
# echo "##vso[task.setvariable variable=LD_LIBRARY_PATH;]:/agent/_work/_tool/Python/3.13.7/x64/lib/"
10+
# displayName: 'Set python tool cache path'
11+
- bash: |
12+
PATCH=$(curl -s https://api.github.com/repos/actions/python-versions/releases \
13+
| jq -r '[.[] | .tag_name | select(startswith("3.13"))] | .[]' \
14+
| sort -V | tail -n 1 | cut -d- -f1)
15+
echo "Resolved latest python version: $PATCH"
16+
echo "##vso[task.setvariable variable=LD_LIBRARY_PATH;]/agent/_work/_tool/Python/${PATCH}/x64/lib/"
17+
displayName: 'Query and set python tool cache path'
18+
19+
720
- task: UsePythonVersion@0
21+
name: UsePy
22+
displayName: 'Use Python 3.13'
823
inputs:
9-
versionSpec: '3.8'
24+
versionSpec: '3.13'
25+
26+
- bash: |
27+
echo "Checking the python version in use to set LD_LIBRARY_PATH"
28+
echo "Python location: $(UsePy.pythonLocation)"
29+
echo "##vso[task.setvariable variable=LD_LIBRARY_PATH]$(UsePy.pythonLocation)/lib"
30+
displayName: 'Set LD_LIBRARY_PATH'
31+
1032
1133
- bash: |
1234
tfenv use 0.14.6

0 commit comments

Comments
 (0)