1
Fork 0

Setup databases for github actions tests

This commit is contained in:
viktorstrate 2021-04-23 20:52:55 +02:00
parent 60f8a68bf6
commit 5ca4bd43ba
No known key found for this signature in database
GPG Key ID: 3F855605109C1E8A
4 changed files with 54 additions and 3 deletions

2
.github/mysql.testing.env vendored Normal file
View File

@ -0,0 +1,2 @@
PHOTOVIEW_DATABASE_DRIVER=mysql
PHOTOVIEW_MYSQL_URL='photoview:photosecret@tcp(mariadb)/photoview_test'

2
.github/postgres.testing.env vendored Normal file
View File

@ -0,0 +1,2 @@
PHOTOVIEW_DATABASE_DRIVER=postgres
PHOTOVIEW_POSTGRES_URL='photoview:photosecret@tcp(postgres)/photoview_test'

2
.github/sqlite.testing.env vendored Normal file
View File

@ -0,0 +1,2 @@
PHOTOVIEW_DATABASE_DRIVER=sqlite
PHOTOVIEW_SQLITE_PATH=photoview_test.db

View File

@ -11,15 +11,44 @@ jobs:
name: Test API
runs-on: ubuntu-20.04
strategy:
matrix:
database: ['mysql', 'postgres', 'sqlite']
services:
mariadb:
image: mariadb:10.5
env:
MYSQL_DATABASE: photoview_test
MYSQL_USER: photoview
MYSQL_PASSWORD: photosecret
options: >-
--health-cmd="mysqladmin ping"
--health-interval=10s
--health-timeout=5s
--health-retries=5
postgres:
images: postgres:13.2
env:
POSTGRES_USER: photoview
POSTGRES_PASSWORD: photosecret
POSTGRES_DB: photoview_test
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
defaults:
run:
working-directory: api
steps:
- name: Set up Go 1.x
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: ^1.13
go-version: ^1.16
id: go
- name: Check out code into the Go module directory
@ -43,8 +72,24 @@ jobs:
- name: Build
run: go build -v .
- name: Configure MySQL
if: ${{ matrix.database == 'mysql' }}
run: |
cp ../.github/mysql.testing.env testing.env
- name: Configure Postgres
if: ${{ matrix.database == 'postgres' }}
run: |
cp ../.github/postgres.testing.env testing.env
- name: Configure Sqlite
if: ${{ matrix.database == 'sqlite' }}
run: |
touch photoview_test.db
cp ../.github/sqlite.testing.env testing.env
- name: Test
run: go test -v ./...
run: go test ./... -v -database -filesystem -p 1
test-ui:
name: Test UI