Update PostGIS base Docker image for Azure mock database: 12-3.1 ->…
#131
Workflow file for this run
This file contains hidden or 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: Docker Build & Push & Test | |
| on: | |
| push: | |
| pull_request: | |
| branches: [main] | |
| jobs: | |
| push_to_registry: | |
| name: Build & Push docker image to dockerhub | |
| runs-on: ubuntu-24.04 | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Get metadata as environment variables | |
| uses: HSLdevcom/jore4-tools/github-actions/extract-metadata@extract-metadata-v1 | |
| - name: Pull previous images to support caching | |
| run: | | |
| docker pull $IMAGE_NAME:latest || echo "Previous image not found" | |
| docker pull $IMAGE_NAME:mapmatching || echo "Previous image not found" | |
| docker pull $IMAGE_NAME:azuredbmock || echo "Previous image not found" | |
| - name: Build docker images | |
| run: | | |
| docker build \ | |
| --cache-from=$IMAGE_NAME:latest \ | |
| --cache-from=$IMAGE_NAME:mapmatching \ | |
| -t $IMAGE_NAME:mapmatching \ | |
| -t $IMAGE_NAME:latest \ | |
| -t $IMAGE_NAME:mapmatching-$COMMIT_ID ./mapmatching | |
| docker build \ | |
| --cache-from=$IMAGE_NAME:latest \ | |
| --cache-from=$IMAGE_NAME:azuredbmock \ | |
| -t $IMAGE_NAME:azuredbmock \ | |
| -t $IMAGE_NAME:latest \ | |
| -t $IMAGE_NAME:azuredbmock-$COMMIT_ID ./azuredbmock | |
| - name: Login to Docker Hub | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ secrets.JORE4_DOCKERHUB_USER }} | |
| password: ${{ secrets.JORE4_DOCKERHUB_TOKEN }} | |
| - name: Push images tagged with git commit details to Docker Hub | |
| run: | | |
| docker push $IMAGE_NAME:mapmatching-$COMMIT_ID | |
| docker push $IMAGE_NAME:azuredbmock-$COMMIT_ID | |
| - name: Push rest of the tags to Docker Hub | |
| if: ${{ github.ref == 'refs/heads/main' }} | |
| run: | | |
| docker push $IMAGE_NAME:azuredbmock | |
| docker push $IMAGE_NAME:mapmatching | |
| docker push $IMAGE_NAME:latest | |
| test-docker-images: | |
| name: verify that the docker images work | |
| needs: push_to_registry | |
| runs-on: ubuntu-24.04 | |
| env: | |
| POSTGRES_DB: testdb | |
| POSTGRES_USER: user | |
| POSTGRES_PASSWORD: password | |
| PGPASSWORD: password | |
| DIGIROAD_ROUTING_DUMP_VERSION: "2021-11-04" | |
| strategy: | |
| matrix: | |
| include: | |
| # mapmatching image | |
| - dockerImage: mapmatching | |
| envMapping: | |
| '-e POSTGRES_DB="$POSTGRES_DB" -e POSTGRES_USER="$POSTGRES_USER" | |
| -e POSTGRES_PASSWORD="$POSTGRES_PASSWORD" -e | |
| DIGIROAD_ROUTING_DUMP_VERSION="$DIGIROAD_ROUTING_DUMP_VERSION"' | |
| # 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: azuredbmock | |
| 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-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" | |
| dbQuery: | |
| # finds all users in the database | |
| "SELECT usename FROM pg_catalog.pg_user ORDER BY usename;" | |
| expectedOutput: | | |
| usename | |
| ----------------------- | |
| authusername | |
| hasurausername | |
| importerusername | |
| tiamat | |
| timetablesapiusername | |
| user | |
| (6 rows) | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Get metadata as environment variables | |
| uses: HSLdevcom/jore4-tools/github-actions/extract-metadata@extract-metadata-v1 | |
| - name: Start up postgresql docker container | |
| run: | | |
| docker run -d --rm -p 6432:5432 --name postgres ${{ matrix.envMapping }} ${{ matrix.secretMapping }} $IMAGE_NAME:${{ matrix.dockerImage }}-$COMMIT_ID | |
| - name: Verify that postgres database is up and can be connected to | |
| 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) | |
| 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 | |
| run_e2e_tests: | |
| needs: push_to_registry | |
| name: Run E2E tests | |
| # These must run on ubuntu 22.04 or older. | |
| # The MS SQL server used by jore4-jore3-importer, | |
| # does not run on Linux kernels newer than 6.6.x. | |
| runs-on: ubuntu-22.04 | |
| steps: | |
| - name: Extract metadata to env variables | |
| uses: HSLdevcom/jore4-tools/github-actions/extract-metadata@extract-metadata-v1 | |
| - name: Run e2e tests | |
| uses: HSLdevcom/jore4-tools/github-actions/run-ci@main | |
| with: | |
| testdb_version: "${{ env.IMAGE_NAME }}:azuredbmock-${{ env.COMMIT_ID }}" |