Skip to content

Commit

Permalink
add postgres and mysql tests back to CI
Browse files Browse the repository at this point in the history
resolves #1238
  • Loading branch information
nickysemenza committed Oct 3, 2022
1 parent d4488a8 commit a9a2c2e
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 5 deletions.
41 changes: 38 additions & 3 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,45 @@ jobs:
strategy:
matrix:
go: ["1.18", "1.19"]
services:
# Label used to access the service container
postgres:
# Docker Hub image
image: postgres
# Provide the password for postgres
env:
POSTGRES_DB: postgres_db
POSTGRES_PASSWORD: ""
POSTGRES_HOST_AUTH_METHOD: trust # allow no password
POSTGRES_PORT: 5432
POSTGRES_USER: postgres
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
mysql:
image: mysql
env:
MYSQL_ALLOW_EMPTY_PASSWORD: yes
MYSQL_ROOT_PASSWORD: ""
ports:
- 3306:3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3

env:
GOFLAGS: "-mod=vendor"
GODEBUG: "x509sha1=1"
BUILD_TAGS: "postgresql"
PGHOST: localhost
MYSQL_HOST: 127.0.0.1
steps:
- run: psql -c 'create database certdb_development;' -U postgres;
- run: mysql -e 'create database certdb_development;' -u root;
- run: mysql -e 'SET global sql_mode = 0;' -u root;
- uses: actions/checkout@v2

- name: Set up Go
Expand All @@ -24,11 +59,11 @@ jobs:

- name: Build
run: go build -v ./...

- run: make bin/goose;
- run: ./bin/goose -path certdb/pg up;
- run: ./bin/goose -path certdb/mysql up;
- name: Test
run: ./test.sh
# todo: these Actions tests still need to be updated to run the database tests
# that used to run in travis
- uses: codecov/codecov-action@v3

golangci:
Expand Down
2 changes: 1 addition & 1 deletion certdb/pg/dbconf.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
development:
driver: postgres
open: dbname=certdb_development sslmode=disable
open: dbname=certdb_development sslmode=disable user=postgres

test:
driver: postgres
Expand Down
2 changes: 1 addition & 1 deletion certdb/testdb/testdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func MySQLDB() *sqlx.DB {

// PostgreSQLDB returns a PostgreSQL db instance for certdb testing.
func PostgreSQLDB() *sqlx.DB {
connStr := "dbname=certdb_development sslmode=disable"
connStr := "dbname=certdb_development sslmode=disable user=postgres"

if dbURL := os.Getenv("DATABASE_URL"); dbURL != "" {
connStr = dbURL
Expand Down

0 comments on commit a9a2c2e

Please sign in to comment.