Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
174 changes: 23 additions & 151 deletions .github/workflows/build-pipeline.yml
Original file line number Diff line number Diff line change
@@ -1,192 +1,64 @@
# 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: Lint and Test
# This is the main build pipeline that verifies and publishes the software
name: Build Harmony filtering image
Comment thread
ank1m marked this conversation as resolved.
Outdated

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

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
tags:
- '[0-9]+.[0-9]+.[0-9]+'
- '[0-9]+.[0-9]+.[0-9]+rc[0-9]+'
Comment thread
ank1m marked this conversation as resolved.

env:
POETRY_VERSION: "2.1.3"
PYTHON_VERSION: "3.12"
REGISTRY: ghcr.io
Comment thread
ank1m marked this conversation as resolved.
IMAGE_NAME: ${{ github.repository }}

jobs:
run_tests:
uses: ./.github/workflows/run_tests.yml
secrets:
codecov_token: ${{ secrets.CODECOV_TOKEN }}

build:
needs: run_tests
runs-on: ubuntu-latest

steps:
Comment thread
ank1m marked this conversation as resolved.
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- name: Retrieve repository
uses: actions/checkout@v6
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install Poetry
uses: abatilo/actions-poetry@v4.0.0
with:
poetry-version: ${{ env.POETRY_VERSION }}
- name: Get version
id: get-version
run: |
echo "current_version=$(poetry version | awk '{print $2}')" >> $GITHUB_OUTPUT
echo "pyproject_name=$(poetry version | awk '{print $1}')" >> $GITHUB_ENV

# Bumps the version, based on which branch is the target.
- 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
fetch-depth: 0

- name: Run Snyk as a blocking step
uses: snyk/actions/python-3.11@master
env:
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
- name: Set up uv
uses: astral-sh/setup-uv@v7
with:
command: test
args: >
--org=${{ secrets.SNYK_ORG_ID }}
--project-name=${{ github.repository }}
--severity-threshold=high
--fail-on=all
- name: Run Snyk on Python
uses: snyk/actions/python-3.11@master
env:
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
with:
command: monitor
args: >
--org=${{ secrets.SNYK_ORG_ID }}
--project-name=${{ github.repository }}
python-version: ${{ env.PYTHON_VERSION }}

- name: Commit Version Bump
# If building the `develop`, a `release` branch, or `main`,
# then we commit the version bump back to the repo.
if: |
github.ref == 'refs/heads/develop' ||
github.ref == 'refs/heads/main' ||
startsWith(github.ref, 'refs/heads/release')
- name: Determine version
id: version
run: |
git config --global user.name 'batchee bot'
git config --global user.email 'batchee@noreply.github.com'
git commit -am "/version ${{ env.software_version }}" --no-verify
git push --no-verify
SERVICE_VERSION="$(uv tool run hatch version)"
echo "service_version=$SERVICE_VERSION" >> "$GITHUB_OUTPUT"

# Builds and pushes the package to the Python Package Index (PyPI)
- name: Build Python Artifact
run: |
poetry build
- uses: actions/upload-artifact@v6
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.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.PYPI_TOKEN_PYPI}}
run: |
poetry publish

# Builds and pushes a Docker image
- name: Log in to the Container registry
if: ${{ !startsWith(github.ref, 'refs/heads/main/') }}
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
if: ${{ !startsWith(github.ref, 'refs/heads/main/') }}
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=raw,pattern={{version}},value=${{ env.software_version }}
type=raw,value=${{ env.venue }}
type=raw,value=${{ steps.version.outputs.service_version }}
type=raw,value=uat,enable=${{ startsWith(github.ref, 'refs/tags/') && contains(github.ref_name, 'rc') }}
type=raw,value=ops,enable=${{ startsWith(github.ref, 'refs/tags/') && !contains(github.ref_name, 'rc') }}
type=raw,value=latest,enable=${{ startsWith(github.ref, 'refs/tags/') && !contains(github.ref_name, 'rc') }}
Comment thread
ank1m marked this conversation as resolved.

- name: Build and push Docker image
if: ${{ !startsWith(github.ref, 'refs/heads/main/') }}
id: docker-push
uses: docker/build-push-action@v6
with:
context: .
file: Dockerfile
build-args: |
SOURCE=${{env.pyproject_name}}[harmony]==${{ env.software_version }}
push: true
SERVICE_VERSION=${{ steps.version.outputs.service_version }}
push: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') }}
pull: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
Comment thread
ank1m marked this conversation as resolved.

- name: Push Tag
if: |
github.ref == 'refs/heads/develop' ||
github.ref == 'refs/heads/main' ||
startsWith(github.ref, 'refs/heads/release')
run: |
git config user.name "${GITHUB_ACTOR}"
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 }}"
18 changes: 0 additions & 18 deletions .github/workflows/pull_request.yml

This file was deleted.

42 changes: 0 additions & 42 deletions .github/workflows/release-created.yml

This file was deleted.

25 changes: 8 additions & 17 deletions .github/workflows/run_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,10 @@
name: A reusable workflow to build and run the unit test suite
Comment thread
ank1m marked this conversation as resolved.
Outdated

on:
workflow_call:
secrets:
codecov_token:
required: true
Comment thread
danielfromearth marked this conversation as resolved.
push:
Comment thread
danielfromearth marked this conversation as resolved.
Comment thread
ank1m marked this conversation as resolved.
workflow_dispatch:
Comment thread
ank1m marked this conversation as resolved.

env:
POETRY_VERSION: "2.1.3"
PYTHON_VERSION: "3.12"

jobs:
Expand All @@ -24,26 +20,21 @@ jobs:
- name: Retrieve repository
uses: actions/checkout@v6

- name: Set up Python
uses: actions/setup-python@v6
- name: Set up uv
uses: astral-sh/setup-uv@v7
with:
python-version: ${{ env.PYTHON_VERSION }}

- name: Set up Poetry
uses: abatilo/actions-poetry@v4.0.0
with:
poetry-version: ${{ env.POETRY_VERSION }}

- name: Install package
run: poetry install --extras dev
- name: Install dependencies
run: uv sync --extra dev --frozen

- name: Lint
- name: Run Linting
Comment thread
danielfromearth marked this conversation as resolved.
run: |
poetry run ruff check batchee
uv run ruff check batchee

- name: Run tests with coverage
run: |
poetry run pytest --cov=batchee --cov-report=xml:build/reports/coverage.xml --cov-report=html:build/reports/coverage.html tests/
uv run pytest --cov=batchee --cov-report=xml:build/reports/coverage.xml --cov-report=html:build/reports/coverage.html tests/
Comment thread
ank1m marked this conversation as resolved.
Outdated

- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v5
Expand Down
46 changes: 0 additions & 46 deletions .github/workflows/wait-for-pypi.py

This file was deleted.

Loading
Loading