Skip to content

Add input to disable macos x86 for the dev workflow (since it can be … #9

Add input to disable macos x86 for the dev workflow (since it can be …

Add input to disable macos x86 for the dev workflow (since it can be … #9

name: 'Build and test wheel'

Check failure on line 1 in .github/workflows/build-and-test-wheels-on-one-platform.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/build-and-test-wheels-on-one-platform.yml

Invalid workflow file

(Line: 150, Col: 18): Unexpected symbol: '['. Located at position 105 within expression: inputs.platform_tag == 'macosx_x86_64' && 'macos-14-large' || (inputs.platform_tag == 'macosx_arm64' && ['self-hosted', 'macOS', 'ARM64'] || ['self-hosted', 'Windows', 'X64'])
run-name: 'Build wheels (python-versions=${{ inputs.python-versions }}, platform-tag=${{ inputs.platform-tag }}, unoptimized=${{ inputs.unoptimized }}, include-debug-info-for-macos=${{ inputs.include-debug-info-for-macos }}, run_tests=${{ inputs.run_tests }}, registry-name=${{ inputs.registry-name }}, image-name=${{ inputs.image-name }}, server-tag=${{ inputs.server-tag }}, test-file=${{ inputs.test-file }})'
# Build wheels on all (or select) Python versions supported by the Python client for a specific platform
permissions:
id-token: write
contents: read
on:
workflow_dispatch:
inputs: &inputs
# These are the usual cases for building wheels:
#
# 1. One wheel for *one* supported Python version. This is for running specialized tests that only need one Python version
# like valgrind or a failing QE test. And usually, we only need one wheel for debugging purposes.
# 2. Wheels for *all* supported Python versions for *one* supported platform. This is useful for testing workflow changes for a
# single OS or CPU architecture (e.g testing that changes to debugging modes work on all Python versions)
# 3. Wheels for *all* supported Python versions and *all* supported platforms. This is for building wheels for different
# CI/CD stages (e.g dev, stage, or master). We can also test debugging modes for all platforms that support them
#
# We're able to combine case 1 and 2 into one workflow by creating an input that takes in a JSON list of strings (Python tags)
# to build wheels for. Actual list inputs aren't supported yet, so it's actually a JSON list encoded as a string.
#
# However, it's harder to combine this workflow (case 1 + 2) with case 3, because matrix outputs don't exist yet
# in Github Actions. So all jobs in the build-wheel job would have to pass for a self hosted job to run.
# We want each platform to be tested independently of each other,
# so there is a wrapper workflow that has a list of platforms to test and reuses this workflow for each platform.
# If one platform fails, it will not affect the building and testing of another platform (we disable fail fast mode)
python-versions:
type: string
description: Valid JSON list of Python tags to build the client for.
required: false
default: '["3.10", "3.11", "3.12", "3.13", "3.14"]'
platform-tag:
# One of these values:
# - manylinux_x86_64
# - manylinux_aarch64
# - macosx_x86_64
# - macosx_arm64
# - win_amd64
description: Platform to build the client for.
type: string
required: true
default: manylinux_x86_64
unoptimized:
description: 'macOS or Linux: Apply -O0 flag?'
# Windows supports a different flag to disable optimizations, but we haven't added support for it yet
type: boolean
required: false
default: false
include-debug-info-for-macos:
description: 'macOS: Build wheels for debugging?'
type: boolean
required: false
default: false
run_tests:
description: 'Run Aerospike server and run tests using built wheels?'
type: boolean
required: false
default: false
registry-name:
type: string
required: false
description: Registry name
default: 'docker.io'
image-name:
type: string
required: false
description: Image name
default: 'aerospike/aerospike-server-enterprise'
server-tag:
type: string
required: true
default: 'latest'
description: 'Server docker image tag'
test-file:
type: string
required: false
default: ''
description: 'new_tests/<value>'
test-macos-x86:
type: boolean
required: false
default: true
workflow_call:
inputs: *inputs
jobs:
# Maps don't exist in Github Actions, so we have to store the map using a script and fetch it in a job
# This uses up more billing minutes (rounded up to 1 minute for each job run),
# but this should be ok based on the minutes usage data for the aerospike organization
get-build-runner-os:
outputs:
runner-os: ${{ steps.get-runner-os.outputs.runner_os }}
runs-on: ubuntu-22.04
steps:
- name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@8d3c67de8e2fe68ef647c8db1e6a09f647780f40 # v2.19.0
with:
egress-policy: audit
- id: get-runner-os
# Single source of truth for which runner OS to use for each platform tag
run: |
declare -A hashmap
hashmap[manylinux_x86_64]="ubuntu-22.04"
hashmap[manylinux_aarch64]="ubuntu-22.04-arm"
hashmap[macosx_x86_64]="macos-14-large"
hashmap[macosx_arm64]="macos-14"
hashmap[win_amd64]="windows-2022"
echo runner_os=${hashmap[${{ inputs.platform-tag }}]} >> $GITHUB_OUTPUT
# Bash >= 4 supports hashmaps
shell: bash
build-wheel:
needs: get-build-runner-os
strategy:
matrix:
runs-on: ${{ needs.get-build-runner-os.outputs.runner_os }}
python-version: ${{ fromJson(inputs.python-versions) }}
fail-fast: false
uses: aerospike/shared-workflows/.github/workflows/reusable_execute-build.yaml@1004088a1b5122b9b71a39b40f619f6b50e78d16
with:
jf-project: ${{ vars.JFROG_PROJECT_FOR_CLIENT_TEAM }}
jf-build-name: ${{ vars.JFROG_BUILD_NAME }}
jf-build-id: ${{ github.run_id }}-${{ github.run_attempt }}
gh-artifact-name: ${{ vars.GH_ARTIFACT_NAME_PREFIX_FOR_BUILDS }}-${{ matrix.python-version }}-${{ inputs.platform-tag }}
gh-artifact-directory: wheelhouse
gh-workflows-ref: 1004088a1b5122b9b71a39b40f619f6b50e78d16
oidc-provider-name: ${{ vars.OIDC_PROVIDER_NAME }}
oidc-audience: ${{ vars.OIDC_AUDIENCE }}
build-script-path: ./build-prod-wheel.bash
setup-python: true
build-env: "MANYLINUX_REGISTRY_NAME=${{ vars.JF_EXTERNAL_URL }}/${{ vars.JFROG_REPO_FOR_CUSTOM_MANYLINUX_IMAGES }}"
test-wheel:
if: ${{ inputs.run_tests && !startsWith(inputs.platform_tag, 'manylinux') && (inputs.platform_tag != 'macosx_x86_64' || inputs.test-macos-x86 == true) }}
needs: [
build-wheel
]
strategy:
fail-fast: false
matrix:
python-version: ${{ fromJSON(inputs.python-versions) }}
uses: ./.github/workflows/test-wheel.yml
with:
# Not the prettiest solution...
runner-os: ${{ inputs.platform_tag == 'macosx_x86_64' && 'macos-14-large' || (inputs.platform_tag == 'macosx_arm64' && ['self-hosted', 'macOS', 'ARM64'] || ['self-hosted', 'Windows', 'X64']) }}
python-version: ${{ matrix.python-version }}
test-manylinux-wheel:
if: ${{ inputs.run_tests && startsWith(inputs.platform-tag, 'manylinux') }}
needs: [
build-wheel
]
uses: ./.github/workflows/test-wheel-in-container.yml
strategy:
fail-fast: false
matrix:
python-version: ${{ fromJSON(inputs.python-versions) }}
with:
python-version: ${{ matrix.python-version }}
container-image-name: quay.io/pypa/manylinux_2_28_${{ endsWith(inputs.platform-tag, 'x86_64') && 'x86_64' || 'aarch64' }}
cpu-arch: ${{ endsWith(matrix.image-name, 'x86_64') && 'x86_64' || 'aarch64' }}