Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 3 additions & 17 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
28 changes: 27 additions & 1 deletion justfile
Original file line number Diff line number Diff line change
Expand Up @@ -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}}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
Loading