Merge pull request #10 from hmac/hmac-native-tls-optional #48
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
name: Test | |
on: | |
push: | |
branches: [ main ] | |
pull_request: | |
branches: '*' | |
env: | |
CARGO_TERM_COLOR: always | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
continue-on-error: ${{ matrix.nightly }} | |
strategy: | |
fail-fast: false | |
matrix: | |
postgresql-version: [14] | |
toolchain: [ 'stable' ] | |
nightly: [false] | |
include: | |
- toolchain: 'nightly' | |
nightly: true | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Install rust tooling | |
run: | | |
rustup update ${{ matrix.toolchain }} | |
rustup component add --toolchain ${{ matrix.toolchain }} clippy rustfmt | |
- name: Print rust tooling information | |
run: | | |
rustup run ${{ matrix.toolchain }} rustc --version | |
rustup run ${{ matrix.toolchain }} cargo --version --verbose | |
rustup run ${{ matrix.toolchain }} cargo clippy --version | |
rustup run ${{ matrix.toolchain }} cargo fmt --version | |
- name: Install PostgreSQL client version matching docker-compose | |
env: | |
POSTGRESQL_VERSION: ${{ matrix.postgresql-version }} | |
run: | | |
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list' | |
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add - | |
sudo apt-get update | |
sudo apt-get -y install --no-install-recommends "postgresql-client-${POSTGRESQL_VERSION}" | |
- name: Cache cargo registry | |
uses: actions/cache@v3 | |
with: | |
path: | | |
~/.cargo/registry | |
~/.cargo/git | |
key: rust_${{ matrix.toolchain }}-cargo-${{ hashFiles('**/Cargo.toml') }} | |
- name: Run cargo fmt | |
run: rustup run ${{ matrix.toolchain }} cargo fmt --all -- --check | |
- name: Run test - sqlite | sqlx | runtime-async-std | macros | |
run: rustup run ${{ matrix.toolchain }} cargo test --features sqlite,sqlx,runtime-async-std,macros --all-targets --verbose | |
- name: Run test - sqlite | diesel | runtime-async-std | macros | |
run: rustup run ${{ matrix.toolchain }} cargo test --features sqlite,diesel,runtime-async-std,macros --all-targets --verbose | |
- name: Run test - sqlite | diesel | |
run: rustup run ${{ matrix.toolchain }} cargo test --features sqlite,diesel --all-targets --verbose | |
- name: Start containers for database tests | |
run: docker compose -f "docker-compose.yml" up -d | |
- name: Run test - mysql | diesel | |
run: rustup run ${{ matrix.toolchain }} cargo test --features mysql,diesel --all-targets --verbose | |
- name: Run test - mysql | sqlx | runtime-async-std | |
run: rustup run ${{ matrix.toolchain }} cargo test --features mysql,sqlx,runtime-async-std --all-targets --verbose | |
- name: Run test - postgres | diesel | |
run: | | |
rustup run ${{ matrix.toolchain }} cargo test --features postgres,diesel --all-targets --verbose | |
psql "postgresql://root:@127.0.0.1:5432/postgres" -c "DROP TABLE __diesel_schema_migrations,diesel_users" | |
- name: Run test - postgres | sqlx | runtime-async-std | |
run: | | |
export PATH="/usr/lib/postgresql/${POSTGRESQL_VERSION}/bin:$PATH" | |
rustup run ${{ matrix.toolchain }} cargo test --features postgres,sqlx,runtime-async-std --all-targets --verbose | |
psql "postgresql://root:@127.0.0.1:5432/postgres" -c "DROP TABLE _sqlx_migrations,sqlx_users" | |
- name: Stop containers for database tests | |
if: always() | |
run: | | |
docker compose -f "docker-compose.yml" down --volumes | |
sudo rm -rf .data/{postgresql-${POSTGRESQL_VERSION},mysql-8} | |
- name: Run doc tests | |
run: rustup run ${{ matrix.toolchain }} cargo test --features sqlite,sqlx,runtime-async-std,macros --doc --verbose | |
- name: Run clippy | |
run: rustup run ${{ matrix.toolchain }} cargo clippy --features sqlite,sqlx,runtime-async-std,macros -- -Dwarnings | |