diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 65f13a6d4..9f514a0ca 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -208,7 +208,7 @@ jobs: env: PGPORT: ${{ job.services.postgres.ports[5432] }} - uses: taiki-e/install-action@763e3324d4fd026c9bd284c504378585777a87d5 # v2.62.57 - with: { tool: sqlx-cli } + with: { tool: "just,sqlx-cli" } # we want to test our docker images before we push them to the registry # this is done by @@ -323,25 +323,11 @@ jobs: platforms: linux/arm64,linux/amd64 - name: Test linux/arm64 Docker image - run: | - PLATFORM=linux/arm64 - TAG=${{ github.repository }}:linux - export MARTIN_BUILD_ALL=- - export MARTIN_BIN="docker run --rm --net host --platform $PLATFORM -e DATABASE_URL -e AWS_REGION=eu-central-1 -e AWS_SKIP_CREDENTIALS=1 -e RUST_LOG_FORMAT=bare -v $PWD/tests:/tests $TAG" - export MARTIN_CP_BIN="docker run --rm --net host --platform $PLATFORM -e DATABASE_URL -e AWS_REGION=eu-central-1 -e AWS_SKIP_CREDENTIALS=1 -e RUST_LOG_FORMAT=bare -v $PWD/tests:/tests --entrypoint /usr/local/bin/martin-cp $TAG" - export MBTILES_BIN="docker run --rm --net host --platform $PLATFORM -e DATABASE_URL -e AWS_REGION=eu-central-1 -e AWS_SKIP_CREDENTIALS=1 -v $PWD/tests:/tests --entrypoint /usr/local/bin/mbtiles $TAG" - tests/test.sh + run: just test-int-in-docker-image linux/arm64 ${{ github.repository }}:linux env: DATABASE_URL: postgres://${{ env.PGUSER }}:${{ env.PGUSER }}@${{ env.PGHOST }}:${{ job.services.postgres.ports[5432] }}/${{ env.PGDATABASE }}?sslmode=require - name: Test linux/amd64 Docker image - run: | - PLATFORM=linux/amd64 - TAG=${{ github.repository }}:linux - export MARTIN_BUILD_ALL=- - export MARTIN_BIN="docker run --rm --net host --platform $PLATFORM -e DATABASE_URL -e AWS_REGION=eu-central-1 -e AWS_SKIP_CREDENTIALS=1 -e RUST_LOG_FORMAT=bare -v $PWD/tests:/tests $TAG" - export MARTIN_CP_BIN="docker run --rm --net host --platform $PLATFORM -e DATABASE_URL -e AWS_REGION=eu-central-1 -e AWS_SKIP_CREDENTIALS=1 -e RUST_LOG_FORMAT=bare -v $PWD/tests:/tests --entrypoint /usr/local/bin/martin-cp $TAG" - export MBTILES_BIN="docker run --rm --net host --platform $PLATFORM -e DATABASE_URL -e AWS_REGION=eu-central-1 -e AWS_SKIP_CREDENTIALS=1 -v $PWD/tests:/tests --entrypoint /usr/local/bin/mbtiles $TAG" - tests/test.sh + run: just test-int-in-docker-image linux/amd64 ${{ github.repository }}:linux env: DATABASE_URL: postgres://${{ env.PGUSER }}:${{ env.PGUSER }}@${{ env.PGHOST }}:${{ job.services.postgres.ports[5432] }}/${{ env.PGDATABASE }}?sslmode=require diff --git a/justfile b/justfile index 57eabb5d5..32cc3dba9 100755 --- a/justfile +++ b/justfile @@ -349,6 +349,16 @@ restart: run *args='--webui enable-for-all': cargo run -p martin -- {{args}} +# Run a specified entrypoint of a docker image +run-in-docker-image PLATFORM image entrypoint *args='': + docker run --rm --net host \ + --platform {{PLATFORM}} \ + -e DATABASE_URL \ + -e AWS_REGION=eu-central-1 -e AWS_SKIP_CREDENTIALS=1 \ + -v "$PWD/tests:/tests" \ + --entrypoint /usr/local/bin/{{entrypoint}} \ + {{image}} {{args}} + # Start release-compiled Martin server and a test database run-release *args='--webui enable-for-all': start cargo run -p martin --release -- {{args}} @@ -431,6 +441,23 @@ test-int: clean-test install-sqlx start-pmtiles-server fi fi +# Run integration tests against a docker container +test-int-in-docker-image platform image: + #!/usr/bin/env bash + set -euo pipefail + + if ! command -v docker >/dev/null 2>&1; then + echo "Docker is missing -> https://docs.docker.com/get-docker/" + exit 1 + fi + + export MARTIN_BUILD_ALL="-" + export MARTIN_BIN="{{just_executable()}} run-in-docker-image {{platform}} {{image}} martin" + export MARTIN_CP_BIN="{{just_executable()}} run-in-docker-image {{platform}} {{image}} martin-cp" + export MBTILES_BIN="{{just_executable()}} run-in-docker-image {{platform}} {{image}} mbtiles" + + {{just}} test-int + # Run AWS Lambda smoke test against SAM local test-lambda martin_bin='target/debug/martin': #!/usr/bin/env bash @@ -477,7 +504,6 @@ test-lambda martin_bin='target/debug/martin': jq -ne 'input.statusCode == 200' <<<"$response" - # Run all tests using the oldest supported version of the database test-legacy: start-legacy (test-cargo "--all-targets") test-pg test-doc test-int