Skip to content

Merge pull request #155 from AutomatedProcessImprovement/conditions #134

Merge pull request #155 from AutomatedProcessImprovement/conditions

Merge pull request #155 from AutomatedProcessImprovement/conditions #134

Workflow file for this run

name: Build, Test, Release
on:
workflow_dispatch:
push:
branches: [ master ]
paths:
- 'src/simod/**'
- 'tests/**'
- '.github/workflows/**'
- 'Dockerfile'
- 'pyproject.toml'
pull_request:
branches: [ master ]
paths:
- 'src/simod/**'
- 'tests/**'
- '.github/workflows/**'
- 'Dockerfile'
env:
DOCKERHUB_USERNAME: nokal
DOCKERHUB_REPO: nokal/simod
jobs:
test:
runs-on: ubuntu-latest
timeout-minutes: 120
strategy:
matrix:
python-version: [ '3.9' ]
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- uses: actions/setup-java@v3
with:
distribution: 'corretto'
java-version: '8'
- name: Install
shell: bash
run: |
pip install poetry
poetry install
- name: Test
shell: bash
run: poetry run pytest --cov=. --cov-report=xml --durations=0 -v -x -k "not test_build_fuzzy_calendars and not test_bpic15 and not test_missing_activities_repaired" -m "not benchmark"
- name: PyLint
shell: bash
run: poetry run pylint -j 0 --exit-zero src/simod > pylint.txt
- name: Upload PyLint output
uses: actions/upload-artifact@v3
with:
name: pylint.txt
path: ./pylint.txt
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v2
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage.xml
env_vars: OS,PYTHON
fail_ci_if_error: false
name: codecov-umbrella
verbose: true
build-and-publish-images:
runs-on: ubuntu-latest
needs: [ test ]
timeout-minutes: 120
if: github.ref == 'refs/heads/master'
outputs:
version: ${{ steps.versioning.outputs.version }}
docker_image: ${{ env.DOCKERHUB_REPO }}:${{ steps.versioning.outputs.version }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ env.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Get the version
id: versioning
run: |
pip install poetry
echo "version=$(poetry version --short)" >> "$GITHUB_OUTPUT"
- name: Build and push to DockerHub
uses: docker/build-push-action@v2
with:
push: true
tags: ${{ env.DOCKERHUB_REPO }}:latest,${{ env.DOCKERHUB_REPO }}:${{ steps.versioning.outputs.version }}
file: Dockerfile
context: .
platforms: linux/amd64,linux/arm64
release-pypi:
needs: [ test ]
runs-on: ubuntu-latest
outputs:
version: ${{ steps.versioning.outputs.version }}
if: github.ref == 'refs/heads/master'
environment:
name: PyPI
url: https://pypi.org/p/simod
permissions:
id-token: write
contents: write
packages: write
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Install poetry
run: pip install poetry
- name: Build
run: poetry install && poetry build
- name: Generate licenses.md
run: |
poetry run pip install pip-licenses
poetry run pip-licenses --with-system --with-urls --format=markdown --output-file=licenses.md
- name: Upload licenses.md
uses: actions/upload-artifact@v3
with:
name: licenses.md
path: licenses.md
- name: Generate changelog
run: |
echo "# Changelog" > CHANGELOG.md
echo "" >> CHANGELOG.md
echo "\`\`\`" >> CHANGELOG.md
git log --pretty=format:"%h - %s (%an)" $(git describe --tags --abbrev=0)..HEAD >> CHANGELOG.md
echo "" >> CHANGELOG.md
echo "\`\`\`" >> CHANGELOG.md
- name: Get the version
id: versioning
run: echo "version=$(poetry version --short)" >> "$GITHUB_OUTPUT"
- name: Assign a version tag if not present
run: |
if ! git rev-parse ${{ steps.versioning.outputs.version }}; then
git tag ${{ steps.versioning.outputs.version }}
git push --tags
fi
- name: Create a release if needed
uses: softprops/action-gh-release@v1
with:
files: |
dist/*
tag_name: ${{ steps.versioning.outputs.version }}
body_path: CHANGELOG.md
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1