Skip to content

Commit 17c4787

Browse files
committed
Reduce code repetition by reusing workflows
1 parent 5d69381 commit 17c4787

2 files changed

Lines changed: 69 additions & 208 deletions

File tree

.github/workflows/stage-tests.yml

Lines changed: 39 additions & 206 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ on:
1919
required: false
2020
# These will be set if use_jfrog_builds is false (i.e when someone is building the artifacts from scratch and stage testing them in a calling workflow)
2121
# If use_jfrog_builds is true, only the defaults will be used
22+
python-versions-to-test:
23+
required: true
24+
type: string
2225
registry-name:
2326
type: string
2427
required: false
@@ -55,228 +58,58 @@ jobs:
5558
strategy:
5659
matrix:
5760
test-case: [
58-
# Docker image + tag, test category, Docker image platform (cpu arch), Python version
59-
["amazonlinux:2023", "x86_64", "3.11"],
60-
["amazonlinux:2023", "aarch64", "3.11"],
61-
["ubuntu:22.04", "x86_64", "3.10"],
62-
["ubuntu:22.04", "aarch64", "3.10"],
63-
["ubuntu:24.04", "x86_64", "3.12"],
64-
["ubuntu:24.04", "aarch64", "3.12"],
61+
# Docker image + tag, Docker image platform (cpu arch), Python version, build-from-source
62+
["amazonlinux:2023", "x86_64", "3.11", false],
63+
["amazonlinux:2023", "aarch64", "3.11", false],
64+
65+
# TODO - Probably can remove this if we reuse the test workflow
66+
["ubuntu:22.04", "x86_64", "3.10", false],
67+
["ubuntu:22.04", "aarch64", "3.10", false],
68+
["ubuntu:24.04", "x86_64", "3.12", false],
69+
["ubuntu:24.04", "aarch64", "3.12", false],
70+
6571
# Bookworm is Debian 12
66-
["python:3.10-bookworm", "x86_64", "3.10"],
67-
["python:3.10-bookworm", "aarch64", "3.10"],
68-
["python:3.11-bookworm", "x86_64", "3.11"],
69-
["python:3.11-bookworm", "aarch64", "3.11"],
70-
["python:3.12-bookworm", "x86_64", "3.12"],
71-
["python:3.12-bookworm", "aarch64", "3.12"],
72-
["python:3.13-bookworm", "x86_64", "3.13"],
73-
["python:3.13-bookworm", "aarch64", "3.13"],
74-
["python:3.14-rc-bookworm", "x86_64", "3.14"],
75-
["python:3.14-rc-bookworm", "aarch64", "3.14"],
72+
["python:3.10-bookworm", "x86_64", "3.10", false],
73+
["python:3.10-bookworm", "aarch64", "3.10", false],
74+
["python:3.11-bookworm", "x86_64", "3.11", false],
75+
["python:3.11-bookworm", "aarch64", "3.11", false],
76+
["python:3.12-bookworm", "x86_64", "3.12", false],
77+
["python:3.12-bookworm", "aarch64", "3.12", false],
78+
["python:3.13-bookworm", "x86_64", "3.13", false],
79+
["python:3.13-bookworm", "aarch64", "3.13", false],
80+
["python:3.14-rc-bookworm", "x86_64", "3.14", false],
81+
["python:3.14-rc-bookworm", "aarch64", "3.14", false],
7682
# QE currently covers Debian 13 on all client-supported Python versions
7783
# We do not use ubi9/python-311 because we cannot install packages using dnf as root
78-
["redhat/ubi9", "x86_64", "3.11"],
79-
["redhat/ubi9", "aarch64", "3.11"],
84+
["redhat/ubi9", "x86_64", "3.11", false],
85+
["redhat/ubi9", "aarch64", "3.11", false],
86+
87+
["amazonlinux:2023", 1, "linux/amd64", "3.11", true],
88+
["redhat/ubi9", 1, "linux/amd64", "3.11", true],
8089
]
8190
fail-fast: false
8291
uses: ./.github/workflows/test-wheel-in-container.yml
8392
with:
8493
container-image-name: ${{ matrix.test-case[0] }}
8594
cpu-arch: ${{ matrix.test-case[1] }}
8695
python-version: ${{ matrix.test-case[2] }}
87-
88-
linux-distro-source-build-tests:
89-
strategy:
90-
matrix:
91-
test-case: [
92-
# Docker image + tag, test category, Docker image platform (cpu arch), Python version
93-
["amazonlinux:2023", 1, "linux/amd64", "3.11"],
94-
["redhat/ubi9", 1, "linux/amd64", "3.11"],
95-
]
96-
fail-fast: false
97-
env:
98-
LINUX_DISTRO_CONTAINER_NAME: linux-distro
99-
PIP_INSTALL_COMMAND: 'pip install'
100-
runs-on: ${{ matrix.test-case[2] == 'linux/amd64' && 'ubuntu-22.04' || 'ubuntu-22.04-arm' }}
101-
steps:
102-
# TODO: the checkout code is also duplicated in the macOS stage tests
103-
# But it's only a few lines of code so I didn't bother to create a composite action for it.
104-
- name: Harden the runner (Audit all outbound calls)
105-
uses: step-security/harden-runner@8d3c67de8e2fe68ef647c8db1e6a09f647780f40 # v2.19.0
106-
with:
107-
egress-policy: audit
108-
109-
- name: Get tests and Github action scripts
110-
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
111-
with:
112-
ref: ${{ inputs.use_jfrog_builds && inputs.jfrog-build-version-to-test || github.sha }}
113-
sparse-checkout: |
114-
test
115-
.github
116-
117-
# Map test case tuple entries to env vars to make code easier to read
118-
- run: echo "DISTRO_DOCKER_IMAGE_AND_TAG=${{ matrix.test-case[0] }}" >> $GITHUB_ENV
119-
- run: echo "TEST_CATEGORY=${{ matrix.test-case[1] }}" >> $GITHUB_ENV
120-
- run: echo "DISTRO_DOCKER_IMAGE_PLATFORM=${{ matrix.test-case[2] }}" >> $GITHUB_ENV
121-
- run: echo "PYTHON_VERSION=${{ matrix.test-case[3] }}" >> $GITHUB_ENV
122-
123-
- uses: ./.github/actions/get-artifact-for-stage-tests
124-
with:
125-
get_from_jfrog: ${{ inputs.use_jfrog_builds }}
126-
# This input is only used if above input is true
127-
jfrog_build_version: ${{ inputs.jfrog-build-version-to-test }}
128-
dist_type_to_get: ${{ env.TEST_CATEGORY == '2' && 'wheel' || 'sdist' }}
129-
# wheel* inputs are used only if running category 2 tests
130-
wheel_python_version: ${{ env.PYTHON_VERSION }}
131-
wheel_os: manylinux
132-
wheel_cpu_arch: ${{ env.DISTRO_DOCKER_IMAGE_PLATFORM == 'linux/amd64' && 'x86_64' || 'aarch64' }}
133-
jfrog-platform-url: ${{ vars.JF_EXTERNAL_URL }}
134-
jfrog-project: ${{ vars.JFROG_PROJECT_FOR_CLIENT_TEAM }}
135-
jfrog-oidc-provider-name: ${{ vars.OIDC_PROVIDER_NAME }}
136-
jfrog-oidc-audience: ${{ vars.OIDC_AUDIENCE }}
137-
gh_artifact_name_prefix: ${{ vars.GH_ARTIFACT_NAME_PREFIX_FOR_BUILDS }}
138-
139-
- uses: ./.github/actions/run-ee-server
140-
with:
141-
registry-name: ${{ inputs.registry-name }}
142-
registry-username: ${{ env.REGISTRY_USERNAME }}
143-
registry-password: ${{ env.REGISTRY_PASSWORD }}
144-
image-name: ${{ inputs.image-name }}
145-
server-tag: ${{ inputs.server-tag }}
146-
where-is-client-connecting-from: 'separate-docker-container'
147-
148-
- name: Run distro container
149-
# Run distro container on host network to access the Aerospike server using localhost (without having to change config.conf)
150-
run: docker run --detach --network host --platform ${{ env.DISTRO_DOCKER_IMAGE_PLATFORM }} --name ${{ env.LINUX_DISTRO_CONTAINER_NAME }} ${{ env.DISTRO_DOCKER_IMAGE_AND_TAG }} tail -f /dev/null
151-
152-
- name: Copy repo (and artifact) to container
153-
run: docker cp . ${{ env.LINUX_DISTRO_CONTAINER_NAME }}:/aerospike-client-python
154-
155-
- name: 'DNF based distros: install python3'
156-
if: ${{ env.DISTRO_DOCKER_IMAGE_AND_TAG == 'amazonlinux:2023' || contains(env.DISTRO_DOCKER_IMAGE_AND_TAG, 'ubi') }}
157-
run: docker exec ${{ env.LINUX_DISTRO_CONTAINER_NAME }} dnf install -y python3.11
158-
159-
- name: 'Ubuntu: Install python 3 that comes by default (step 1)'
160-
if: ${{ startsWith(env.DISTRO_DOCKER_IMAGE_AND_TAG, 'ubuntu') }}
161-
run: |
162-
docker exec ${{ env.LINUX_DISTRO_CONTAINER_NAME }} apt-get update
163-
docker exec ${{ env.LINUX_DISTRO_CONTAINER_NAME }} apt-get install python3 python3-pip -y
164-
165-
- name: Make sure pip is installed
166-
# This is good to check in general, so we run for all distros
167-
# Ubuntu doesn't have this by default though, but it's fine since it has pip already
168-
if: ${{ !startsWith(env.DISTRO_DOCKER_IMAGE_AND_TAG, 'ubuntu') }}
169-
run: docker exec ${{ env.LINUX_DISTRO_CONTAINER_NAME }} python${{ env.PYTHON_VERSION }} -m ensurepip
170-
171-
- name: 'Cat 1: Install build dependencies using dnf'
172-
# Here we assume all cat 1 tests are running on a dnf-based. distro
173-
if: ${{ env.TEST_CATEGORY == '1' }}
174-
run: |
175-
docker exec ${{ env.LINUX_DISTRO_CONTAINER_NAME }} dnf install -y libyaml-devel \
176-
openssl-devel \
177-
glibc-devel \
178-
autoconf \
179-
automake \
180-
libtool \
181-
zlib-devel \
182-
openssl-devel \
183-
python3.11-devel
184-
185-
- if: ${{ env.DISTRO_DOCKER_IMAGE_AND_TAG == 'ubuntu:24.04' }}
186-
# Python 3.12+ fails to install packages to the system directory by default
187-
run: echo PIP_INSTALL_COMMAND="$PIP_INSTALL_COMMAND --break-system-packages" >> $GITHUB_ENV
188-
189-
- name: 'Cat 1: Install pip build frontend'
190-
if: ${{ env.TEST_CATEGORY == '1' }}
191-
run: docker exec --workdir /aerospike-client-python/ ${{ env.LINUX_DISTRO_CONTAINER_NAME }} python${{ env.PYTHON_VERSION }} -m ${{ env.PIP_INSTALL_COMMAND }} -r requirements.txt
192-
193-
- name: Install sdist or wheel distribution
194-
run: docker exec --workdir /aerospike-client-python/ ${{ env.LINUX_DISTRO_CONTAINER_NAME }} python${{ env.PYTHON_VERSION }} -m ${{ env.PIP_INSTALL_COMMAND }} ${{ env.ARTIFACT_FILE_NAME_PATTERN }}
195-
196-
- name: Install pytest
197-
run: docker exec --workdir /aerospike-client-python/test ${{ env.LINUX_DISTRO_CONTAINER_NAME }} python${{ env.PYTHON_VERSION }} -m ${{ env.PIP_INSTALL_COMMAND }} pytest -c requirements.txt
198-
199-
- name: Run tests
200-
run: docker exec --workdir /aerospike-client-python/test ${{ env.LINUX_DISTRO_CONTAINER_NAME }} python${{ env.PYTHON_VERSION }} -m pytest new_tests/
96+
build-from-source: ${{ matrix.test-case[3] }}
20197

