mirror of
https://github.com/maplibre/martin.git
synced 2024-12-19 04:41:46 +03:00
1e34676a14
* style: run fmt * ci: run release only on tags * ci: switch to actions/checkout@v2 * ci: add grcov * ci: update docker job
212 lines
5.8 KiB
YAML
212 lines
5.8 KiB
YAML
name: CI
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- master
|
|
pull_request:
|
|
branches:
|
|
- master
|
|
|
|
jobs:
|
|
check:
|
|
name: Check
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout sources
|
|
uses: actions/checkout@v2
|
|
|
|
- name: Install stable toolchain
|
|
uses: actions-rs/toolchain@v1
|
|
with:
|
|
toolchain: stable
|
|
override: true
|
|
|
|
- name: Run cargo check
|
|
uses: actions-rs/cargo@v1
|
|
with:
|
|
command: check
|
|
|
|
clippy:
|
|
name: Clippy
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout sources
|
|
uses: actions/checkout@v2
|
|
|
|
- name: Install stable toolchain
|
|
uses: actions-rs/toolchain@v1
|
|
with:
|
|
toolchain: stable
|
|
override: true
|
|
|
|
- name: Install clippy
|
|
run: rustup component add clippy
|
|
|
|
- name: Run cargo clippy
|
|
uses: actions-rs/cargo@v1
|
|
with:
|
|
command: clippy
|
|
args: -- -D warnings
|
|
|
|
fmt:
|
|
name: Rustfmt
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout sources
|
|
uses: actions/checkout@v2
|
|
|
|
- name: Install stable toolchain
|
|
uses: actions-rs/toolchain@v1
|
|
with:
|
|
toolchain: stable
|
|
override: true
|
|
|
|
- name: Install rustfmt
|
|
run: rustup component add rustfmt
|
|
|
|
- name: Run cargo fmt
|
|
uses: actions-rs/cargo@v1
|
|
with:
|
|
command: fmt
|
|
args: --all -- --check
|
|
|
|
test:
|
|
name: Test Suite
|
|
runs-on: ubuntu-latest
|
|
services:
|
|
postgres:
|
|
image: mdillon/postgis:11-alpine
|
|
env:
|
|
POSTGRES_USER: postgres
|
|
POSTGRES_DB: test
|
|
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@v2
|
|
|
|
- name: Setup database
|
|
run: |
|
|
sudo apt-get install postgresql-client
|
|
psql -h $POSTGRES_HOST -p $POSTGRES_PORT -U postgres -d test -f tests/fixtures/TileBBox.sql
|
|
psql -h $POSTGRES_HOST -p $POSTGRES_PORT -U postgres -d test -f tests/fixtures/table_source.sql
|
|
psql -h $POSTGRES_HOST -p $POSTGRES_PORT -U postgres -d test -f tests/fixtures/function_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] }}/test
|
|
|
|
- name: Run build
|
|
uses: actions-rs/cargo@v1
|
|
with:
|
|
command: build
|
|
|
|
- name: Run server
|
|
run: ./target/debug/martin &
|
|
env:
|
|
DATABASE_URL: postgres://postgres@localhost:${{ job.services.postgres.ports[5432] }}/test
|
|
|
|
- name: Test server response
|
|
run: |
|
|
curl localhost:3000/public.table_source/0/0/0.pbf > table_source.pbf
|
|
curl localhost:3000/rpc/public.function_source/0/0/0.pbf > function_source.pbf
|
|
./tests/vtzero-check table_source.pbf
|
|
./tests/vtzero-check function_source.pbf
|
|
./tests/vtzero-show table_source.pbf
|
|
./tests/vtzero-show function_source.pbf
|
|
|
|
docker:
|
|
if: startsWith(github.ref, 'refs/tags/')
|
|
needs: [test]
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout sources
|
|
uses: actions/checkout@v2
|
|
|
|
- name: Build the Docker image
|
|
uses: docker/build-push-action@v1
|
|
with:
|
|
username: ${{ secrets.DOCKER_USERNAME }}
|
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
|
repository: urbica/martin
|
|
tag_with_ref: true
|
|
push: ${{ startsWith(github.ref, 'refs/tags/') }}
|
|
|
|
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@v2
|
|
- 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 }}
|