Skip to content

Merge pull request #15 from open-formulieren/feature/deal-with-black-… #47

Merge pull request #15 from open-formulieren/feature/deal-with-black-…

Merge pull request #15 from open-formulieren/feature/deal-with-black-… #47

Workflow file for this run

name: Run CI
# Run this workflow every time a new commit pushed to your repository
on:
push:
branches:
- main
tags:
- '*'
pull_request:
workflow_dispatch:
env:
IMAGE_NAME: openformulieren/open-forms-ext-token-exchange
jobs:
tests:
name: Run the Django test suite
runs-on: ubuntu-latest
services:
postgres:
image: postgres:14
env:
POSTGRES_HOST_AUTH_METHOD: trust
ports:
- 5432:5432
# Needed because the postgres container does not provide a healthcheck
options:
--health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
--name postgres
redis:
image: redis:6
ports:
- 6379:6379
steps:
- name: Checkout Open Forms
uses: actions/checkout@v3
with:
repository: open-formulieren/open-forms
path: open-forms
- name: Checkout Token Exchange extension
uses: actions/checkout@v3
with:
path: extension
- name: Set up backend environment
uses: maykinmedia/[email protected]
with:
apt-packages: 'libxml2-dev libxmlsec1-dev libxmlsec1-openssl gettext postgresql-client gdal-bin'
python-version: '3.10'
optimize-postgres: 'yes'
pg-service: 'postgres'
setup-node: 'yes'
nvmrc-custom-dir: 'open-forms'
npm-ci-flags: '--legacy-peer-deps'
working-directory: ${{ github.workspace }}/open-forms
- name: Make symlink in OF to the extension
run: |
ln -s ${{ github.workspace }}/extension/token_exchange ${{ github.workspace }}/open-forms/src
- name: Run tests
run: |
export OPEN_FORMS_EXTENSIONS=token_exchange
python src/manage.py compilemessages
coverage run --source=token_exchange src/manage.py test token_exchange
coverage combine
coverage xml -o coverage-extension.xml
env:
DJANGO_SETTINGS_MODULE: openforms.conf.ci
SECRET_KEY: dummy
DB_USER: postgres
DB_PASSWORD: ''
working-directory: ${{ github.workspace }}/open-forms
- name: Publish coverage report
uses: codecov/[email protected]
with:
root_dir: ${{ github.workspace }}/extension
working-directory: ${{ github.workspace }}/open-forms
files: ./coverage-extension.xml
docker_build:
name: Build Docker image
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set tag
id: vars
run: |
# Strip git ref prefix from version
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
# Strip "v" prefix from tag name (if present at all)
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
# Use Docker `latest` tag convention
[ "$VERSION" == "main" ] && VERSION=latest
# PRs result in version 'merge' -> transform that into 'latest'
[ "$VERSION" == "merge" ] && VERSION=latest
echo ::set-output name=tag::${VERSION}
- name: Build the Docker image
run: |
docker build . \
--tag $IMAGE_NAME:$RELEASE_VERSION
env:
RELEASE_VERSION: ${{ steps.vars.outputs.tag }}
- run: docker image save -o image.tar $IMAGE_NAME:${{ steps.vars.outputs.tag }}
- name: Store image artifact
uses: actions/upload-artifact@v3
with:
name: docker-image
path: image.tar
retention-days: 1
publish:
name: Publish package to PyPI
runs-on: ubuntu-latest
needs:
- tests
- docker_build
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Build sdist and wheel
run: |
pip install pip setuptools wheel --upgrade
python setup.py sdist bdist_wheel
- name: Publish a Python distribution to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_TOKEN }}