mirror of
https://github.com/maplibre/martin.git
synced 2024-12-26 16:34:36 +03:00
def4a6f1ec
* Detect all unrecognized config file values, and report them. Ideally we want to use `serde-ignored` crate, but it doesn't work with flattened structs (yet). So using a bad workaround. * CI test has been using all sorts of somewhat duplicated temporary pbf files - cleaned up to `tmp.pbf`, and made sure curl only shows errors, not download stats. * In CI, crash psql instead of silently ignoring errors * Don't serialize optional config values as nulls * Tiny error message cleanup
356 lines
13 KiB
YAML
356 lines
13 KiB
YAML
name: CI
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
pull_request:
|
|
branches:
|
|
- main
|
|
release:
|
|
branches:
|
|
- main
|
|
|
|
jobs:
|
|
lints:
|
|
name: Run format and clippy tests
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout sources
|
|
uses: actions/checkout@v3
|
|
|
|
- name: Install stable toolchain
|
|
uses: actions-rs/toolchain@v1
|
|
with:
|
|
toolchain: stable
|
|
|
|
- name: Install fmt & clippy
|
|
run: rustup component add clippy rustfmt
|
|
|
|
- name: Run cargo fmt
|
|
uses: actions-rs/cargo@v1
|
|
with:
|
|
command: fmt
|
|
args: --all -- --check
|
|
|
|
- name: Run cargo clippy
|
|
uses: actions-rs/cargo@v1
|
|
with:
|
|
command: clippy
|
|
args: --all-targets --all-features -- -D warnings
|
|
|
|
test:
|
|
name: Test Suite
|
|
runs-on: ubuntu-latest
|
|
services:
|
|
postgres:
|
|
image: postgis/postgis:14-3.1-alpine
|
|
env:
|
|
POSTGRES_DB: db
|
|
POSTGRES_USER: postgres
|
|
POSTGRES_HOST_AUTH_METHOD: trust
|
|
ports:
|
|
# will assign a random free host port
|
|
- 5432/tcp
|
|
# needed because the postgres container does not provide a healthcheck
|
|
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
|
|
steps:
|
|
- name: Checkout sources
|
|
uses: actions/checkout@v3
|
|
|
|
- name: Setup database
|
|
run: |
|
|
sudo apt-get install postgresql-client
|
|
psql -h $POSTGRES_HOST -p $POSTGRES_PORT -U postgres -d db -v ON_ERROR_STOP=1 -f tests/fixtures/TileBBox.sql
|
|
psql -h $POSTGRES_HOST -p $POSTGRES_PORT -U postgres -d db -v ON_ERROR_STOP=1 -f tests/fixtures/table_source.sql
|
|
psql -h $POSTGRES_HOST -p $POSTGRES_PORT -U postgres -d db -v ON_ERROR_STOP=1 -f tests/fixtures/table_source_multiple_geom.sql
|
|
psql -h $POSTGRES_HOST -p $POSTGRES_PORT -U postgres -d db -v ON_ERROR_STOP=1 -f tests/fixtures/function_source.sql
|
|
psql -h $POSTGRES_HOST -p $POSTGRES_PORT -U postgres -d db -v ON_ERROR_STOP=1 -f tests/fixtures/function_source_query_params.sql
|
|
psql -h $POSTGRES_HOST -p $POSTGRES_PORT -U postgres -d db -v ON_ERROR_STOP=1 -f tests/fixtures/points1_source.sql
|
|
psql -h $POSTGRES_HOST -p $POSTGRES_PORT -U postgres -d db -v ON_ERROR_STOP=1 -f tests/fixtures/points2_source.sql
|
|
psql -h $POSTGRES_HOST -p $POSTGRES_PORT -U postgres -d db -v ON_ERROR_STOP=1 -f tests/fixtures/points3857_source.sql
|
|
psql -h $POSTGRES_HOST -p $POSTGRES_PORT -U postgres -d db -v ON_ERROR_STOP=1 -f tests/fixtures/points_empty_srid_source.sql
|
|
env:
|
|
POSTGRES_HOST: localhost
|
|
POSTGRES_PORT: ${{ job.services.postgres.ports[5432] }}
|
|
|
|
- name: Install stable toolchain
|
|
uses: actions-rs/toolchain@v1
|
|
with:
|
|
toolchain: stable
|
|
override: true
|
|
|
|
- name: Run tests
|
|
uses: actions-rs/cargo@v1
|
|
with:
|
|
command: test
|
|
args: --all
|
|
env:
|
|
DATABASE_URL: postgres://postgres@localhost:${{ job.services.postgres.ports[5432] }}/db
|
|
|
|
- name: Run build
|
|
uses: actions-rs/cargo@v1
|
|
with:
|
|
command: build
|
|
|
|
- name: Run server
|
|
run: ./target/debug/martin --default-srid 900913 &
|
|
env:
|
|
DATABASE_URL: postgres://postgres@localhost:${{ job.services.postgres.ports[5432] }}/db
|
|
|
|
- name: Test server response for table source
|
|
run: |
|
|
curl -sS "localhost:3000/index.json" | jq -e
|
|
curl -sS "localhost:3000/public.table_source/0/0/0.pbf" > tmp.pbf
|
|
./tests/vtzero-check tmp.pbf
|
|
./tests/vtzero-show tmp.pbf
|
|
curl -sS "localhost:3000/public.table_source/6/38/20.pbf" > tmp.pbf
|
|
./tests/vtzero-check tmp.pbf
|
|
./tests/vtzero-show tmp.pbf
|
|
curl -sS "localhost:3000/public.table_source/12/2476/1280.pbf" > tmp.pbf
|
|
./tests/vtzero-check tmp.pbf
|
|
./tests/vtzero-show tmp.pbf
|
|
curl -sS "localhost:3000/public.table_source/13/4952/2560.pbf" > tmp.pbf
|
|
./tests/vtzero-check tmp.pbf
|
|
./tests/vtzero-show tmp.pbf
|
|
curl -sS "localhost:3000/public.table_source/14/9904/5121.pbf" > tmp.pbf
|
|
./tests/vtzero-check tmp.pbf
|
|
./tests/vtzero-show tmp.pbf
|
|
curl -sS "localhost:3000/public.table_source/20/633856/327787.pbf" > tmp.pbf
|
|
./tests/vtzero-check tmp.pbf
|
|
./tests/vtzero-show tmp.pbf
|
|
curl -sS "localhost:3000/public.table_source/21/1267712/655574.pbf" > tmp.pbf
|
|
./tests/vtzero-check tmp.pbf
|
|
./tests/vtzero-show tmp.pbf
|
|
|
|
- name: Test server response for composite source
|
|
run: |
|
|
curl -sS "localhost:3000/public.table_source,public.points1,public.points2/0/0/0.pbf" > tmp.pbf
|
|
./tests/vtzero-check tmp.pbf
|
|
./tests/vtzero-show tmp.pbf
|
|
curl -sS "localhost:3000/public.table_source,public.points1,public.points2/6/38/20.pbf" > tmp.pbf
|
|
./tests/vtzero-check tmp.pbf
|
|
./tests/vtzero-show tmp.pbf
|
|
curl -sS "localhost:3000/public.table_source,public.points1,public.points2/12/2476/1280.pbf" > tmp.pbf
|
|
./tests/vtzero-check tmp.pbf
|
|
./tests/vtzero-show tmp.pbf
|
|
curl -sS "localhost:3000/public.table_source,public.points1,public.points2/13/4952/2560.pbf" > tmp.pbf
|
|
./tests/vtzero-check tmp.pbf
|
|
./tests/vtzero-show tmp.pbf
|
|
curl -sS "localhost:3000/public.table_source,public.points1,public.points2/14/9904/5121.pbf" > tmp.pbf
|
|
./tests/vtzero-check tmp.pbf
|
|
./tests/vtzero-show tmp.pbf
|
|
curl -sS "localhost:3000/public.table_source,public.points1,public.points2/20/633856/327787.pbf" > tmp.pbf
|
|
./tests/vtzero-check tmp.pbf
|
|
./tests/vtzero-show tmp.pbf
|
|
curl -sS "localhost:3000/public.table_source,public.points1,public.points2/21/1267712/655574.pbf" > tmp.pbf
|
|
./tests/vtzero-check tmp.pbf
|
|
./tests/vtzero-show tmp.pbf
|
|
|
|
- name: Test server response for function source
|
|
run: |
|
|
curl -sS "localhost:3000/rpc/public.function_source/0/0/0.pbf" > tmp.pbf
|
|
./tests/vtzero-check tmp.pbf
|
|
./tests/vtzero-show tmp.pbf
|
|
curl -sS "localhost:3000/rpc/public.function_source/6/38/20.pbf" > tmp.pbf
|
|
./tests/vtzero-check tmp.pbf
|
|
./tests/vtzero-show tmp.pbf
|
|
curl -sS "localhost:3000/rpc/public.function_source/12/2476/1280.pbf" > tmp.pbf
|
|
./tests/vtzero-check tmp.pbf
|
|
./tests/vtzero-show tmp.pbf
|
|
curl -sS "localhost:3000/rpc/public.function_source/13/4952/2560.pbf" > tmp.pbf
|
|
./tests/vtzero-check tmp.pbf
|
|
./tests/vtzero-show tmp.pbf
|
|
curl -sS "localhost:3000/rpc/public.function_source/14/9904/5121.pbf" > tmp.pbf
|
|
./tests/vtzero-check tmp.pbf
|
|
./tests/vtzero-show tmp.pbf
|
|
curl -sS "localhost:3000/rpc/public.function_source/20/633856/327787.pbf" > tmp.pbf
|
|
./tests/vtzero-check tmp.pbf
|
|
./tests/vtzero-show tmp.pbf
|
|
curl -sS "localhost:3000/rpc/public.function_source/21/1267712/655574.pbf" > tmp.pbf
|
|
./tests/vtzero-check tmp.pbf
|
|
./tests/vtzero-show tmp.pbf
|
|
curl -sS "localhost:3000/rpc/public.function_source_query_params/0/0/0.pbf?token=martin" > tmp.pbf
|
|
./tests/vtzero-check tmp.pbf
|
|
./tests/vtzero-show tmp.pbf
|
|
|
|
- name: Test server response for table source with different SRID
|
|
run: |
|
|
curl -sS "localhost:3000/public.points3857/0/0/0.pbf" > tmp.pbf
|
|
./tests/vtzero-check tmp.pbf
|
|
./tests/vtzero-show tmp.pbf
|
|
|
|
- name: Test server response for table source with empty SRID
|
|
run: |
|
|
curl -sS "localhost:3000/public.points_empty_srid/0/0/0.pbf" > tmp.pbf
|
|
./tests/vtzero-check tmp.pbf
|
|
./tests/vtzero-show tmp.pbf
|
|
|
|
- name: Prepare config
|
|
run: sed -i 's/5432/${{ job.services.postgres.ports[5432] }}/g' ./tests/config.yaml
|
|
|
|
- name: Run server with config
|
|
run: pkill martin && ./target/debug/martin --config ./tests/config.yaml &
|
|
|
|
- name: Test server response
|
|
run: |
|
|
curl -sS "localhost:3000/index.json" | jq -e
|
|
curl -sS "localhost:3000/public.table_source/0/0/0.pbf" > tmp.pbf
|
|
./tests/vtzero-check tmp.pbf
|
|
./tests/vtzero-show tmp.pbf
|
|
curl -sS "localhost:3000/public.points1,public.points2/0/0/0.pbf" > tmp.pbf
|
|
./tests/vtzero-check tmp.pbf
|
|
./tests/vtzero-show tmp.pbf
|
|
curl -sS "localhost:3000/rpc/public.function_source/0/0/0.pbf" > tmp.pbf
|
|
./tests/vtzero-check tmp.pbf
|
|
./tests/vtzero-show tmp.pbf
|
|
curl -sS "localhost:3000/rpc/public.function_source_query_params/0/0/0.pbf?token=martin" > tmp.pbf
|
|
./tests/vtzero-check tmp.pbf
|
|
./tests/vtzero-show tmp.pbf
|
|
|
|
build:
|
|
needs: [test]
|
|
strategy:
|
|
matrix:
|
|
os: [ubuntu-latest, macOS-latest, windows-latest]
|
|
include:
|
|
- os: ubuntu-latest
|
|
rust: stable
|
|
target: x86_64-unknown-linux-gnu
|
|
bin: martin
|
|
name: martin-Linux-x86_64.tar.gz
|
|
- os: windows-latest
|
|
rust: stable
|
|
target: x86_64-pc-windows-msvc
|
|
bin: martin.exe
|
|
name: martin-Windows-x86_64.zip
|
|
- os: macOS-latest
|
|
rust: stable
|
|
target: x86_64-apple-darwin
|
|
bin: martin
|
|
name: martin-Darwin-x86_64.tar.gz
|
|
runs-on: ${{ matrix.os }}
|
|
steps:
|
|
- name: Install stable toolchain
|
|
uses: actions-rs/toolchain@v1
|
|
with:
|
|
toolchain: ${{ matrix.rust }}
|
|
override: true
|
|
target: ${{ matrix.target }}
|
|
- name: Checkout
|
|
uses: actions/checkout@v3
|
|
- name: Install OpenSSL
|
|
if: matrix.os == 'windows-latest'
|
|
run: |
|
|
echo "VCPKG_ROOT=$env:VCPKG_INSTALLATION_ROOT" | Out-File -FilePath $env:GITHUB_ENV -Append
|
|
vcpkg install openssl:x64-windows-static-md
|
|
- name: Run build
|
|
uses: actions-rs/cargo@v1
|
|
with:
|
|
command: build
|
|
args: --release --target ${{ matrix.target }}
|
|
|
|
docker:
|
|
needs: [test]
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout sources
|
|
uses: actions/checkout@v3
|
|
|
|
# https://github.com/docker/metadata-action
|
|
- name: Docker meta
|
|
id: docker_meta
|
|
uses: docker/metadata-action@v4
|
|
with:
|
|
images: maplibre/martin
|
|
|
|
# https://github.com/docker/setup-qemu-action
|
|
- name: Set up QEMU
|
|
uses: docker/setup-qemu-action@v2
|
|
|
|
# https://github.com/docker/setup-buildx-action
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v2
|
|
with:
|
|
install: true
|
|
|
|
- name: Login to DockerHub
|
|
uses: docker/login-action@v2
|
|
if: ${{ github.actor != 'dependabot[bot]' && !github.event.pull_request.head.repo.fork }}
|
|
with:
|
|
username: ${{ secrets.DOCKER_HUB_USERNAME }}
|
|
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
|
|
|
|
- name: Build and push the Docker image
|
|
uses: docker/build-push-action@v3
|
|
with:
|
|
push: ${{ github.actor != 'dependabot[bot]' && github.event_name != 'pull_request' }}
|
|
tags: ${{ steps.docker_meta.outputs.tags }}
|
|
labels: ${{ steps.docker_meta.outputs.labels }}
|
|
|
|
release:
|
|
if: startsWith(github.ref, 'refs/tags/')
|
|
needs: [test]
|
|
strategy:
|
|
matrix:
|
|
os: [ubuntu-latest, macOS-latest, windows-latest]
|
|
include:
|
|
- os: ubuntu-latest
|
|
rust: stable
|
|
target: x86_64-unknown-linux-gnu
|
|
bin: martin
|
|
name: martin-Linux-x86_64.tar.gz
|
|
- os: windows-latest
|
|
rust: stable
|
|
target: x86_64-pc-windows-msvc
|
|
bin: martin.exe
|
|
name: martin-Windows-x86_64.zip
|
|
- os: macOS-latest
|
|
rust: stable
|
|
target: x86_64-apple-darwin
|
|
bin: martin
|
|
name: martin-Darwin-x86_64.tar.gz
|
|
runs-on: ${{ matrix.os }}
|
|
steps:
|
|
- name: Install stable toolchain
|
|
uses: actions-rs/toolchain@v1
|
|
with:
|
|
toolchain: ${{ matrix.rust }}
|
|
override: true
|
|
target: ${{ matrix.target }}
|
|
- name: Checkout
|
|
uses: actions/checkout@v3
|
|
- name: Install OpenSSL
|
|
if: matrix.os == 'windows-latest'
|
|
run: |
|
|
echo "VCPKG_ROOT=$env:VCPKG_INSTALLATION_ROOT" | Out-File -FilePath $env:GITHUB_ENV -Append
|
|
vcpkg install openssl:x64-windows-static-md
|
|
- name: Run build
|
|
uses: actions-rs/cargo@v1
|
|
with:
|
|
command: build
|
|
args: --release --target ${{ matrix.target }}
|
|
- name: Package
|
|
shell: bash
|
|
run: |
|
|
strip target/${{ matrix.target }}/release/${{ matrix.bin }}
|
|
cd target/${{ matrix.target }}/release
|
|
if [[ "${{ matrix.os }}" == "windows-latest" ]]
|
|
then
|
|
7z a ../../../${{ matrix.name }} ${{ matrix.bin }}
|
|
else
|
|
tar czvf ../../../${{ matrix.name }} ${{ matrix.bin }}
|
|
fi
|
|
cd -
|
|
- name: Generate SHA-256
|
|
if: matrix.os == 'macOS-latest'
|
|
run: shasum -a 256 ${{ matrix.name }}
|
|
- name: Publish
|
|
uses: softprops/action-gh-release@v1
|
|
with:
|
|
draft: true
|
|
files: 'martin*'
|
|
body_path: CHANGELOG.md
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|