From 4a84df445bec024a2b96098142a0e86ac37d2135 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Omar=20Vergara=20P=C3=A9rez?= Date: Sat, 8 May 2021 01:07:59 -0500 Subject: [PATCH] ci(actions): add a way to run mysql in a service --- .github/workflows/ci.yaml | 73 ++++++++------------------------------- 1 file changed, 14 insertions(+), 59 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index bfbbe4e..5c3cd44 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -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] @@ -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: @@ -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 @@ -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: