refactor with tests app #313
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Conformance | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
jobs: | |
conformance: | |
runs-on: ubuntu-latest | |
env: | |
DOCKER_BUILDKIT: 1 | |
COMPOSE_DOCKER_CLI_BUILD: 1 | |
OGCAPIF_HOST: localhost | |
permissions: | |
contents: write | |
pull-requests: write # to write comment | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Login to DockerHub | |
uses: docker/login-action@v2 | |
if: github.repository == 'opengisch/django-ogcapif' | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Build Django image | |
uses: docker/build-push-action@v4 | |
with: | |
context: . | |
provenance: false | |
file: docker/django/Dockerfile | |
push: ${{ github.repository == 'opengisch/django-ogcapif' }} | |
pull: true | |
cache-from: type=registry,ref=opengisch/signalo-django:latest | |
cache-to: type=registry,ref=opengisch/signalo-django:latest,mode=max | |
tags: opengisch/signalo-django:latest | |
- name: Do quickstart | |
run: | | |
# copy default conf | |
cp .env.example .env | |
# start the stack | |
docker compose up --build -d | |
# deploy static files and migrate database | |
docker compose exec django python manage.py collectstatic --no-input | |
docker compose exec django python manage.py migrate --no-input | |
docker compose exec django python manage.py populate_vl | |
docker compose exec django python manage.py populate_signs_poles | |
- name: Healthcheck | |
run: wget --no-check-certificate https://localhost/oapif/collections/signalo_core.pole/items | |
- name: Run conformance test suite | |
run: docker compose run conformance_test | |
- name: Archive production artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
name: emailable-report | |
path: | | |
./_test_outputs/**/emailable-report.html | |
- name: Check baseline | |
id: baseline | |
run: | | |
pip install lxml | |
EXIT_CODE=0 | |
python scripts/parse_report.py _test_outputs/emailable-report.html conformance-baseline.json || EXIT_CODE=$? | |
echo "EXIT_CODE=${EXIT_CODE}" >> $GITHUB_OUTPUT | |
- name: Commit baseline if improved | checkout | |
uses: actions/checkout@v3 | |
if: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository && steps.baseline.outputs.EXIT_CODE == '1' }} | |
with: | |
repository: ${{ github.event.pull_request.head.repo.full_name }} | |
ref: ${{ github.event.pull_request.head.ref }} | |
path: ./baseline_repo | |
- name: Commit baseline if improved | copy baseline file | |
if: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository && steps.baseline.outputs.EXIT_CODE == '1' }} | |
run: cp conformance-baseline.json baseline_repo/conformance-baseline.json | |
- name: Commit baseline if improved | commit | |
if: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository && steps.baseline.outputs.EXIT_CODE == '1' }} | |
uses: EndBug/add-and-commit@v9 | |
with: | |
add: conformance-baseline.json | |
cwd: ./baseline_repo | |
message: update baseline | |
- name: 💬 Prepare comment | |
id: prepare_comment | |
if: ${{ github.event_name == 'pull_request' && steps.baseline.outputs.EXIT_CODE != '0' }} | |
run : | | |
if [[ ${{ steps.baseline.outputs.EXIT_CODE }} == 1 ]]; then | |
echo "comment=Conformance tests got better! (update baseline if the job fails)" >> $GITHUB_OUTPUT | |
else | |
echo "comment=Oh no! Conformance tests got worse!" >> $GITHUB_OUTPUT | |
fi | |
- name: 💬 Create comment | |
uses: marocchino/sticky-pull-request-comment@v2 | |
if: ${{ github.event_name == 'pull_request' && steps.baseline.outputs.EXIT_CODE != '0' }} | |
with: | |
message: ${{ steps.prepare_comment.outputs.comment }} | |
- name: Recheck baseline | |
run: | | |
pip install lxml | |
python scripts/parse_report.py _test_outputs/emailable-report.html conformance-baseline.json | |
- name: Failure logs | |
if: failure() | |
run: docker-compose logs |