-
Notifications
You must be signed in to change notification settings - Fork 29
116 lines (96 loc) · 4.09 KB
/
docker-test-and-push.yaml
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
name: Docker
on:
push:
branches:
- master
tags:
- '*'
pull_request:
branches:
- master
release:
types: ['prereleased', 'released']
jobs:
docker-tests:
name: Docker
runs-on: ubuntu-22.04
strategy:
matrix:
# postgres-postgis version, see available tags https://hub.docker.com/r/postgis/postgis/tags
pgis:
# WARNING: if changing this, make sure tu update `pgis_stable` below
- 13-3.4
- 14-3.4
#- 15-3.3 # Postgis 3.3 requires QGEP datamodel adaptations
# See https://github.com/QGEP/QGEP/issues/825
fail-fast: false
env:
# which pgis version to use for :tag images and to generate the dumps attached to the release (must be in the matrix above)
pgis_stable: "14-3.4"
steps:
- uses: actions/checkout@v4
- name: "assert version is up to date"
run: |
LAST_VERSION=$(ls delta | sort -r | sed '/^delta_/!d' | head -n 1 | cut -d_ -f2)
CUR_VERSION=$(cat system/CURRENT_VERSION.txt)
[[ "${LAST_VERSION}" == "${CUR_VERSION}" ]] || (echo "Version mismatch ${LAST_VERSION} != ${CUR_VERSION}" && exit 1)
- name: "build dockerfile"
run: docker build -f .docker/Dockerfile --build-arg POSTGIS_VERSION=${{ matrix.pgis }} --tag opengisch/qgep_datamodel:${GITHUB_REF##*/}-${{ matrix.pgis }} .
- name: "initialize qgep container"
run: docker run -d -p 5432:5432 --name qgep opengisch/qgep_datamodel:${GITHUB_REF##*/}-${{ matrix.pgis }}
- name: "wait for qgep container"
run: docker exec qgep init_qgep.sh wait
timeout-minutes: 10
- name: "run tests on qgep_build (structure)"
run: |
docker start qgep
# Run tests that depend on data model. Tests that require demo data are ignored and run below in qgep_prod
docker exec -e PGSERVICE=qgep_build qgep pytest --ignore test/test_import.py --ignore test/test_swmm.py
- name: "run tests on qgep_prod (production)"
run: |
docker start qgep
docker exec -e PGSERVICE=qgep_prod qgep pytest
- name: "dockerhub login"
if: github.event_name != 'pull_request'
run: |
docker login --username "${{ secrets.DOCKERHUB_USERNAME }}" --password "${{ secrets.DOCKERHUB_PASSWORD }}"
- name: "push to dockerhub"
if: github.event_name != 'pull_request'
run: |
docker push opengisch/qgep_datamodel:${GITHUB_REF##*/}-${{ matrix.pgis }}
- name: "push to dockerhub (:tag)"
if: github.event_name != 'pull_request' && matrix.pgis == env.pgis_stable && github.ref != 'refs/heads/master'
run: |
docker tag opengisch/qgep_datamodel:${GITHUB_REF##*/}-${{ matrix.pgis }} opengisch/qgep_datamodel:${GITHUB_REF##*/}
docker push opengisch/qgep_datamodel:${GITHUB_REF##*/}
- name: "push to dockerhub (:latest)"
if: github.event_name != 'pull_request' && github.ref == 'refs/heads/master'
run: |
docker tag opengisch/qgep_datamodel:${GITHUB_REF##*/}-${{ matrix.pgis }} opengisch/qgep_datamodel:latest
docker push opengisch/qgep_datamodel:latest
- name: "create dumps"
if: github.event_name != 'pull_request' && matrix.pgis == env.pgis_stable
run: |
CI_TAG=${GITHUB_REF#refs/*/} .deploy/create-dumps.py
ls artifacts
env:
PGHOST: localhost
PGPASSWORD: postgres
PGUSER: postgres
- uses: svenstaro/upload-release-action@v2
if: github.event_name == 'release' && matrix.pgis == env.pgis_stable
with:
file: artifacts/*
file_glob: true
overwrite: true
- name: "failure logs"
if: failure()
run: |
docker logs qgep
# TMATE disabled for now as it hangs process, we should do this instead :
# https://github.com/marketplace/actions/debugging-with-tmate#manually-triggered-debug
# - name: Setup tmate session
# if: failure()
# uses: mxschmitt/action-tmate@v3
# with:
# limit-access-to-actor: true