20298
macOS:
20399
if: ${{ inputs.test-macos-x86 }}
204100
strategy:
205101
matrix:
206-
runner-os-and-arch: [
102+
runner-os: [
207103
# These larger runners run on intel
208-
["macos-15-large", "x86_64"],
104+
# TODO: check if there's a regular size runner for x86
105+
"macos-15-large",
209106
# arm64, since x86 not avaiable as Github hosted runner
210-
["macos-26", "arm64"]
211-
]
212-
python-version: [
213-
"3.10",
214-
"3.11",
215-
"3.12",
216-
"3.13",
217-
"3.14"
107+
"macos-26"
218108
]
109+
python-version: ${{ fromJson(inputs.python-versions-to-test) }}
219110
fail-fast: false
220-
runs-on: ${{ matrix.runner-os-and-arch[0] }}
221-
steps:
222-
- name: Harden the runner (Audit all outbound calls)
223-
uses: step-security/harden-runner@8d3c67de8e2fe68ef647c8db1e6a09f647780f40 # v2.19.0
224-
with:
225-
egress-policy: audit
226-
227-
- name: Get tests and Github action scripts
228-
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
229-
with:
230-
ref: ${{ inputs.use_jfrog_builds && inputs.jfrog-build-version-to-test || github.sha }}
231-
sparse-checkout: |
232-
test
233-
.github
234-
235-
- uses: ./.github/actions/get-artifact-for-stage-tests
236-
with:
237-
# See comments in linux stage tests for how this works
238-
get_from_jfrog: ${{ inputs.use_jfrog_builds }}
239-
jfrog_build_version: ${{ inputs.jfrog-build-version-to-test }}
240-
dist_type_to_get: 'wheel'
241-
wheel_python_version: ${{ matrix.python-version }}
242-
wheel_os: macosx
243-
wheel_cpu_arch: ${{ matrix.runner-os-and-arch[1] }}
244-
jfrog-platform-url: ${{ vars.JF_EXTERNAL_URL }}
245-
jfrog-project: ${{ vars.JFROG_PROJECT_FOR_CLIENT_TEAM }}
246-
jfrog-oidc-provider-name: ${{ vars.OIDC_PROVIDER_NAME }}
247-
jfrog-oidc-audience: ${{ vars.OIDC_AUDIENCE }}
248-
249-
- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
250-
with:
251-
python-version: ${{ matrix.python-version }}
252-
253-
- if: ${{ matrix.runner-os-and-arch[1] == 'x86_64' }}
254-
uses: ./.github/actions/setup-docker-on-macos
255-
256-
- if: ${{ matrix.runner-os-and-arch[1] == 'x86_64' }}
257-
uses: ./.github/actions/run-ee-server
258-
with:
259-
registry-name: ${{ inputs.registry-name }}
260-
registry-username: ${{ env.REGISTRY_USERNAME }}
261-
registry-password: ${{ env.REGISTRY_PASSWORD }}
262-
image-name: ${{ inputs.image-name }}
263-
server-tag: ${{ inputs.server-tag }}
264-
where-is-client-connecting-from: 'docker-host'
265-
266-
- name: Install wheel
267-
run: python3 -m pip install *.whl
268-
269-
- name: Install test dependencies
270-
if: ${{ matrix.runner-os-and-arch[1] == 'x86_64' }}
271-
run: python3 -m pip install pytest -c requirements.txt
272-
working-directory: test
273-
274-
- name: Run tests
275-
if: ${{ matrix.runner-os-and-arch[1] == 'x86_64' }}
276-
run: python3 -m pytest new_tests/
277-
working-directory: test
278-
279-
- name: Run tests on macos 26
280-
if: ${{ matrix.runner-os-and-arch[1] == 'arm64' }}
281-
run: python3 -c "import aerospike"
282-
working-directory: test
111+
uses: ./.github/workflows/test-wheel.yml
112+
with:
113+
runner-os: ${{ matrix.runner-os }}
114+
python-version: ${{ matrix.python-version }}
115+
# TODO: will fail without passing in required inputs

.github/workflows/test-wheel-in-container.yml

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Test wheel inside container
1+
name: (Optionally build and) test wheel inside container
22

33
on:
44
workflow_call:
@@ -12,6 +12,11 @@ on:
1212
python-version:
1313
required: true
1414
type: string
15+
build-from-source:
16+
required: true
17+
default: false
18+
description: 'If false, download wheel artifact from Github'
19+
type: boolean
1520

1621
jobs:
1722
test-wheel:
@@ -26,6 +31,10 @@ jobs:
2631
egress-policy: audit
2732

2833
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
34+
with:
35+
sparse-checkout: |
36+
test
37+
.github
2938
3039
- run: docker run -d --name "$CONTAINER_NAME" "${{ inputs.container-image-name }}" tail -f /dev/null
3140

@@ -35,7 +44,7 @@ jobs:
3544
server-tag: latest
3645
docker-hub-username: ${{ secrets.DOCKER_HUB_BOT_USERNAME }}
3746
docker-hub-password: ${{ secrets.DOCKER_HUB_BOT_PW }}
38-
where-is-client-connecting-from: 'docker-container'
47+
where-is-client-connecting-from: 'separate-docker-container'
3948

4049
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
4150
with:
@@ -45,6 +54,25 @@ jobs:
4554
- name: Copy repo and wheel into container
4655
run: docker cp ../$REPO_DIR_NAME $CONTAINER_NAME:/
4756

57+
- name: 'DNF based distros: install python3'
58+
if: ${{ inputs.container-image-name == 'amazonlinux:2023' || contains(inputs.container-image-name, 'ubi') }}
59+
run: docker exec "$CONTAINER_NAME" dnf install -y python3.11
60+
61+
- name: 'Cat 1: Install build dependencies'
62+
# Here we assume all cat 1 tests are running on a dnf-based. distro
63+
run: |
64+
docker exec "$CONTAINER_NAME" dnf install -y libyaml-devel \
65+
openssl-devel \
66+
glibc-devel \
67+
autoconf \
68+
automake \
69+
libtool \
70+
zlib-devel \
71+
openssl-devel \
72+
python3.11-devel
73+
docker exec --workdir /$REPO_DIR_NAME "$CONTAINER_NAME" python${{ inputs.python-version }} -m pip install -r requirements.txt
74+
docker exec --workdir /$REPO_DIR_NAME "$CONTAINER_NAME" python${{ inputs.python-version }} -m build
75+
4876
- name: Install wheel
4977
run: docker exec --workdir /$REPO_DIR_NAME "$CONTAINER_NAME" python${{ inputs.python-version }} -m pip install *.whl
5078

0 commit comments

Comments
 (0)