Update actions/checkout action to v6 #225
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: CD | |
| on: | |
| push: | |
| branches: | |
| - main | |
| - "releases/**" | |
| pull_request: | |
| 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-v1 | |
| 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-v1 | |
| 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://jore4storage.blob.core.windows.net/jore4-digiroad/digiroad_r_routing_2022-10-06.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" | |
| 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@v5 | |
| - 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 | |
| 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: | |
| 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 }}" |