-
-
Notifications
You must be signed in to change notification settings - Fork 1
130 lines (107 loc) · 4.61 KB
/
conformance.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
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
permissions:
contents: write
pull-requests: write # to write comment
steps:
- uses: actions/checkout@v4
- name: Create env
run: cp .env.example .env
- name: Load .env file
uses: xom9ikk/dotenv@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to DockerHub
uses: docker/login-action@v3
if: github.repository == 'opengisch/django-ogcapif'
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build Django image
uses: docker/build-push-action@v5
with:
context: .
provenance: false
file: docker/django/Dockerfile
push: ${{ github.repository == 'opengisch/django-ogcapif' }}
pull: true
cache-from: type=registry,ref=opengisch/django-oapif:latest
cache-to: type=registry,ref=opengisch/django-oapif:latest,mode=max
tags: opengisch/django-oapif:latest
- name: Do quickstart
run: |
# copy default conf
cp .env.example .env
# start the stack
docker compose --profile testing_conformance up --build -d
# deploy static files and migrate database
docker compose exec django python manage.py migrate --no-input
docker compose exec django python manage.py populate_users
docker compose exec django python manage.py populate_data
- name: Healthcheck
run: wget http://${OGCAPIF_HOST}:${DJANGO_DEV_PORT}/oapif/collections/tests.point_2056_10fields/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: Install requirements
run: pip install lxml
- name: Check baseline
id: baseline
run: |
EXIT_CODE=0
python tests/conformance/parse_report.py test_outputs/emailable-report.html tests/conformance/conformance-baseline.json || EXIT_CODE=$?
echo "EXIT_CODE=${EXIT_CODE}" >> $GITHUB_OUTPUT
- name: Commit baseline if improved >> checkout
uses: actions/checkout@v4
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 tests/conformance/conformance-baseline.json baseline_repo/tests/conformance/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: tests/conformance/conformance-baseline.json
cwd: ./baseline_repo
message: update conformance 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 conformance 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: |
python tests/conformance/parse_report.py test_outputs/emailable-report.html tests/conformance/conformance-baseline.json
- name: Failure logs
if: failure()
run: docker-compose logs