Skip to content

Commit

Permalink
Merge pull request #39 from danielfromearth/develop
Browse files Browse the repository at this point in the history
update `main`
  • Loading branch information
danielfromearth authored Oct 31, 2023
2 parents 4695e1c + da13976 commit ddbc43c
Show file tree
Hide file tree
Showing 22 changed files with 743 additions and 514 deletions.
7 changes: 2 additions & 5 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,12 @@ updates:
- package-ecosystem: pip
directory: "/"
schedule:
interval: daily
interval: "weekly"
# Raise pull requests for version updates
# to pip against the `develop` branch
target-branch: "develop"
- package-ecosystem: "github-actions"
directory: "/"
schedule:
# Check for updates to GitHub Actions every weekday
interval: "daily"
# Raise pull requests for version updates
# to pip against the `develop` branch
interval: "weekly"
target-branch: "develop"
135 changes: 135 additions & 0 deletions .github/workflows/build-pipeline.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
# 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

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

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

jobs:
run_tests:
uses: ./.github/workflows/reusable_run_tests.yml

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

steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v4
with:
python-version: '3.10'

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

- 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
# - 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: |
# github.ref == 'refs/heads/develop' ||
# github.ref == 'refs/heads/main' ||
# startsWith(github.ref, 'refs/heads/release')
# run: |
# git config --global user.name 'batchee bot'
# git config --global user.email '[email protected]'
# git commit -am "/version ${{ env.software_version }}"
# git push
#
# - 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 }}"

# - 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
107 changes: 0 additions & 107 deletions .github/workflows/on_push.yml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
# When a pull request is opened, run linting and tests.
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/**
branches: [ feature/**, issue/**, issues/** ]

jobs:
build_and_test:
uses: ./.github/workflows/run_tests.yml
uses: ./.github/workflows/reusable_run_tests.yml
40 changes: 40 additions & 0 deletions .github/workflows/release-created.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# As soon as a release branch is pushed, the minor version on develop is bumped automatically.
# This allows further development to continue on develop for ‘the next’ release.
name: Release Branch Created

# Run whenever a ref is created https://docs.github.com/en/actions/reference/events-that-trigger-workflows#create
on:
create

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:
# Checks-out the develop branch
- uses: actions/checkout@v4
with:
ref: 'refs/heads/develop'
# - 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
56 changes: 56 additions & 0 deletions .github/workflows/reusable_run_tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# 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 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

on:
workflow_call:
workflow_dispatch:

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: ${{ matrix.python-version }}

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

- name: Install package
run: poetry install

- name: Lint
run: |
poetry run ruff batcher
- name: Run tests with coverage
run: |
poetry run pytest --cov=batcher --cov-report=xml:build/reports/coverage.xml --cov-report=html:build/reports/coverage.html tests/
- name: Archive code coverage report (xml)
if: ${{ always() }}
uses: actions/upload-artifact@v3
with:
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: build/reports/coverage.html
Loading

0 comments on commit ddbc43c

Please sign in to comment.