Skip to content

Commit

Permalink
update workflows with commented out version bumping
Browse files Browse the repository at this point in the history
  • Loading branch information
danielfromearth committed Oct 25, 2023
1 parent 408c5fc commit e2815d1
Show file tree
Hide file tree
Showing 4 changed files with 115 additions and 117 deletions.
142 changes: 79 additions & 63 deletions .github/workflows/build-pipeline.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# When code is pushed to a branch, run linting and tests, and
# then automatically increment the version number as appropriate for the branch source.
name: On a Push
name: Lint and Test

# Controls when the workflow will run
on:
# Triggers the workflow on push events
push:
branches: [ develop, release/**, main, feature/**, issue/**, issues/** ]

Expand All @@ -16,17 +17,16 @@ jobs:

bump_version:
needs: run_tests
runs-on: ubuntu-20.04
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
- uses: actions/setup-python@v4
with:
python-version: '3.10'

- name: Set up Poetry
- name: Install Poetry
uses: abatilo/[email protected]
with:
poetry-version: 1.3.2
Expand All @@ -37,64 +37,52 @@ jobs:
echo "current_version=$(poetry version | awk '{print $2}')" >> $GITHUB_OUTPUT
echo "pyproject_name=$(poetry version | awk '{print $1}')" >> $GITHUB_ENV
- name: Bump pre-alpha version
# If triggered by push to a feature branch
if: |
${{ startsWith(github.ref, 'refs/heads/issue') }} ||
${{ startsWith(github.ref, 'refs/heads/dependabot/') }} ||
${{ startsWith(github.ref, 'refs/heads/feature/') }}
run: |
new_ver="${{ steps.get-version.outputs.current_version }}+$(git rev-parse --short ${GITHUB_SHA})"
poetry version $new_ver
echo "software_version=$(poetry version | awk '{print $2}')" >> $GITHUB_ENV
- name: Bump alpha version
# If triggered by push to the develop branch
if: ${{ github.ref == 'refs/heads/develop' }}
run: |
poetry version prerelease
echo "software_version=$(poetry version | awk '{print $2}')" >> $GITHUB_ENV
echo "venue=sit" >> $GITHUB_ENV
- name: Bump rc version
# If triggered by push to a release branch
if: ${{ startsWith(github.ref, 'refs/heads/release/') }}
env:
# True if the version already has a 'rc' pre-release identifier
BUMP_RC: ${{ contains(steps.get-version.outputs.current_version, 'rc') }}
run: |
if [ "$BUMP_RC" = true ]; then
poetry version prerelease
else
poetry version ${GITHUB_REF#refs/heads/release/}rc1
fi
echo "software_version=$(poetry version | awk '{print $2}')" >> $GITHUB_ENV
echo "venue=uat" >> $GITHUB_ENV
- name: Release version
# If triggered by push to the main branch
if: ${{ startsWith(github.ref, 'refs/heads/main') }}
env:
CURRENT_VERSION: ${{ steps.get-version.outputs.current_version }}
# True if the version already has a 'rc' pre-release identifier
BUMP_RC: ${{ contains(steps.get-version.outputs.current_version, 'rc') }}
# True if the version already has a 'alpha' pre-release identifier
BUMP_A: ${{ contains(steps.get-version.outputs.current_version, 'a') }}
# True if the version already has a 'beta' pre-release identifier
BUMP_B: ${{ contains(steps.get-version.outputs.current_version, 'b') }}
# Remove rc* from end of version string
# The ${string%%substring} syntax below deletes the longest match of $substring from back of $string.
run: |
if [ "$BUMP_RC" = true ]; then
poetry version ${CURRENT_VERSION%%rc*}
elif [ "$BUMP_B" = true ]; then
poetry version ${CURRENT_VERSION%%b*}
elif [ "$BUMP_A" = true ]; then
poetry version ${CURRENT_VERSION%%a*}
fi
echo "software_version=$(poetry version | awk '{print $2}')" >> $GITHUB_ENV
echo "venue=ops" >> $GITHUB_ENV
# - name: Bump pre-alpha version
# # If triggered by push to a feature branch
# if: |
# ${{ startsWith(github.ref, 'refs/heads/issue') }} ||
# ${{ startsWith(github.ref, 'refs/heads/dependabot/') }} ||
# ${{ startsWith(github.ref, 'refs/heads/feature/') }}
# run: |
# new_ver="${{ steps.get-version.outputs.current_version }}+$(git rev-parse --short ${GITHUB_SHA})"
# poetry version $new_ver
# echo "software_version=$(poetry version | awk '{print $2}')" >> $GITHUB_ENV
#
# - name: Bump alpha version
# # If triggered by push to the develop branch
# if: ${{ github.ref == 'refs/heads/develop' }}
# run: |
# poetry version prerelease
# echo "software_version=$(poetry version | awk '{print $2}')" >> $GITHUB_ENV
# echo "venue=sit" >> $GITHUB_ENV
#
# - name: Bump rc version
# # If triggered by push to a release branch
# if: ${{ startsWith(github.ref, 'refs/heads/release/') }}
# env:
# # True if the version already has a 'rc' pre-release identifier
# BUMP_RC: ${{ contains(steps.get-version.outputs.current_version, 'rc') }}
# run: |
# if [ "$BUMP_RC" = true ]; then
# poetry version prerelease
# else
# poetry version ${GITHUB_REF#refs/heads/release/}rc1
# fi
# echo "software_version=$(poetry version | awk '{print $2}')" >> $GITHUB_ENV
# echo "venue=uat" >> $GITHUB_ENV
#
# - name: Release version
# # If triggered by push to the main branch
# if: ${{ startsWith(github.ref, 'refs/heads/main') }}
# env:
# CURRENT_VERSION: ${{ steps.get-version.outputs.current_version }}
# # Remove rc* from the end of version string
# # The ${string%%substring} syntax below deletes the longest match of $substring from back of $string.
# run: |
# poetry version ${CURRENT_VERSION%%rc*}
# echo "software_version=$(poetry version | awk '{print $2}')" >> $GITHUB_ENV
# echo "venue=ops" >> $GITHUB_ENV
#
# - name: Commit Version Bump
# # If building develop, a release branch, or main then we commit the version bump back to the repo
# if: |
Expand All @@ -117,3 +105,31 @@ jobs:
# git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
# git tag -a "${{ env.software_version }}" -m "Version ${{ env.software_version }}"
# git push origin "${{ env.software_version }}"

# - name: Build Python Artifact
# run: |
# poetry build
#
# - uses: actions/upload-artifact@v3
# with:
# name: python-artifact
# path: dist/*
#
# - name: Publish to test.pypi.org
# id: pypi-test-publish
# if: |
# github.ref == 'refs/heads/develop' ||
# startsWith(github.ref, 'refs/heads/release')
# env:
# POETRY_PYPI_TOKEN_TESTPYPI: ${{secrets.POETRY_PYPI_TOKEN_TESTPYPI}}
# run: |
# poetry config repositories.testpypi https://test.pypi.org/legacy/
# poetry publish -r testpypi
#
# - name: Publish to pypi.org
# if: ${{ github.ref == 'refs/heads/main' }}
# id: pypi-publish
# env:
# POETRY_PYPI_TOKEN_PYPI: ${{secrets.POETRY_PYPI_TOKEN_PYPI}}
# run: |
# poetry publish
3 changes: 2 additions & 1 deletion .github/workflows/pull-request-received.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
# When a pull request is opened, run linting and tests.
name: Pull Request Received
name: Receive PR

# read-only repo token
# no access to secrets
on:
pull_request:
# Sequence of patterns matched against refs/heads
branches: [ feature/**, issue/**, issues/** ]

jobs:
Expand Down
48 changes: 20 additions & 28 deletions .github/workflows/release-created.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,39 +10,31 @@ jobs:
# First job in the workflow builds and verifies the software artifacts
bump:
name: Bump minor version on develop

# The type of runner that the job will run on
runs-on: ubuntu-latest

# Only run if ref created was a release branch
if:
${{ startsWith(github.ref, 'refs/heads/release/') }}

steps:
- name: Retrieve repository (on the develop branch)
uses: actions/checkout@v4
# Checks-out the develop branch
- uses: actions/checkout@v4
with:
ref: 'refs/heads/develop'

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'

- name: Set up Poetry
uses: abatilo/[email protected]
with:
poetry-version: 1.3.2

- name: Bump minor version
run: |
poetry version ${GITHUB_REF#refs/heads/release/}
poetry version preminor
echo "software_version=$(poetry version | awk '{print $2}')" >> $GITHUB_ENV
- name: Commit Version Bump
run: |
git config --global user.name 'batchee bot'
git config --global user.email '[email protected]'
git commit -am "/version ${{ env.software_version }}"
git push
# - uses: actions/setup-python@v4
# with:
# python-version: '3.10'
# - name: Install Poetry
# uses: abatilo/[email protected]
# with:
# poetry-version: 1.3.2
## - name: Bump minor version
## run: |
## poetry version ${GITHUB_REF#refs/heads/release/}
## poetry version preminor
## echo "software_version=$(poetry version | awk '{print $2}')" >> $GITHUB_ENV
## - name: Commit Version Bump
## run: |
## git config --global user.name 'batchee bot'
## git config --global user.email '[email protected]'
## git commit -am "/version ${{ env.software_version }}"
## git push
39 changes: 14 additions & 25 deletions .github/workflows/reusable_run_tests.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# This workflow will install Python dependencies, run tests,
# and report test results and code coverage as artifacts. It will
# be called by the workflow that run tests against new PRs and as
# a first step in the workflow that publishes new Docker images.
# and report test results and code coverage as artifacts. It will
# be called by the workflow that runs tests against new PRs and as
# a first step in the workflow that publishes new Docker images.

name: A reusable workflow to build and run the unit test suite

Expand All @@ -12,14 +12,18 @@ on:
jobs:
build_and_test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ '3.10' ]

name: Python ${{ matrix.python-version }} tests
steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
python-version: ${{ matrix.python-version }}

- name: Set up Poetry
uses: abatilo/[email protected]
Expand All @@ -29,39 +33,24 @@ jobs:
- name: Install package
run: poetry install

- name: Run linting
- name: Lint
run: |
poetry run ruff batcher
- name: Run tests with coverage
run: |
poetry run coverage run -m pytest >& test_results.txt
# poetry run pytest tests/test_filename_grouping.py >& test_results.txt
# TODO: expand tests to include full concatenation runs, i.e., don't just run test_group_handling.py
poetry run pytest --cov=batcher --cov-report=xml:build/reports/coverage.xml --cov-report=html:build/reports/coverage.html tests/
- name: Generate coverage report
if: ${{ always() }}
run: |
poetry run coverage report -m >& coverage_report.txt
poetry run coverage html --dir htmlcov
- name: Archive test results
if: ${{ always() }}
uses: actions/upload-artifact@v3
with:
name: test result
path: test_results.txt

- name: Archive code coverage report (plain text)
- name: Archive code coverage report (xml)
if: ${{ always() }}
uses: actions/upload-artifact@v3
with:
name: code coverage report (plain text)
path: coverage_report.txt
name: code coverage report (xml)
path: build/reports/coverage.xml

- name: Archive code coverage report (HTML)
if: ${{ always() }}
uses: actions/upload-artifact@v3
with:
name: code coverage report (HTML)
path: htmlcov/*
path: build/reports/coverage.html

0 comments on commit e2815d1

Please sign in to comment.