Specify resolver for workspace (#206) #619
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Github workflow files do not support YAML anchors. | |
name: CI | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
env: | |
CARGO_TERM_COLOR: always | |
jobs: | |
check: | |
name: Check / Linux | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v1 | |
- uses: actions-rs/toolchain@v1 | |
id: toolchain | |
with: | |
profile: minimal | |
toolchain: stable | |
- name: Chown cargo registry because of caching | |
run: sudo chown -R runner ~/.cargo/registry | |
- name: Cache cargo registry and target | |
uses: actions/cache@v2 | |
with: | |
path: | | |
~/.cargo/registry | |
target | |
key: linux-check-${{ steps.toolchain.outputs.rustc_hash }}-cargo-${{ hashFiles('**/Cargo.lock') }} | |
- name: Check | |
uses: actions-rs/cargo@v1 | |
with: | |
command: check | |
- name: Cleanup for caching | |
uses: actions-rs/cargo@v1 | |
with: | |
command: clean | |
args: --package pg_datanymizer | |
if: steps.cache-target.outputs.cache-hit != 'true' | |
fmt: | |
name: Rustfmt / Linux | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v1 | |
- uses: actions-rs/toolchain@v1 | |
with: | |
profile: minimal | |
toolchain: stable | |
components: rustfmt | |
- uses: actions-rs/cargo@v1 | |
with: | |
command: fmt | |
args: --all -- --check | |
clippy: | |
name: Clippy / Linux | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v1 | |
- uses: actions-rs/toolchain@v1 | |
id: toolchain | |
with: | |
profile: minimal | |
toolchain: stable | |
components: clippy | |
- name: Chown cargo registry because of caching | |
run: sudo chown -R runner ~/.cargo/registry | |
- name: Cache cargo registry and target | |
uses: actions/cache@v2 | |
with: | |
path: | | |
~/.cargo/registry | |
target | |
key: clippy-linux-${{ steps.toolchain.outputs.rustc_hash }}-cargo-${{ hashFiles('**/Cargo.lock') }} | |
- name: Check with Clippy | |
uses: actions-rs/cargo@v1 | |
with: | |
command: clippy | |
args: -- -D warnings | |
- name: Cleanup for caching | |
uses: actions-rs/cargo@v1 | |
with: | |
command: clean | |
args: --package pg_datanymizer | |
if: steps.cache-target.outputs.cache-hit != 'true' | |
test: | |
name: Test and coverage / Linux | |
runs-on: ubuntu-latest | |
env: | |
postgres_password: 'pgpass' | |
postgres_port: 5432 | |
postgres_version: 14 | |
steps: | |
- name: Run Postges (with Docker) | |
# requires the `server.crt` file for TLS support | |
run: | | |
docker run -d -p 127.0.0.1:${{ env.postgres_port }}:5432 -e POSTGRES_PASSWORD=${{ env.postgres_password }} \ | |
postgres:${{ env.postgres_version }} | |
- uses: actions/checkout@v1 | |
- uses: actions-rs/toolchain@v1 | |
id: toolchain | |
with: | |
profile: minimal | |
toolchain: nightly | |
override: true | |
- name: Chown cargo registry because of caching | |
run: sudo chown -R runner ~/.cargo/registry | |
- name: Set grcov version | |
run: echo "GRCOV_VERSION=$(cargo search --limit 1 grcov | head -n1 | cut -d '"' -f2)" >> $GITHUB_ENV | |
- name: Cache cargo registry, target, and grcov binary | |
id: test-grcov | |
uses: actions/cache@v2 | |
with: | |
path: | | |
~/.cargo/registry | |
~/.cargo/bin/grcov | |
target | |
key: grcov-${{ steps.toolchain.outputs.rustc_hash }}-cargo-${{ hashFiles('**/Cargo.lock') }}-${{ env.GRCOV_VERSION }} | |
- name: Install grcov | |
run: | | |
cargo install --version $GRCOV_VERSION grcov | |
if: steps.test-grcov.outputs.cache-hit != 'true' | |
- name: Clean coverage | |
run: | | |
rm -f target/debug/deps/*.gcda | |
rm -f target/debug/deps/*.gcno | |
- name: Run tests | |
uses: actions-rs/cargo@v1 | |
with: | |
command: test | |
args: --all-features #--no-fail-fast | |
env: | |
CARGO_INCREMENTAL: '0' | |
DATANYMIZER_TEST_PG_DB: | | |
postgres://postgres:${{ env.postgres_password }}@localhost:${{ env.postgres_port }}/datanymizer_test | |
RUSTFLAGS: | | |
-Zprofile -Zpanic_abort_tests -Ccodegen-units=1 -Clink-dead-code -Coverflow-checks=off | |
- uses: actions-rs/grcov@v0.1 | |
- uses: codecov/codecov-action@v1 | |
with: | |
file: ./lcov.info | |
- name: Cleanup for caching | |
uses: actions-rs/cargo@v1 | |
with: | |
command: clean | |
args: --package pg_datanymizer | |
if: steps.cache-target.outputs.cache-hit != 'true' | |
test_demo: | |
name: Test demo | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v1 | |
- name: Bootstrap demo, make a dump file, ensure that it is not empty | |
run: | | |
cd demo | |
make bootstrap | |
make dump | |
([[ -s /tmp/fake_dump.sql ]] && echo "The dump file exists and is not empty") || (echo "No dump file or it is empty" && exit 1) | |
- name: Restore the dump and check the data | |
run: | | |
cd demo | |
make restore_dump | |
make check_data | |
linux_build: | |
name: Build / Linux | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v1 | |
- uses: actions-rs/toolchain@v1 | |
id: toolchain | |
with: | |
profile: minimal | |
toolchain: stable | |
- name: Chown cargo registry because of caching | |
run: sudo chown -R runner ~/.cargo/registry | |
- name: Cache cargo registry and target | |
uses: actions/cache@v2 | |
with: | |
path: | | |
~/.cargo/registry | |
target | |
key: build-linux-${{ steps.toolchain.outputs.rustc_hash }}-cargo-${{ hashFiles('**/Cargo.lock') }} | |
- name: Build | |
uses: actions-rs/cargo@v1 | |
with: | |
command: build | |
- name: Cleanup for caching | |
uses: actions-rs/cargo@v1 | |
with: | |
command: clean | |
args: --package pg_datanymizer | |
if: steps.cache-target.outputs.cache-hit != 'true' | |
windows_build: | |
name: Build / Windows | |
runs-on: windows-latest | |
steps: | |
- uses: actions/checkout@v1 | |
- uses: actions-rs/toolchain@v1 | |
id: toolchain | |
with: | |
profile: minimal | |
toolchain: stable | |
- name: Cache cargo registry and target | |
uses: actions/cache@v2 | |
with: | |
path: | | |
~/.cargo/registry | |
target | |
key: build-windows-${{ steps.toolchain.outputs.rustc_hash }}-cargo-${{ hashFiles('**/Cargo.lock') }} | |
- name: Build | |
uses: actions-rs/cargo@v1 | |
with: | |
command: build | |
- name: Cleanup for caching | |
uses: actions-rs/cargo@v1 | |
with: | |
command: clean | |
args: --package pg_datanymizer | |
if: steps.cache-target.outputs.cache-hit != 'true' | |
docker_build: | |
name: Build / Docker | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v1 | |
- name: Build | |
run: docker build --target builder . |