Files

104 lines
3.5 KiB
YAML

name: CI
on:
push:
branches: [main]
pull_request:
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: actions/setup-go@v7
with:
go-version: "1.26"
- name: Check formatting
run: |
unformatted=$(gofmt -l .)
if [ -n "$unformatted" ]; then
echo "The following files are not gofmt-formatted:"
echo "$unformatted"
exit 1
fi
- name: Vet
run: go vet ./...
- name: Build
run: go build ./...
- name: Test
run: go test -race -count=1 -timeout 20m ./...
# The `test` job above runs everything on in-memory SQLite, which silently
# drops SELECT ... FOR UPDATE and therefore cannot prove row-lock
# serialization or multi-replica fork/join convergence. The two jobs below
# run those tests against real servers.
#
# Both jobs run test/multiinstance (two engines sharing one DB, real row
# locks) plus the real-DB FOR UPDATE test in service/instance_lock_test.go.
# test/e2e still runs on in-memory SQLite in the `test` job above, so it is
# not repeated here.
# The lock tests create and drop their own gflow_locktest database, so only a
# reachable server is required (the service DB below is just the base DSN).
postgres-test:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:16
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: gflow_engine_pgtest
ports:
- 5432:5432
options: >-
--health-cmd "pg_isready -U postgres"
--health-interval 5s
--health-timeout 5s
--health-retries 10
steps:
- uses: actions/checkout@v7
- uses: actions/setup-go@v7
with:
go-version: "1.26"
- name: Multi-replica fork/join test (postgres)
env:
GFLOW_MULTI_DB_DRIVER: postgres
GFLOW_MULTI_PG_DSN: "postgres://postgres:postgres@127.0.0.1:5432/gflow_engine_pgtest?sslmode=disable"
run: go test -race -count=1 -v ./test/multiinstance/
- name: Real-DB row-lock test (postgres)
env:
TEST_PG_DSN: "host=127.0.0.1 user=postgres password=postgres dbname=gflow_engine_pgtest port=5432 sslmode=disable"
run: go test -race -count=1 -v -run TestWithInstanceTx_RealDB_ForUpdateSerializes ./service/
mysql-test:
runs-on: ubuntu-latest
services:
mysql:
image: mysql:8
env:
MYSQL_ROOT_PASSWORD: root
MYSQL_ROOT_HOST: "%"
MYSQL_DATABASE: gflow_engine_mysqltest
ports:
- 3306:3306
options: >-
--health-cmd "mysqladmin ping -proot"
--health-interval 5s
--health-timeout 5s
--health-retries 10
steps:
- uses: actions/checkout@v7
- uses: actions/setup-go@v7
with:
go-version: "1.26"
- name: Multi-replica fork/join test (mysql)
env:
GFLOW_MULTI_DB_DRIVER: mysql
GFLOW_MULTI_MYSQL_DSN: "root:root@tcp(127.0.0.1:3306)/gflow_engine_mysqltest?charset=utf8mb4&parseTime=True&loc=Local"
run: go test -race -count=1 -v ./test/multiinstance/
- name: Real-DB row-lock test (mysql)
env:
TEST_MYSQL_DSN: "root:root@tcp(127.0.0.1:3306)/gflow_engine_mysqltest?charset=utf8mb4&parseTime=True&loc=Local"
run: go test -race -count=1 -v -run TestWithInstanceTx_RealDB_ForUpdateSerializes ./service/