Skip to content

Commit

Permalink
Bootstrap GHA
Browse files Browse the repository at this point in the history
  • Loading branch information
pete-woods committed Apr 9, 2024
1 parent 7e11d57 commit a54816b
Show file tree
Hide file tree
Showing 3 changed files with 117 additions and 0 deletions.
103 changes: 103 additions & 0 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
name: Go

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

jobs:
test:
runs-on: ubuntu-latest

services:

mysql:
image: mysql
env:
MYSQL_ROOT_PASSWORD: root-password
MYSQL_DATABASE: dbname
MYSQL_USER: user
MYSQL_PASSWORD: password
options: >-
--health-cmd "mysqladmin ping --silent"
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 3306:3306

postgres:
image: postgres
env:
POSTGRES_DB: dbname
POSTGRES_USER: user
POSTGRES_PASSWORD: password
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432

redis:
image: redis
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 6379:6379

steps:
- uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.20'

- name: Test
run: go test -race -v ./...

- name: Run postgres migrations
run: psql -f pgxstore/testdata/schema.sql postgres://user:password@localhost:5432/dbname

- name: Run mysql migrations
run: mysql --protocol=TCP --host=localhost --port=3306 --user=user --password=password dbname < mysqlstore/testdata/schema.sql

- name: Test goredisstore
env:
SCS_REDIS_TEST_DSN: redis://localhost:6379
working-directory: goredisstore
run: go test -race -v ./...

- name: Test mysqlstore
env:
SCS_MYSQL_TEST_DSN: user:password@tcp(localhost:3306)/dbname
working-directory: mysqlstore
run: go test -race -v ./...

- name: Test pgxstore
env:
SCS_POSTGRES_TEST_DSN: postgres://user:password@localhost:5432/dbname
working-directory: pgxstore
run: go test -race -v ./...

- name: Test postgresstore
env:
SCS_POSTGRES_TEST_DSN: postgres://user:password@localhost:5432/dbname?sslmode=disable
working-directory: postgresstore
run: go test -race -v ./...

- name: Test redisstore
env:
SCS_REDIS_TEST_DSN: localhost:6379
working-directory: redisstore
run: go test -race -v ./...

- name: Test sqlite3store
working-directory: sqlite3store
run: go test -race -v ./...
7 changes: 7 additions & 0 deletions mysqlstore/testdata/schema.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
CREATE TABLE sessions (
token CHAR(43) PRIMARY KEY,
data BLOB NOT NULL,
expiry TIMESTAMP(6) NOT NULL
);

CREATE INDEX sessions_expiry_idx ON sessions (expiry);
7 changes: 7 additions & 0 deletions pgxstore/testdata/schema.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
CREATE TABLE sessions (
token TEXT PRIMARY KEY,
data BYTEA NOT NULL,
expiry TIMESTAMPTZ NOT NULL
);

CREATE INDEX sessions_expiry_idx ON sessions (expiry);

0 comments on commit a54816b

Please sign in to comment.