Skip to content

Commit

Permalink
ci(actions): add a way to run mysql in a service
Browse files Browse the repository at this point in the history
  • Loading branch information
danvergara committed May 8, 2021
1 parent 9edad16 commit 4a84df4
Showing 1 changed file with 14 additions and 59 deletions.
73 changes: 14 additions & 59 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ name: Run Integration Tests
on: [push, pull_request]

jobs:
postgres-test:
name: Postgres Tests
integration-test:
name: Integration Tests
strategy:
matrix:
os: [ubuntu-latest]
Expand All @@ -26,47 +26,6 @@ jobs:
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
# The steps that will be run through for each version and platform combination.
- name: Set up Go ${{ matrix.goVer }}
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.goVer }}
# Checks out our code locally so we can work with the files.
- name: Checkout code
uses: actions/checkout@v2
# Caches downloaded modules
- uses: actions/cache@v2
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
# Runs go test ./... against postgres container
- name: Test Postgres
run: |
go run cmd/dbmigrate/main.go
go run cmd/seeder/main.go seed
go test -v ./...
env:
DB_USER: postgres
DB_PASSWORD: password
DB_HOST: localhost
DB_PORT: 5432
DB_NAME: users
DB_DRIVER: postgres

mysql-test:
name: MySQL Tests
strategy:
matrix:
os: [ubuntu-latest]
goVer: [1.13, 1.14, 1.15, 1.16]
# Defines the platform for each test run.
runs-on: ${{ matrix.os }}
# define the container services used to run integration tests
services:
mysql:
image: mysql:8
env:
Expand All @@ -79,15 +38,6 @@ jobs:
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3

steps:
# - name: Set up MySQL
# run: |
# sudo /etc/init.d/mysql start
# mysql -e 'CREATE DATABASE ${{ env.DB_DATABASE }};' -u${{ env.DB_USER }} -p${{ env.DB_PASSWORD }}
# env:
# DB_DATABASE: users
# DB_USER: root
# DB_PASSWORD: root

# The steps that will be run through for each version and platform combination.
- name: Set up Go ${{ matrix.goVer }}
uses: actions/setup-go@v2
Expand All @@ -104,19 +54,24 @@ jobs:
restore-keys: |
${{ runner.os }}-go-
- name: Migrate db
run: go run cmd/dbmigrate/main.go
# Runs go test ./... against postgres container
- name: Test Postgres
run: |
go run cmd/dbmigrate/main.go
go run cmd/seeder/main.go seed
go test -v ./...
env:
DB_USER: dblab_user
DB_PASSWORD: dblab_pass
DB_USER: postgres
DB_PASSWORD: password
DB_HOST: localhost
DB_PORT: 3306
DB_NAME: dblab_db
DB_DRIVER: mysql
DB_PORT: 5432
DB_NAME: users
DB_DRIVER: postgres

# Runs go test ./... against mysql container
- name: Test MySQL
run: |
go run cmd/dbmigrate/main.go
go run cmd/seeder/main.go seed
go test -v ./...
env:
Expand Down

0 comments on commit 4a84df4

Please sign in to comment.