Bake example scripts into eugene
executable and improve demo
#286
Workflow file for this run
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: Tests | |
on: | |
pull_request: | |
branches: | |
- main | |
push: | |
branches: | |
- main | |
env: | |
CARGO_TERM_COLOR: always | |
RUST_BACKTRACE: "1" | |
jobs: | |
run_tests_ubuntu: | |
runs-on: ubuntu-latest | |
name: Test postgres-${{ matrix.pgversion }} | |
strategy: | |
matrix: | |
pgversion: | |
- "12" | |
- "13" | |
- "14" | |
- "15" | |
- "16" | |
env: | |
PGPASS: postgres | |
services: | |
postgres: | |
image: postgres:${{ matrix.pgversion }} | |
ports: | |
- 5432:5432 | |
env: | |
POSTGRES_USER: postgres | |
POSTGRES_PASSWORD: postgres | |
POSTGRES_DB: postgres | |
TZ: UTC | |
options: >- | |
--health-cmd="pg_isready -U postgres" --health-interval=10s --health-timeout=5s --health-retries=5 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Cache Cargo registry | |
uses: actions/cache@v3 | |
with: | |
path: | | |
~/.cargo/registry/index | |
~/.cargo/registry/cache | |
~/.cargo/git/db | |
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }} | |
restore-keys: | | |
${{ runner.os }}-cargo-registry- | |
- name: Cache Cargo build | |
uses: actions/cache@v2 | |
with: | |
path: target | |
key: ${{ runner.os }}-cargo-build-${{ hashFiles('**/Cargo.lock') }} | |
restore-keys: | | |
${{ runner.os }}-cargo-build- | |
- name: Set up psql | |
run: sudo apt-get install -y postgresql-client postgresql | |
- name: Make ~/.pgpass | |
run: echo "localhost:5432:*:postgres:$PGPASS" > ~/.pgpass && chmod 600 ~/.pgpass | |
- name: Init testdb | |
run: psql --host localhost --port 5432 -U postgres < db-initscripts/init-testdb.sql | |
- name: Put postgres binaries on PATH for tests | |
run: echo "/usr/lib/postgresql/14/bin" >> $GITHUB_PATH | |
- name: Run tests | |
env: | |
TZ: UTC | |
RUST_LOG: eugene=trace | |
run: cargo test --all-targets --all-features | |
run_tests_macos: | |
name: Test on macos | |
runs-on: macos-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Cache Cargo registry | |
uses: actions/cache@v3 | |
with: | |
path: | | |
~/.cargo/registry/index | |
~/.cargo/registry/cache | |
~/.cargo/git/db | |
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }} | |
restore-keys: | | |
${{ runner.os }}-cargo-registry- | |
- name: Cache Cargo build | |
uses: actions/cache@v2 | |
with: | |
path: target | |
key: ${{ runner.os }}-cargo-build-${{ hashFiles('**/Cargo.lock') }} | |
restore-keys: | | |
${{ runner.os }}-cargo-build- | |
- name: Install psql and postgres | |
run: brew install postgresql | |
- name: Init postgres db | |
env: | |
TZ: UTC | |
run: | | |
initdb -E UTF-8 -U postgres $HOME/pgdata | |
pg_ctl -D $HOME/pgdata start | |
- name: Give postgres time to start | |
run: sleep 10 | |
- name: Set up ~/.pgpass | |
run: | | |
psql -U postgres -c "ALTER USER postgres WITH PASSWORD 'postgres';" | |
echo "localhost:5432:*:postgres:postgres" > ~/.pgpass && chmod 600 ~/.pgpass | |
- name: Init testdb | |
run: psql -U postgres < db-initscripts/init-testdb.sql | |
- name: Run tests | |
env: | |
TZ: UTC | |
RUST_LOG: eugene=trace | |
run: cargo test --all-targets --all-features | |
- name: Stop postgres | |
run: pg_ctl -D $HOME/pgdata stop | |
run_tests_windows: | |
name: Test on Windows | |
runs-on: windows-latest | |
env: | |
GIT_CRLFAUTOCONVERT: false | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Cache Cargo registry | |
uses: actions/cache@v3 | |
with: | |
path: | | |
~/.cargo/registry/index | |
~/.cargo/registry/cache | |
~/.cargo/git/db | |
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }} | |
restore-keys: | | |
${{ runner.os }}-cargo-registry- | |
- name: Cache Cargo build | |
uses: actions/cache@v2 | |
with: | |
path: target | |
key: ${{ runner.os }}-cargo-build-${{ hashFiles('**/Cargo.lock') }} | |
restore-keys: | | |
${{ runner.os }}-cargo-build- | |
- name: Cache postgres install | |
uses: actions/cache@v3 | |
with: | |
path: C:\Program Files\PostgreSQL\16 | |
key: ${{ runner.os }}-postgres-install | |
restore-keys: | | |
${{ runner.os }}-postgres-install | |
- name: Install postgres with choco | |
shell: bash | |
env: | |
TZ: UTC | |
run: | | |
choco install postgresql16 --params "/Password:postgres" | |
echo 'C:\Program Files\PostgreSQL\16\bin' >> $GITHUB_PATH | |
echo 'C:\Program Files\PostgreSQL\16\lib' >> $GITHUB_PATH | |
- name: Start postgres service | |
shell: pwsh | |
run: Start-Service postgresql-x64-16 | |
- name: Give postgres time to start | |
shell: pwsh | |
run: Start-Sleep -s 10 | |
- name: Init testdb | |
shell: bash | |
env: | |
PGPASSWORD: postgres | |
run: | | |
mkdir -p $APPDATA/postgresql | |
echo "localhost:5432:*:postgres:postgres" > $APPDATA/postgresql/pgpass.conf | |
psql -U postgres < db-initscripts/init-testdb.sql | |
- name: Run tests | |
env: | |
TZ: UTC | |
RUST_LOG: eugene=trace | |
run: cargo test --all-targets --all-features |