sqlx/.github/workflows/postgres.yml
Ryan Leckey fe827a3337
Tweak CI and enable for PRs
* Tweak cache strategy for Rust

* Tweak cache strategy some more

* ci: trigger

* Tweak the rest of the CI tasks
2020-01-06 23:55:11 -08:00

64 lines
1.7 KiB
YAML

name: Postgres
on:
pull_request:
push:
branches:
- master
jobs:
postgres:
runs-on: ubuntu-latest
strategy:
matrix:
postgres: [9.4.25, 10.11, 12.1]
services:
postgres:
image: postgres:${{ matrix.postgres }}
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: postgres
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:
- uses: actions/checkout@v1
# Rust ------------------------------------------------
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
if: steps.cache_rust.outputs.cache-hit != 'true'
with:
toolchain: stable
profile: minimal
override: true
- name: Cache target/
uses: actions/cache@v1
with:
path: target
key: ${{ runner.os }}-cargo-build-target-postgres-${{ hashFiles('**/Cargo.lock') }}
# -----------------------------------------------------
- run: cargo test -p sqlx --no-default-features --features 'postgres macros uuid chrono'
env:
DATABASE_URL: postgres://postgres:postgres@localhost:${{ job.services.postgres.ports[5432] }}/postgres
# Rust ------------------------------------------------
- name: Prepare build directory for cache
run: |
find ./target/debug -maxdepth 1 -type f -delete \
&& rm -fr ./target/debug/{deps,.fingerprint}/*sqlx* \
&& rm -f ./target/.rustc_info.json
# -----------------------------------------------------