Skip to content

Commit

Permalink
Fix test-version bump (#1013)
Browse files Browse the repository at this point in the history
* Fix bump test logic
  • Loading branch information
umbertoDifa authored Feb 25, 2025
1 parent 9244d22 commit 71242aa
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 30 deletions.
23 changes: 4 additions & 19 deletions .github/workflows/EVENT_pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,30 +20,15 @@ jobs:
permissions:
contents: read

format:
name: Check format of python
python_checks:
name: Python Checks
needs: get_changed_files
if: needs.get_changed_files.outputs.python_changed_files != ''
uses: ./.github/workflows/JOB_format.yml
with:
files: ${{ needs.get_changed_files.outputs.python_changed_files }}
permissions:
contents: read

lint:
name: Lint python
needs: get_changed_files
if: needs.get_changed_files.outputs.python_changed_files != ''
uses: ./.github/workflows/JOB_lint.yml
uses: ./.github/workflows/JOB_python_checks.yml

with:
files: ${{ needs.get_changed_files.outputs.python_changed_files }}
permissions:
contents: read

run_tests:
name: Run tests
needs: get_changed_files
if: needs.get_changed_files.outputs.python_changed_files != ''
uses: ./.github/workflows/JOB_tests.yml
permissions:
contents: read
24 changes: 24 additions & 0 deletions .github/workflows/JOB_python_checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Python Checks
on:
workflow_call:
inputs:
files:
required: true
type: string

jobs:
format:
name: Check format
uses: ./.github/workflows/JOB_format.yml
with:
files: ${{ inputs.files }}

lint:
name: Lint
uses: ./.github/workflows/JOB_lint.yml
with:
files: ${{ inputs.files }}

run_tests:
name: Run tests
uses: ./.github/workflows/JOB_tests.yml
34 changes: 23 additions & 11 deletions .github/workflows/version_bump.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,28 +47,40 @@ jobs:
- name: Bump version
run: |
python deploy/increase_version.py --${{ inputs.bump_type }}
BASE_VERSION=$(cat .version)
if [[ "${{ inputs.test_mode }}" == "true" ]]; then
TIMESTAMP=$(date +%Y%m%d%H%M%S)
echo "NEW_VERSION=0.0.0-test.${TIMESTAMP}" >> $GITHUB_ENV
echo "TAG_PREFIX=test-" >> $GITHUB_ENV
echo "BRANCH_NAME=test/version-bump" >> $GITHUB_ENV
TEST_VERSION="${BASE_VERSION}-test.${TIMESTAMP}"
# Update version in pyproject.toml and __init__.py
sed -i "s/^version = .*/version = \"${TEST_VERSION}\"/" pyproject.toml
sed -i "s/__version__ = .*/__version__ = \"${TEST_VERSION}\"/" darwin/__init__.py
NEW_VERSION="${BASE_VERSION}-test.${TIMESTAMP}"
TAG_PREFIX="test-"
BRANCH_NAME="test/version-bump"
else
python deploy/increase_version.py --${{ inputs.bump_type }}
NEW_VERSION=$(cat .version)
echo "NEW_VERSION=${NEW_VERSION}" >> $GITHUB_ENV
echo "TAG_PREFIX=v" >> $GITHUB_ENV
echo "BRANCH_NAME=master" >> $GITHUB_ENV
NEW_VERSION="${BASE_VERSION}"
TAG_PREFIX="v"
BRANCH_NAME="master"
fi
echo "NEW_VERSION=${NEW_VERSION}" >> $GITHUB_ENV
echo "TAG_PREFIX=${TAG_PREFIX}" >> $GITHUB_ENV
echo "BRANCH_NAME=${BRANCH_NAME}" >> $GITHUB_ENV
- name: Commit and push changes
if: ${{ inputs.test_mode != 'true' }}
run: |
git add pyproject.toml darwin/__init__.py
git commit -m "Version bump to ${{ env.NEW_VERSION }}"
if [[ "${{ inputs.test_mode }}" == "true" ]]; then
git checkout -b ${BRANCH_NAME}
fi
git push origin HEAD:${BRANCH_NAME}
- name: Create test branch
if: ${{ inputs.test_mode == 'true' }}
run: |
git checkout -b ${BRANCH_NAME}
git push origin ${BRANCH_NAME}
- name: Create and push tag
run: |
git tag -a "${TAG_PREFIX}${NEW_VERSION}" -m "bump version to ${TAG_PREFIX}${NEW_VERSION}"
Expand Down

0 comments on commit 71242aa

Please sign in to comment.