diff --git a/.github/workflows/cargo-test.yaml b/.github/workflows/cargo-test.yaml index 0908a0d6..ec4293e5 100644 --- a/.github/workflows/cargo-test.yaml +++ b/.github/workflows/cargo-test.yaml @@ -36,9 +36,6 @@ jobs: services: | sqlserver - - name: Load Chinook data - run: sqlcmd -S localhost,64003 -U SA -P "Password!" -i "./static/chinook-sqlserver.sql" - - name: run tests run: | cargo test --release --workspace diff --git a/docker-compose.yaml b/docker-compose.yaml index c2979806..493166fd 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -6,6 +6,7 @@ services: platform: linux/amd64 ports: - 64003:1433 + command: bash -c "/docker/entrypoint.sh" environment: ACCEPT_EULA: "Y" MSSQL_PID: "Developer" @@ -14,8 +15,13 @@ services: volumes: - /var/opt/mssql - type: bind + read_only: true source: ./static target: /static + - type: bind + read_only: true + source: ./docker + target: /docker healthcheck: test: - CMD-SHELL diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh new file mode 100755 index 00000000..aeb1bf5f --- /dev/null +++ b/docker/entrypoint.sh @@ -0,0 +1 @@ +/docker/import-chinook.sh & /opt/mssql/bin/sqlservr diff --git a/docker/import-chinook.sh b/docker/import-chinook.sh new file mode 100755 index 00000000..3e8eb15e --- /dev/null +++ b/docker/import-chinook.sh @@ -0,0 +1,18 @@ +#run the setup script to create the DB and the schema in the DB +#do this in a loop because the timing for when the SQL instance is ready is indeterminate + +PASSWORD="Password!" + +for i in {1..50}; +do + /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P "${PASSWORD}" -i /static/chinook-sqlserver.sql + if [ $? -eq 0 ] + then + echo "setup.sql completed" + break + else + echo "not ready yet..." + sleep 1 + fi +done + diff --git a/justfile b/justfile index 5f088dbb..36b73bd4 100644 --- a/justfile +++ b/justfile @@ -88,10 +88,7 @@ test-integrated: # run sqlserver start-dependencies: - # start sqlserver - docker compose down -v sqlserver docker compose up --wait sqlserver - docker exec -it ndc-sqlserver-sqlserver-1 /opt/mssql-tools/bin/sqlcmd -S localhost,1433 -U SA -P "Password!" -i "/static/chinook-sqlserver.sql" # run prometheus + grafana start-metrics: