2019-09-30 12:42:49 +03:00
|
|
|
name: CI
|
2019-09-29 21:47:24 +03:00
|
|
|
|
2020-05-05 14:13:48 +03:00
|
|
|
on:
|
|
|
|
push:
|
|
|
|
branches:
|
2021-11-07 17:28:21 +03:00
|
|
|
- main
|
2020-05-05 14:13:48 +03:00
|
|
|
pull_request:
|
|
|
|
branches:
|
2021-11-07 17:28:21 +03:00
|
|
|
- main
|
2022-10-07 23:32:40 +03:00
|
|
|
release:
|
|
|
|
branches:
|
|
|
|
- main
|
2019-09-29 21:47:24 +03:00
|
|
|
|
|
|
|
jobs:
|
2022-10-22 18:01:16 +03:00
|
|
|
lints:
|
|
|
|
name: Run format and clippy tests
|
2019-09-29 21:47:24 +03:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- name: Checkout sources
|
2022-05-27 15:00:45 +03:00
|
|
|
uses: actions/checkout@v3
|
2022-10-22 18:01:16 +03:00
|
|
|
- name: Install fmt & clippy
|
|
|
|
run: rustup component add clippy rustfmt
|
|
|
|
- name: Run cargo fmt
|
2022-10-26 12:52:31 +03:00
|
|
|
run: cargo fmt --all -- --check
|
2019-09-29 21:47:24 +03:00
|
|
|
- name: Run cargo clippy
|
2022-10-26 12:52:31 +03:00
|
|
|
run: cargo clippy --all-targets --all-features -- -D warnings
|
2019-09-29 21:47:24 +03:00
|
|
|
|
|
|
|
test:
|
|
|
|
name: Test Suite
|
2022-10-06 04:06:04 +03:00
|
|
|
runs-on: ubuntu-latest
|
2022-10-25 21:54:36 +03:00
|
|
|
env:
|
|
|
|
# PG_* variables are used by psql
|
|
|
|
PGDATABASE: db
|
|
|
|
PGHOST: localhost
|
|
|
|
PGUSER: postgres
|
2019-09-29 21:47:24 +03:00
|
|
|
services:
|
|
|
|
postgres:
|
2022-10-28 21:52:39 +03:00
|
|
|
image: postgis/postgis:14-3.3-alpine
|
2019-09-29 21:47:24 +03:00
|
|
|
env:
|
2022-10-25 21:54:36 +03:00
|
|
|
# POSTGRES_* variables are used by the postgis/postgres image
|
|
|
|
POSTGRES_DB: ${{ env.PGDATABASE }}
|
|
|
|
POSTGRES_USER: ${{ env.PGUSER }}
|
2020-12-27 16:35:05 +03:00
|
|
|
POSTGRES_HOST_AUTH_METHOD: trust
|
2019-09-29 21:47:24 +03:00
|
|
|
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
|
2022-05-27 15:00:45 +03:00
|
|
|
uses: actions/checkout@v3
|
2019-09-29 21:47:24 +03:00
|
|
|
|
|
|
|
- name: Setup database
|
|
|
|
run: |
|
|
|
|
sudo apt-get install postgresql-client
|
2022-10-25 21:54:36 +03:00
|
|
|
tests/fixtures/initdb.sh
|
2019-09-29 21:47:24 +03:00
|
|
|
env:
|
2022-10-25 21:54:36 +03:00
|
|
|
PGPORT: ${{ job.services.postgres.ports[5432] }}
|
2019-09-29 21:47:24 +03:00
|
|
|
|
2020-05-05 14:13:48 +03:00
|
|
|
- name: Run tests
|
2022-10-26 12:52:31 +03:00
|
|
|
run: cargo test --all
|
2019-09-29 21:47:24 +03:00
|
|
|
env:
|
2022-10-28 21:52:39 +03:00
|
|
|
DATABASE_URL: postgres://${{ env.PGUSER }}@${{ env.PGHOST }}:${{ job.services.postgres.ports[5432] }}/${{ env.PGDATABASE }}
|
2019-09-29 21:47:24 +03:00
|
|
|
|
|
|
|
- name: Run build
|
2022-10-26 12:52:31 +03:00
|
|
|
run: cargo build
|
2019-09-29 21:47:24 +03:00
|
|
|
|
2022-10-28 21:52:39 +03:00
|
|
|
- name: Run martin tests
|
|
|
|
run: ./tests/test.sh
|
2019-09-30 08:43:16 +03:00
|
|
|
env:
|
2022-10-28 21:52:39 +03:00
|
|
|
MARTIN_BIN: ./target/debug/martin
|
|
|
|
DATABASE_URL: postgres://${{ env.PGUSER }}@${{ env.PGHOST }}:${{ job.services.postgres.ports[5432] }}/${{ env.PGDATABASE }}
|
2019-09-30 08:43:16 +03:00
|
|
|
|
2022-10-28 21:52:39 +03:00
|
|
|
- name: Compare test output results (TODO)
|
|
|
|
if: false
|
|
|
|
run: |
|
|
|
|
# TODO: this test is currently broken because the output of the tests is not deterministic
|
|
|
|
diff --brief --recursive --new-file tests/output tests/expected
|
2022-02-13 15:43:52 +03:00
|
|
|
|
2022-10-28 21:52:39 +03:00
|
|
|
- name: 'Save test output on failure'
|
|
|
|
if: failure()
|
|
|
|
uses: actions/upload-artifact@v3
|
|
|
|
with:
|
|
|
|
name: test-output
|
|
|
|
path: tests/output/*
|
|
|
|
retention-days: 5
|
2021-10-12 17:56:45 +03:00
|
|
|
|
2019-09-29 21:47:24 +03:00
|
|
|
|
2022-10-22 20:39:05 +03:00
|
|
|
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
|
2022-10-26 12:52:31 +03:00
|
|
|
uses: dtolnay/rust-toolchain@master
|
2022-10-22 20:39:05 +03:00
|
|
|
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
|
2022-10-26 12:52:31 +03:00
|
|
|
run: cargo build --release --target ${{ matrix.target }}
|
2022-10-22 20:39:05 +03:00
|
|
|
|
2019-09-30 19:12:00 +03:00
|
|
|
docker:
|
|
|
|
needs: [test]
|
2020-05-05 14:13:48 +03:00
|
|
|
runs-on: ubuntu-latest
|
2019-09-30 19:12:00 +03:00
|
|
|
steps:
|
2020-05-05 14:13:48 +03:00
|
|
|
- name: Checkout sources
|
2022-05-27 15:00:45 +03:00
|
|
|
uses: actions/checkout@v3
|
2020-05-05 14:13:48 +03:00
|
|
|
|
2022-05-27 13:35:06 +03:00
|
|
|
# https://github.com/docker/metadata-action
|
2021-01-16 15:48:39 +03:00
|
|
|
- name: Docker meta
|
|
|
|
id: docker_meta
|
2022-05-27 13:35:06 +03:00
|
|
|
uses: docker/metadata-action@v4
|
2021-01-16 15:48:39 +03:00
|
|
|
with:
|
2022-09-27 04:48:46 +03:00
|
|
|
images: maplibre/martin
|
2021-01-16 15:48:39 +03:00
|
|
|
|
2022-05-27 13:35:06 +03:00
|
|
|
# https://github.com/docker/setup-qemu-action
|
|
|
|
- name: Set up QEMU
|
|
|
|
uses: docker/setup-qemu-action@v2
|
|
|
|
|
|
|
|
# https://github.com/docker/setup-buildx-action
|
2021-01-16 15:48:39 +03:00
|
|
|
- name: Set up Docker Buildx
|
2022-05-27 13:35:06 +03:00
|
|
|
uses: docker/setup-buildx-action@v2
|
|
|
|
with:
|
|
|
|
install: true
|
2021-01-16 15:48:39 +03:00
|
|
|
|
|
|
|
- name: Login to DockerHub
|
2022-05-27 13:35:06 +03:00
|
|
|
uses: docker/login-action@v2
|
2022-05-27 14:46:48 +03:00
|
|
|
if: ${{ github.actor != 'dependabot[bot]' && !github.event.pull_request.head.repo.fork }}
|
2020-05-05 14:13:48 +03:00
|
|
|
with:
|
2022-09-27 04:48:46 +03:00
|
|
|
username: ${{ secrets.DOCKER_HUB_USERNAME }}
|
|
|
|
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
|
2021-01-16 15:48:39 +03:00
|
|
|
|
|
|
|
- name: Build and push the Docker image
|
2022-05-27 13:35:06 +03:00
|
|
|
uses: docker/build-push-action@v3
|
2021-01-16 15:48:39 +03:00
|
|
|
with:
|
2022-10-18 17:07:51 +03:00
|
|
|
push: ${{ github.actor != 'dependabot[bot]' && github.event_name != 'pull_request' }}
|
2021-01-16 15:48:39 +03:00
|
|
|
tags: ${{ steps.docker_meta.outputs.tags }}
|
|
|
|
labels: ${{ steps.docker_meta.outputs.labels }}
|
2019-09-30 19:12:00 +03:00
|
|
|
|
2019-09-29 21:47:24 +03:00
|
|
|
release:
|
2020-05-05 14:13:48 +03:00
|
|
|
if: startsWith(github.ref, 'refs/tags/')
|
2019-09-29 21:47:24 +03:00
|
|
|
needs: [test]
|
|
|
|
strategy:
|
|
|
|
matrix:
|
|
|
|
os: [ubuntu-latest, macOS-latest, windows-latest]
|
|
|
|
include:
|
|
|
|
- os: ubuntu-latest
|
|
|
|
rust: stable
|
2020-05-04 21:21:11 +03:00
|
|
|
target: x86_64-unknown-linux-gnu
|
2019-09-29 21:47:24 +03:00
|
|
|
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
|
2022-10-26 12:52:31 +03:00
|
|
|
uses: dtolnay/rust-toolchain@master
|
2019-09-29 21:47:24 +03:00
|
|
|
with:
|
|
|
|
toolchain: ${{ matrix.rust }}
|
|
|
|
override: true
|
|
|
|
target: ${{ matrix.target }}
|
|
|
|
- name: Checkout
|
2022-05-27 15:00:45 +03:00
|
|
|
uses: actions/checkout@v3
|
2022-10-22 20:39:05 +03:00
|
|
|
- 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
|
2019-09-29 21:47:24 +03:00
|
|
|
- name: Run build
|
2022-10-26 12:52:31 +03:00
|
|
|
run: cargo build --release --target ${{ matrix.target }}
|
2019-09-29 21:47:24 +03:00
|
|
|
- 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 -
|
2019-09-30 16:24:15 +03:00
|
|
|
- name: Generate SHA-256
|
|
|
|
if: matrix.os == 'macOS-latest'
|
|
|
|
run: shasum -a 256 ${{ matrix.name }}
|
2019-09-29 21:47:24 +03:00
|
|
|
- name: Publish
|
|
|
|
uses: softprops/action-gh-release@v1
|
|
|
|
with:
|
2019-09-30 12:42:49 +03:00
|
|
|
draft: true
|
2021-10-12 17:56:45 +03:00
|
|
|
files: 'martin*'
|
2019-09-30 13:33:42 +03:00
|
|
|
body_path: CHANGELOG.md
|
2019-09-29 21:47:24 +03:00
|
|
|
env:
|
|
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|