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:
|
2022-10-31 23:28:21 +03:00
|
|
|
branches: [main]
|
2020-05-05 14:13:48 +03:00
|
|
|
pull_request:
|
2022-10-31 23:28:21 +03:00
|
|
|
branches: [main]
|
2022-10-07 23:32:40 +03:00
|
|
|
release:
|
2022-10-31 23:28:21 +03:00
|
|
|
branches: [main]
|
|
|
|
workflow_dispatch:
|
2019-09-29 21:47:24 +03:00
|
|
|
|
|
|
|
jobs:
|
2022-10-31 23:28:21 +03:00
|
|
|
build:
|
|
|
|
strategy:
|
|
|
|
fail-fast: true
|
|
|
|
matrix:
|
|
|
|
include:
|
|
|
|
- os: ubuntu-latest
|
|
|
|
target: x86_64-unknown-linux-gnu
|
|
|
|
- os: windows-latest
|
|
|
|
target: x86_64-pc-windows-msvc
|
|
|
|
- os: macOS-latest
|
|
|
|
target: x86_64-apple-darwin
|
|
|
|
runs-on: ${{ matrix.os }}
|
2019-09-29 21:47:24 +03:00
|
|
|
steps:
|
2022-10-31 23:28:21 +03:00
|
|
|
# - name: Install stable toolchain
|
|
|
|
# uses: dtolnay/rust-toolchain@master
|
|
|
|
# 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-31 23:28:21 +03:00
|
|
|
- name: Lint
|
|
|
|
if: runner.os == 'Linux'
|
|
|
|
shell: bash
|
2019-09-29 21:47:24 +03:00
|
|
|
run: |
|
2022-10-31 23:28:21 +03:00
|
|
|
cargo fmt --all -- --check
|
|
|
|
cargo clippy --all-targets --all-features -- -D warnings
|
|
|
|
- name: Install OpenSSL (Windows)
|
|
|
|
if: runner.os == 'Windows'
|
|
|
|
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-31 23:28:21 +03:00
|
|
|
shell: bash
|
2022-10-28 21:52:39 +03:00
|
|
|
run: |
|
2022-10-31 23:28:21 +03:00
|
|
|
cargo build --release --target ${{ matrix.target }}
|
|
|
|
mkdir target_releases
|
|
|
|
if [[ "${{ runner.os }}" == "Windows" ]]; then
|
|
|
|
mv target/${{ matrix.target }}/release/martin.exe target_releases
|
|
|
|
else
|
|
|
|
mv target/${{ matrix.target }}/release/martin target_releases
|
|
|
|
fi
|
|
|
|
- name: Save build artifacts
|
2022-10-28 21:52:39 +03:00
|
|
|
uses: actions/upload-artifact@v3
|
|
|
|
with:
|
2022-10-31 23:28:21 +03:00
|
|
|
name: build-${{ runner.os }}
|
|
|
|
path: target_releases/*
|
2021-10-12 17:56:45 +03:00
|
|
|
|
2022-10-31 23:28:21 +03:00
|
|
|
test:
|
|
|
|
name: Test builds on ${{ matrix.os }}
|
|
|
|
needs: [build]
|
|
|
|
runs-on: ${{ matrix.os }}
|
2022-10-22 20:39:05 +03:00
|
|
|
strategy:
|
2022-10-31 23:28:21 +03:00
|
|
|
fail-fast: true
|
2022-10-22 20:39:05 +03:00
|
|
|
matrix:
|
|
|
|
include:
|
|
|
|
- os: ubuntu-latest
|
|
|
|
bin: martin
|
|
|
|
name: martin-Linux-x86_64.tar.gz
|
|
|
|
- os: windows-latest
|
|
|
|
bin: martin.exe
|
|
|
|
name: martin-Windows-x86_64.zip
|
|
|
|
- os: macOS-latest
|
|
|
|
bin: martin
|
|
|
|
name: martin-Darwin-x86_64.tar.gz
|
|
|
|
steps:
|
2022-10-31 23:28:21 +03:00
|
|
|
- name: Checkout sources
|
2022-10-22 20:39:05 +03:00
|
|
|
uses: actions/checkout@v3
|
2022-10-31 23:28:21 +03:00
|
|
|
- name: Start postgres
|
|
|
|
uses: nyurik/action-setup-postgis@v1
|
|
|
|
id: pg
|
|
|
|
with:
|
|
|
|
username: test
|
|
|
|
password: test
|
|
|
|
database: test
|
|
|
|
rights: --superuser
|
|
|
|
- name: Init database
|
|
|
|
shell: bash
|
|
|
|
run: tests/fixtures/initdb.sh
|
|
|
|
env:
|
|
|
|
DATABASE_URL: ${{ steps.pg.outputs.connection-uri }}
|
|
|
|
- name: Unit Tests (Linux)
|
|
|
|
if: runner.os == 'Linux'
|
|
|
|
shell: bash
|
2022-10-22 20:39:05 +03:00
|
|
|
run: |
|
2022-10-31 23:28:21 +03:00
|
|
|
cargo test --all
|
|
|
|
rm -rf target
|
|
|
|
env:
|
|
|
|
DATABASE_URL: ${{ steps.pg.outputs.connection-uri }}
|
|
|
|
- uses: actions/download-artifact@v3
|
|
|
|
with:
|
|
|
|
name: build-${{ runner.os }}
|
|
|
|
path: target/
|
|
|
|
- name: Compare test output results (TODO)
|
|
|
|
if: false && runner.os == 'Linux'
|
|
|
|
run: |
|
|
|
|
# TODO: this test is currently broken
|
|
|
|
# the output of the tests is not deterministic
|
|
|
|
diff --brief --recursive --new-file tests/output tests/expected
|
|
|
|
- name: Save test output on failure (Linux)
|
|
|
|
if: failure() && runner.os == 'Linux'
|
|
|
|
uses: actions/upload-artifact@v3
|
|
|
|
with:
|
|
|
|
name: test-output
|
|
|
|
path: tests/output/*
|
|
|
|
retention-days: 5
|
|
|
|
- name: Test
|
|
|
|
shell: bash
|
|
|
|
run: |
|
|
|
|
if [[ "${{ runner.os }}" != "Windows" ]]; then
|
|
|
|
chmod +x target/${{ matrix.bin }}
|
|
|
|
fi
|
|
|
|
tests/test.sh
|
|
|
|
env:
|
|
|
|
DATABASE_URL: ${{ steps.pg.outputs.connection-uri }}
|
|
|
|
MARTIN_BUILD: "-"
|
|
|
|
MARTIN_BIN: target/${{ matrix.bin }}
|
|
|
|
- name: Package
|
|
|
|
shell: bash
|
|
|
|
run: |
|
|
|
|
cd target/
|
|
|
|
strip ${{ matrix.bin }}
|
|
|
|
if [[ "${{ runner.os }}" == "Windows" ]]; then
|
|
|
|
7z a ../${{ matrix.name }} ${{ matrix.bin }}
|
|
|
|
else
|
|
|
|
tar czvf ../${{ matrix.name }} ${{ matrix.bin }}
|
|
|
|
fi
|
|
|
|
cd -
|
|
|
|
- name: Generate SHA-256 (MacOS)
|
|
|
|
if: runner.os == 'macOS'
|
|
|
|
run: shasum -a 256 ${{ matrix.name }}
|
|
|
|
- name: Publish
|
|
|
|
if: startsWith(github.ref, 'refs/tags/')
|
|
|
|
uses: softprops/action-gh-release@v1
|
|
|
|
with:
|
|
|
|
draft: true
|
|
|
|
files: 'martin*'
|
|
|
|
body_path: CHANGELOG.md
|
|
|
|
env:
|
|
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|