Skip to content

Commit

Permalink
[CLIENT-2279] CI/CD: Add option to build debug wheels (#508)
Browse files Browse the repository at this point in the history
  • Loading branch information
juliannguyen4 committed Feb 20, 2024
1 parent 88f92d2 commit 7f99182
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 14 deletions.
17 changes: 17 additions & 0 deletions .github/actions/update-version/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: 'Update version'
description: 'Update version in repo without committing. Repo must already be checked out'
inputs:
new_version:
description: Version string to set
required: true

runs:
using: "composite"
steps:
- name: Update __version__ in aerospike module
run: sed -i "s/const char version\[] = \".*\";/const char version\[] = \"${{ inputs.new_version }}\";/" src/main/aerospike.c
shell: bash

- name: Update VERSION metadata
run: echo ${{ inputs.new_version }} > VERSION
shell: bash
28 changes: 26 additions & 2 deletions .github/workflows/build-wheels.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: Build wheels
run-name: Build wheels (run_tests=${{ inputs.run_tests }}, use-server-rc=${{ inputs.use-server-rc }}, server-tag=${{ inputs.server-tag }}, test-macos-x86=${{ inputs.test-macos-x86 }})
run-name: Build wheels (run_tests=${{ inputs.run_tests }}, use-server-rc=${{ inputs.use-server-rc }}, server-tag=${{ inputs.server-tag }}, test-macos-x86=${{ inputs.test-macos-x86 }}, build-for-debugging=${{ inputs.build-for-debugging }})

# Builds manylinux wheels and source distribution
# If running tests, publish results in commit status
Expand Down Expand Up @@ -29,6 +29,11 @@ on:
type: boolean
default: false
description: 'Test macOS x86 wheels (unstable)'
build-for-debugging:
required: true
type: boolean
default: false
description: 'Apply -O0 when building C client and Python client? (Linux)'
workflow_call:
inputs:
# The "dev" tests test the artifacts against a server release
Expand All @@ -41,7 +46,7 @@ on:
ref:
type: string
required: false
# Calling workflow doesn't actually use the 2 options below
# Calling workflow doesn't actually use the options below
# But we need to set default values for workflow calls to use
use-server-rc:
required: false
Expand All @@ -55,6 +60,10 @@ on:
required: false
type: boolean
default: false
build-for-debugging:
required: false
type: boolean
default: false
secrets:
DOCKER_HUB_BOT_USERNAME:
required: false
Expand Down Expand Up @@ -151,9 +160,24 @@ jobs:
if: ${{ !inputs.run_tests }}
run: echo "TEST_COMMAND=python -c 'import aerospike'" >> $GITHUB_ENV

- name: Get current version if building a debug wheel
if: ${{ inputs.build-for-debugging }}
run: echo DEBUG_VERSION="$(cat VERSION)+unoptimized" >> $GITHUB_ENV

- name: Label version for debugging
if: ${{ inputs.build-for-debugging }}
uses: ./.github/actions/update-version
with:
new_version: ${{ env.DEBUG_VERSION }}

- name: Build without optimizations
if: ${{ inputs.build-for-debugging }}
run: echo "UNOPTIMIZED=1" >> $GITHUB_ENV

- name: Build wheel
uses: pypa/cibuildwheel@v2.15.0
env:
CIBW_ENVIRONMENT_PASS_LINUX: ${{ inputs.build-for-debugging && 'UNOPTIMIZED' || '' }}
CIBW_BUILD: ${{ matrix.python }}-manylinux_${{ matrix.platform }}
CIBW_BUILD_FRONTEND: build
CIBW_BEFORE_ALL_LINUX: >
Expand Down
9 changes: 4 additions & 5 deletions .github/workflows/update-version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,10 @@ jobs:
token: ${{ secrets.CLIENT_BOT_PAT }}
ref: ${{ inputs.ref }}

- name: Update __version__ in aerospike module
run: sed -i "s/const char version\[] = \".*\";/const char version\[] = \"${{ inputs.new_version }}\";/" src/main/aerospike.c

- name: Update VERSION metadata
run: echo ${{ inputs.new_version }} > VERSION
- name: Update version in repo
uses: ./.github/actions/update-version
with:
new_version: ${{ inputs.new_version }}

- name: Commit new version
uses: stefanzweifel/git-auto-commit-action@v4
Expand Down
14 changes: 7 additions & 7 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@
# Not for developers to use, unless you know what the workflow is doing!
COVERAGE = os.getenv('COVERAGE')

# Applies no optimizations on both the C client and Python client
UNOPTIMIZED = os.getenv('UNOPTIMIZED')

################################################################################
# GENERIC BUILD SETTINGS
################################################################################
Expand Down Expand Up @@ -107,13 +110,8 @@
extra_compile_args.append('-ftest-coverage')
extra_link_args.append('-lgcov')

# TODO: this conflicts with the C client's DEBUG mode when building it
# DEBUG = os.getenv('DEBUG')
# if DEBUG:
# extra_compile_args.append("-O0")
# else:
# # Release build
# extra_compile_args.append("-O1")
if UNOPTIMIZED:
extra_compile_args.append('-O0')

################################################################################
# STATIC SSL LINKING BUILD SETTINGS
Expand Down Expand Up @@ -228,6 +226,8 @@ def clean():
'make',
'V=' + str(self.verbose),
]
if UNOPTIMIZED:
cmd.append('O=0')

def compile():
print(cmd, library_dirs, libraries)
Expand Down

0 comments on commit 7f99182

Please sign in to comment.