Repository navigation
195 lines (178 loc) · 7.88 KB
/
Copy pathcd.yml
File metadata and controls
195 lines (178 loc) · 7.88 KB
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
name: CD
on:
push:
branches:
- main
- releases/**
pull_request:
permissions:
contents: read
jobs:
publish_mapmatching_docker_image_to_acr:
name: Publish Map Matching Docker image to ACR
permissions:
id-token: write
contents: read
uses: HSLdevcom/jore4-tools/.github/workflows/shared-build-and-publish-docker-image.yml@shared-build-and-publish-docker-image-v6
with:
docker_image_name: jore4-postgres-mapmatching
build_arm64_image: true
context: ${{ github.server_url }}/${{ github.repository }}.git#${{ github.ref }}:./mapmatching
secrets:
azure_client_id: ${{ secrets.AZURE_CLIENT_ID }}
azure_tenant_id: ${{ secrets.AZURE_TENANT_ID }}
azure_subscription_id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
publish_azuredbmock_docker_image_to_acr:
name: Publish Azure DB Mock Docker image to ACR
permissions:
id-token: write
contents: read
uses: HSLdevcom/jore4-tools/.github/workflows/shared-build-and-publish-docker-image.yml@shared-build-and-publish-docker-image-v6
with:
docker_image_name: jore4-postgres-azuredbmock
build_arm64_image: true
context: ${{ github.server_url }}/${{ github.repository }}.git#${{ github.ref }}:./azuredbmock
secrets:
azure_client_id: ${{ secrets.AZURE_CLIENT_ID }}
azure_tenant_id: ${{ secrets.AZURE_TENANT_ID }}
azure_subscription_id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
test-docker-images:
name: verify that the docker images work
needs:
- publish_mapmatching_docker_image_to_acr
- publish_azuredbmock_docker_image_to_acr
runs-on: ubuntu-24.04
env:
POSTGRES_DB: testdb
POSTGRES_USER: user
POSTGRES_PASSWORD: password
PGPASSWORD: password
DIGIROAD_ROUTING_DUMP_URL: "https://stjore4dev001.blob.core.windows.net/jore4-digiroad/2026-08-04_create_routing_schema_digiroad_r_2026-01_mml_2026-08-04.sql"
strategy:
matrix:
include:
# mapmatching image
- dockerImage: "${{ needs.publish_mapmatching_docker_image_to_acr.outputs.docker_image }}"
envMapping:
'-e POSTGRES_DB="$POSTGRES_DB" -e POSTGRES_USER="$POSTGRES_USER"
-e POSTGRES_PASSWORD="$POSTGRES_PASSWORD" -e
DIGIROAD_ROUTING_DUMP_URL="$DIGIROAD_ROUTING_DUMP_URL"'
# no secrets are needed here
secretMapping: ""
dbQuery:
# verifies that we have all the tables in routing schema
"SELECT table_name FROM information_schema.tables WHERE
table_schema = 'routing' ORDER BY table_name;"
expectedOutput: |
table_name
------------------------------------------------------
infrastructure_link
infrastructure_link_safely_traversed_by_vehicle_type
infrastructure_link_vertices_pgr
infrastructure_source
public_transport_stop
traffic_flow_direction
vehicle_mode
vehicle_type
(8 rows)
# azuredbmock image
- dockerImage: "${{ needs.publish_azuredbmock_docker_image_to_acr.outputs.docker_image }}"
envMapping:
'-e POSTGRES_DB="$POSTGRES_DB" -e POSTGRES_USER="$POSTGRES_USER"
-e POSTGRES_PASSWORD="$POSTGRES_PASSWORD" -e
SECRET_STORE_BASE_PATH="/run/secrets"'
# secrets are bound as volumes because `docker run` does not support secrets
secretMapping: "-v
$(pwd)/test-secrets/db-auth-username:/run/secrets/db-auth-username:ro
-v
$(pwd)/test-secrets/db-auth-password:/run/secrets/db-auth-password:ro
-v $(pwd)/test-secrets/db-auth-name:/run/secrets/db-auth-name:ro
-v
$(pwd)/test-secrets/db-jore3importer-username:/run/secrets/db-jore3importer-username:ro
-v
$(pwd)/test-secrets/db-jore3importer-password:/run/secrets/db-jore3importer-password:ro
-v
$(pwd)/test-secrets/db-jore3importer-name:/run/secrets/db-jore3importer-name:ro
-v
$(pwd)/test-secrets/db-jore4-main-name:/run/secrets/db-jore4-main-name:ro
-v
$(pwd)/test-secrets/db-hasura-username:/run/secrets/db-hasura-username:ro
-v
$(pwd)/test-secrets/db-hasura-password:/run/secrets/db-hasura-password:ro
-v
$(pwd)/test-secrets/db-hasura-name:/run/secrets/db-hasura-name:ro
-v
$(pwd)/test-secrets/db-timetables-name:/run/secrets/db-timetables-name:ro
-v
$(pwd)/test-secrets/db-tiamat-name:/run/secrets/db-tiamat-name:ro
-v
$(pwd)/test-secrets/db-tiamat-username:/run/secrets/db-tiamat-username:ro
-v
$(pwd)/test-secrets/db-tiamat-password:/run/secrets/db-tiamat-password:ro
-v
$(pwd)/test-secrets/db-timetables-api-username:/run/secrets/db-timetables-api-username:ro
-v
$(pwd)/test-secrets/db-timetables-api-password:/run/secrets/db-timetables-api-password:ro
-v
$(pwd)/test-secrets/db-dss-username:/run/secrets/db-dss-username:ro
-v
$(pwd)/test-secrets/db-dss-password:/run/secrets/db-dss-password:ro"
dbQuery:
# finds all users in the database
"SELECT usename FROM pg_catalog.pg_user ORDER BY usename;"
expectedOutput: |
usename
-----------------------
authusername
dss
hasurausername
importerusername
tiamat
timetablesapiusername
user
(7 rows)
steps:
- name: Checkout code
uses: actions/checkout@v7
- name: Start up postgresql docker container
run: |
docker run -d --rm -p 6432:5432 --name postgres ${{ matrix.envMapping }} ${{ matrix.secretMapping }} ${{ matrix.dockerImage }}
- name: Verify that postgres database is up and can be connected to
id: healthcheck
continue-on-error: true
uses: HSLdevcom/jore4-tools/github-actions/healthcheck@healthcheck-v1
with:
command:
'psql -h localhost -p 6432 -U "$POSTGRES_USER" -d "$POSTGRES_DB" -c
"SELECT ''OK'';"'
- name: Verify that the proper sql dumps got imported (diff expected results)
id: verify_sql_dump
continue-on-error: true
run: |
psql -h localhost -p 6432 -U "$POSTGRES_USER" -d "$POSTGRES_DB" -c "${{ matrix.dbQuery }}" > dbresults.txt
echo "${{ matrix.expectedOutput }}" > expectedresults.txt
diff --ignore-all-space --ignore-blank-lines dbresults.txt expectedresults.txt
- name: Dump container diagnostics on failure
if: always() && (steps.healthcheck.outcome == 'failure' || steps.verify_sql_dump.outcome == 'failure')
run: |
echo "::group::docker ps"
docker ps -a
echo "::endgroup::"
echo "::group::container inspect"
docker inspect postgres || true
echo "::endgroup::"
echo "::group::container logs"
docker logs postgres || true
echo "::endgroup::"
- name: Fail job if container validation failed
if: always() && (steps.healthcheck.outcome == 'failure' || steps.verify_sql_dump.outcome == 'failure')
run: exit 1
run_e2e_tests:
name: Run E2E tests
needs:
- publish_mapmatching_docker_image_to_acr
- publish_azuredbmock_docker_image_to_acr
uses: HSLdevcom/jore4-tools/.github/workflows/shared-run-e2e.yml@main
with:
mapmatchingdb_version: "${{ needs.publish_mapmatching_docker_image_to_acr.outputs.docker_image }}"
testdb_version: "${{ needs.publish_azuredbmock_docker_image_to_acr.outputs.docker_image }}"