Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 21 additions & 3 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,97 +64,115 @@
run: make bench ITERATIONS=1

build_and_test:
name: build_and_test (${{ matrix.go-version }}, ${{ matrix.postgres-version }}${{ matrix.primary && ', race' || '' }})
env:
# The special value "local" tells Go to use the bundled Go version rather
# than trying to fetch one according to a `toolchain` value in `go.mod`.
# This ensures that we're really running the Go version in the CI matrix
# rather than one that the Go command has upgraded to automatically.
GOTOOLCHAIN: local
runs-on: ubuntu-latest
strategy:
matrix:
include:
# Run the latest Go version against all supported Postgres versions:
# Run the latest Go version against all supported Postgres versions.
# Only the newest Go/Postgres combination runs with the race detector.
- go-version: "1.27"
postgres-version: 18
primary: true
- go-version: "1.27"
postgres-version: 17
- go-version: "1.27"
postgres-version: 16
- go-version: "1.27"
postgres-version: 15
- go-version: "1.27"
postgres-version: 14

# Also run the previous Go version (the Go version previous to current
# is the only other officially supported Go version) against the
# latest Postgres version:
- go-version: "1.26"
postgres-version: 18
fail-fast: false
timeout-minutes: 5

services:
postgres:
image: postgres:${{ matrix.postgres-version }}
env:
# Left as a reminder that it might not be a bad idea to increase max
# connections and then increase the maximum allowed in the databaes
# pools for each package under tests. This config is only supported on
# Postgres 16+ though, and changing Postgres configuration on any
# version before that is absurdly difficult through Docker, so it
# might be worth just waiting until <16 have rolled off.
# POSTGRES_INITDB_ARGS: "-c max_connections=1500"
POSTGRES_PASSWORD: postgres
options: >-
--health-cmd pg_isready
--health-interval 2s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432

steps:
- uses: actions/checkout@v6

- name: Setup Go ${{ matrix.go-version }}
uses: actions/setup-go@v6
with:
go-version: ${{ matrix.go-version }}

- name: Display Go version
run: go version

- name: Set up database
run: psql -c "CREATE DATABASE river_test" $ADMIN_DATABASE_URL

- name: Test
- name: Test with race detector
if: matrix.primary
run: make test/race TEST_DATABASE=postgres

- name: Test
if: ${{ !matrix.primary }}
run: make test TEST_DATABASE=postgres

build_and_test_sqlite:

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}
name: build_and_test_sqlite (${{ matrix.go-version }}${{ matrix.primary && ', race' || '' }})
env:
GOTOOLCHAIN: local
runs-on: ubuntu-latest
strategy:
matrix:
# Keep both supported Go versions covered without repeating SQLite,
# libSQL, and Turso tests for every PostgreSQL version.
go-version: ["1.27", "1.26"]
include:
# Only the newest Go version runs with the race detector.
- go-version: "1.27"
primary: true
fail-fast: false
timeout-minutes: 5

steps:
- uses: actions/checkout@v6

- name: Setup Go ${{ matrix.go-version }}
uses: actions/setup-go@v6
with:
go-version: ${{ matrix.go-version }}

- name: Test
- name: Test with race detector
if: matrix.primary
run: make test/race TEST_DATABASE=sqlite

- name: Test
if: ${{ !matrix.primary }}
run: make test TEST_DATABASE=sqlite

cli:

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
Expand Down
17 changes: 12 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,17 @@ TEST_DATABASE ?= all

# Only filter the shared driver suite. Other packages have SQLite-named tests
# that use PostgreSQL or mocks and should stay in the regular test run.
sqlite_test_pattern := '^(Test.*(LibSQL|SQLite|Turso)|Example_(libSQL|sqlite|turso))'
sqlite_test_pattern := ^(Test.*(LibSQL|SQLite|Turso)|Example_(libSQL|sqlite|turso))
test_submodules := $(submodules)
legacy_driver_test_flags := -run '/WithTx$$'
ifeq ($(TEST_DATABASE),postgres)
test_submodules := $(filter-out %/riverdriver/riversqlite,$(submodules))
driver_test_flags := -skip $(sqlite_test_pattern)
driver_test_flags := -skip '$(sqlite_test_pattern)'
legacy_driver_test_flags += -skip '$(sqlite_test_pattern)'
else ifeq ($(TEST_DATABASE),sqlite)
test_submodules := $(filter %/riverdriver/riverdrivertest %/riverdriver/riversqlite,$(submodules))
driver_test_flags := -run $(sqlite_test_pattern)
driver_test_flags := -run '$(sqlite_test_pattern)'
legacy_driver_test_flags := -run '$(sqlite_test_pattern)/WithTx$$'
else ifneq ($(TEST_DATABASE),all)
$(error TEST_DATABASE must be all, postgres, or sqlite)
endif
Expand All @@ -77,8 +80,10 @@ endef
$(foreach mod,$(test_submodules),$(eval $(call test-target,$(mod))))

# Exercise the temporary savepoint fallback as well as default transaction reuse.
test:: ; cd ./riverdriver/riverdrivertest && RIVER_USE_LEGACY_SUBTRANSACTIONS=1 go test . -run '/WithTx$$' -timeout 2m
test:: ; cd ./riverdriver/riverdrivertest && RIVER_USE_LEGACY_SUBTRANSACTIONS=1 go test . $(legacy_driver_test_flags) -timeout 2m
ifneq ($(TEST_DATABASE),sqlite)
test:: ; cd ./riverdriver/riverdrivertest && RIVER_USE_LEGACY_SUBTRANSACTIONS=1 go test . -run '^TestDriverRiverPgxV5$$/.*/WithTx$$' -timeout 2m
endif

.PHONY: test/race
test/race:: ## Run tests with race detector (TEST_DATABASE=all, postgres, or sqlite)
Expand All @@ -87,8 +92,10 @@ define test-race-target
endef
$(foreach mod,$(test_submodules),$(eval $(call test-race-target,$(mod))))

test/race:: ; cd ./riverdriver/riverdrivertest && RIVER_USE_LEGACY_SUBTRANSACTIONS=1 go test . -race -run '/WithTx$$' -timeout 2m
test/race:: ; cd ./riverdriver/riverdrivertest && RIVER_USE_LEGACY_SUBTRANSACTIONS=1 go test . -race $(legacy_driver_test_flags) -timeout 2m
ifneq ($(TEST_DATABASE),sqlite)
test/race:: ; cd ./riverdriver/riverdrivertest && RIVER_USE_LEGACY_SUBTRANSACTIONS=1 go test . -race -run '^TestDriverRiverPgxV5$$/.*/WithTx$$' -timeout 2m
endif

.PHONY: bench
bench:: ## Run benchmarks in each submodule (ITERATIONS=100)
Expand Down
3 changes: 2 additions & 1 deletion docs/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ To run the regular suite with the SQLite driver tests excluded:

`TEST_DATABASE` also applies to `make test/race`. CI separates these suites so
the PostgreSQL version matrix doesn't repeat the SQLite tests. Each suite still
runs on both supported Go versions.
runs on both supported Go versions. Only the latest combination in each matrix
uses the race detector, marked `race` in its job title.

## Run lint

Expand Down
Loading