-
Notifications
You must be signed in to change notification settings - Fork 111
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CLIENT-1837] CI/CD: Label version with git commit when building on a…
… non-tagged commit (#605) * Also label version when building unoptimized, with macOS debug support, or with uncommitted changes to the repo (i.e add a "dirty" label) * Rename config.conf to config.conf.template and add config.conf to .gitignore, so creating and modifying config.conf won't cause the repo to be in a dirty state
- Loading branch information
1 parent
f321c35
commit 17335dc
Showing
12 changed files
with
149 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -97,6 +97,7 @@ jobs: | |
with: | ||
submodules: recursive | ||
ref: ${{ inputs.ref }} | ||
fetch-depth: 0 | ||
|
||
- name: Install build dependencies (pip packages) | ||
run: python3 -m pip install -r requirements.txt | ||
|
@@ -147,6 +148,7 @@ jobs: | |
with: | ||
submodules: recursive | ||
ref: ${{ inputs.ref }} | ||
fetch-depth: 0 | ||
|
||
- name: Set up QEMU for cross compiling arm64 | ||
if: ${{ matrix.platform == 'aarch64' }} | ||
|
@@ -170,16 +172,6 @@ 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.apply-no-optimizations }} | ||
run: echo DEBUG_VERSION="$(cat VERSION)+unoptimized" >> $GITHUB_ENV | ||
|
||
- name: Label version for debugging | ||
if: ${{ inputs.apply-no-optimizations }} | ||
uses: ./.github/actions/update-version | ||
with: | ||
new_version: ${{ env.DEBUG_VERSION }} | ||
|
||
- name: Set unoptimize flag | ||
if: ${{ inputs.apply-no-optimizations }} | ||
run: echo "UNOPTIMIZED=1" >> $GITHUB_ENV | ||
|
@@ -235,6 +227,7 @@ jobs: | |
with: | ||
submodules: recursive | ||
ref: ${{ inputs.ref }} | ||
fetch-depth: 0 | ||
|
||
- name: Install Docker Engine | ||
if: ${{ inputs.run_tests }} | ||
|
@@ -323,6 +316,7 @@ jobs: | |
with: | ||
submodules: recursive | ||
ref: ${{ inputs.ref }} | ||
fetch-depth: 0 | ||
|
||
# Update dependencies if needed | ||
- name: Add brew to path | ||
|
@@ -381,6 +375,10 @@ jobs: | |
run: python${{ matrix.python-version[1] }} -m pip install --break-system-packages --force-reinstall delocate -c ./requirements.txt | ||
working-directory: .github/workflows | ||
|
||
- name: Create config.conf | ||
run: cp config.conf.template config.conf | ||
working-directory: test | ||
|
||
- run: delocate-wheel --require-archs "arm64" -w wheelhouse/ -v dist/*.whl | ||
- run: python${{ matrix.python-version[1] }} -m pip install --break-system-packages --find-links=wheelhouse/ --no-index --force-reinstall aerospike | ||
|
||
|
@@ -439,6 +437,7 @@ jobs: | |
with: | ||
submodules: recursive | ||
ref: ${{ inputs.ref }} | ||
fetch-depth: 0 | ||
|
||
- name: Add msbuild to PATH | ||
uses: microsoft/[email protected] | ||
|
@@ -498,6 +497,11 @@ jobs: | |
uses: actions/download-artifact@v4 | ||
with: | ||
name: ${{ matrix.python[0] }}-win_amd64.build | ||
|
||
- name: Create config.conf | ||
run: cp config.conf.template config.conf | ||
working-directory: test | ||
|
||
- name: Install wheel | ||
run: python${{ matrix.python[1] }} -m pip install aerospike --force-reinstall --no-index --find-links=./ | ||
- name: Connect to Docker container on remote machine with Docker daemon | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
from parver import Version | ||
import versioningit | ||
from typing import Any, Dict, Union | ||
import pathlib | ||
|
||
import versioningit.basics | ||
import versioningit.git | ||
import os | ||
|
||
# Take in <version> and <string> as input | ||
# If local version identifier doesn't exist, append +<string> to <version> | ||
# Example: 15.0.0rc1 and dsym as input -> 15.0.0rc1+dsym | ||
# If it does exist, append <version> with .<string> | ||
# Then output new version as str | ||
def append_to_local(version_str: str, value: str) -> str: | ||
version = Version.parse(version_str, strict=True) | ||
if version.local == None: | ||
new_local = value | ||
else: | ||
new_local = f"{version.local}.{value}" | ||
|
||
version = version.replace(local=new_local) | ||
return version.__str__() | ||
|
||
def my_vcs( | ||
project_dir: Union[str, pathlib.Path], | ||
params: Dict[str, Any] | ||
) -> versioningit.VCSDescription: | ||
vcs_description = versioningit.git.describe_git( | ||
project_dir=project_dir, | ||
params=params | ||
) | ||
if vcs_description.state == "exact": | ||
# We don't want the format step to be skipped | ||
# Workaround: https://github.com/jwodder/versioningit/issues/42#issuecomment-1235573432 | ||
vcs_description.state = "exact_" | ||
return vcs_description | ||
|
||
def my_format( | ||
description: versioningit.VCSDescription, | ||
base_version: str, | ||
next_version: str, | ||
params: Dict[str, Any] | ||
) -> str: | ||
# Even if the repository state matches a tag, we always need to label the version if it's unoptimized or includes | ||
# dsym for macOS | ||
if description.state != "exact_": | ||
version_str = versioningit.basics.basic_format( | ||
description=description, | ||
base_version=base_version, | ||
next_version=next_version, | ||
params=params | ||
) | ||
else: | ||
version_str = base_version | ||
|
||
if os.getenv("UNOPTIMIZED"): | ||
version_str = append_to_local(version_str, "unoptimized") | ||
if os.getenv("INCLUDE_DSYM"): | ||
version_str = append_to_local(version_str, "dsym") | ||
|
||
return version_str |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
config.conf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.