Skip to content

Merge pull request #141 from AutomatedProcessImprovement/140_add_simp… #82

Merge pull request #141 from AutomatedProcessImprovement/140_add_simp…

Merge pull request #141 from AutomatedProcessImprovement/140_add_simp… #82

Workflow file for this run

name: Build, Test, Release
on:
workflow_dispatch:
push:
branches: [ master ]
paths:
- 'src/simod/**'
- 'tests/**'
- '.github/workflows/**'
- 'Dockerfile'
pull_request:
branches: [ master ]
paths:
- 'src/simod/**'
- 'tests/**'
- '.github/workflows/**'
- 'Dockerfile'
env:
DOCKERHUB_USERNAME: nokal
DOCKERHUB_REPO: nokal/simod
jobs:
build:
runs-on: ubuntu-latest
timeout-minutes: 80
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
test:
needs: [ build ]
runs-on: ubuntu-latest
container:
image: ${{ needs.build.outputs.docker_image }}
env:
BRANCH_NAME: master
steps:
- name: Testing
shell: bash
run: |
Xvfb :99 &>/dev/null & disown
cd /usr/src/Simod
poetry install
poetry run pytest --cov=. --cov-report=xml --durations=0 -v -x -k "not test_build_fuzzy_calendars" -m "not benchmark"
- name: PyLint
shell: bash
run: |
cd /usr/src/Simod
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: /usr/src/Simod/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
release:
needs: [ test ]
runs-on: ubuntu-latest
outputs:
version: ${{ steps.versioning.outputs.version }}
if: github.ref == 'refs/heads/master'
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Install poetry
run: pip install poetry
- 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
run: |
git tag ${{ steps.versioning.outputs.version }}
git push --tags
- name: Create a release
uses: softprops/action-gh-release@v1
with:
files: |
dist/*
tag_name: ${{ steps.versioning.outputs.version }}
body_path: CHANGELOG.md