Skip to content

test: fix integration tests to run against both SQLite and Postgres in CI #20

test: fix integration tests to run against both SQLite and Postgres in CI

test: fix integration tests to run against both SQLite and Postgres in CI #20

Workflow file for this run

name: verify
on:
push:
branches: [ "main", "master" ]
pull_request:
branches: [ "main", "master" ]
jobs:
integration-tests:
name: Run Integration Tests
runs-on: ubuntu-latest
services:
postgres:
image: postgres:16-alpine
env:
POSTGRES_USER: testuser
POSTGRES_PASSWORD: testpassword
POSTGRES_DB: valkyrie_test
ports:
- 5432:5432
options: >-
--health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
cache: true
cache-dependency-path: '**/go.sum'
- name: Vet packages
run: make vet
- name: Run compiler unit tests
run: make test
- name: Run SQLite Integration Tests
run: make integration-test
- name: Run Postgres Integration Tests
run: |
PG_URL="${{ secrets.PG_DATABASE_URL }}"
if [ -z "$PG_URL" ]; then
PG_URL="postgres://testuser:testpassword@localhost:5432/valkyrie_test?sslmode=disable"
fi
sed -i 's/provider = "sqlite"/provider = "postgres"/' integration/schema.prisma
rm -f integration/valkyrie/migrations/*.sql
make integration-gen
cd integration
../bin/valkyrie migrate -u "$PG_URL" init_pg
PG_DATABASE_URL="$PG_URL" go test -v ./...