Skip to content

Update all dependencies #53

Update all dependencies

Update all dependencies #53

Workflow file for this run

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-22.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:empty || echo "Previous image not found"
docker pull $IMAGE_NAME:schema-only || echo "Previous image not found"
- name: Build docker images
run: |
# build docker image containing the MSSQL service only, no data
docker build \
--cache-from=$IMAGE_NAME:latest \
--cache-from=$IMAGE_NAME:empty \
-t $IMAGE_NAME:empty \
-t $IMAGE_NAME:latest \
-t $IMAGE_NAME:empty-$COMMIT_ID \
--target empty .
# build docker image containing the jore3 test schema, no data
docker build \
--cache-from=$IMAGE_NAME:latest \
--cache-from=$IMAGE_NAME:schema-only \
-t $IMAGE_NAME:schema-only \
-t $IMAGE_NAME:schema-only-$COMMIT_ID \
--target schema-only .
- 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:empty-$COMMIT_ID
docker push $IMAGE_NAME:schema-only-$COMMIT_ID
- name: Push rest of the tags to Docker Hub
if: ${{ github.ref == 'refs/heads/main' }}
run: |
docker push $IMAGE_NAME:empty
docker push $IMAGE_NAME:schema-only
docker push $IMAGE_NAME:latest
test-docker-images:
name: verify that the docker images work
needs: push_to_registry
runs-on: ubuntu-22.04
env:
SA_PASSWORD: "P@ssw0rd"
strategy:
matrix:
include:
# empty image, no test dumps are imported
- dockerImage: empty
volumeMapping: ""
expectedOutput: |
name
--------------------------------------------------------------------------------------------------------------------------------
master
model
msdb
tempdb
(4 rows affected)
# schema-only image, no test dumps are imported
- dockerImage: schema-only
volumeMapping: ""
expectedOutput: |
name
--------------------------------------------------------------------------------------------------------------------------------
jore3testdb
master
model
msdb
tempdb
(5 rows affected)
# empty image, but test dumps are imported
- dockerImage: empty
volumeMapping: ' -v "$(pwd)/docker-image-test-data:/data:ro"'
expectedOutput: |
name
--------------------------------------------------------------------------------------------------------------------------------
bardb
foodb
master
model
msdb
tempdb
(6 rows affected)
# schema-only image, also test dumps are imported
- dockerImage: schema-only
volumeMapping: ' -v "$(pwd)/docker-image-test-data:/data:ro"'
expectedOutput: |
name
--------------------------------------------------------------------------------------------------------------------------------
bardb
foodb
jore3testdb
master
model
msdb
tempdb
(7 rows affected)
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 mssql docker container
run: |
docker run -d --rm -p 1433:1433 --name mssql -e SA_PASSWORD="$SA_PASSWORD" ${{ matrix.volumeMapping }} $IMAGE_NAME:${{ matrix.dockerImage }}-$COMMIT_ID
- name:
Verify that dockerized MSSQL database is up and can be connected to
uses: HSLdevcom/jore4-tools/github-actions/healthcheck@healthcheck-v1
with:
command:
'/opt/mssql-tools/bin/sqlcmd -S 127.0.0.1 -U sa -P "$SA_PASSWORD" -d
master -Q "SELECT ''OK'';"'
- name:
Verify that the proper sql dumps got imported (diff expected results)
env:
# query for listing all available database names
DB_QUERY: "SELECT name FROM master.sys.databases ORDER BY name;"
run: |
/opt/mssql-tools/bin/sqlcmd -S 127.0.0.1 -U sa -P "$SA_PASSWORD" -d master -Q "$DB_QUERY" > 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
runs-on: ubuntu-22.04
steps:
- name: Extract metadata to env variables
uses: HSLdevcom/jore4-tools/github-actions/extract-metadata@extract-metadata-v1
- name: start e2e env
uses: HSLdevcom/jore4-tools/github-actions/setup-e2e-environment@setup-e2e-environment-v1
with:
mssqltestdb_version:
"${{ env.IMAGE_NAME }}:schema-only-${{ env.COMMIT_ID }}"
- name: Seed infrastructure links
uses: HSLdevcom/jore4-tools/github-actions/seed-infrastructure-links@seed-infrastructure-links-v1
- name: Run e2e tests
uses: HSLdevcom/jore4-tools/github-actions/run-cypress-tests@run-cypress-tests-v1