Skip to content

Commit

Permalink
Merge pull request #45 from linycken013127/infra/tweak-github-action
Browse files Browse the repository at this point in the history
ci: fix acceptance test can't work after PR merged
  • Loading branch information
ping-yee authored Oct 20, 2023
2 parents 10da56b + a606f97 commit 85b47ed
Showing 1 changed file with 19 additions and 15 deletions.
34 changes: 19 additions & 15 deletions .github/workflows/test-go-unit.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Backend CI
name: ⚙️ Backend CI

on:
push:
Expand All @@ -18,17 +18,6 @@ jobs:

runs-on: ubuntu-22.04

services:
mysql:
image: mysql:8.1.0
env:
MYSQL_ROOT_PASSWORD: ${{ secrets.DB_ROOT_PASSWORD }}
MYSQL_DATABASE: test
MYSQL_USER: user
MYSQL_PASSWORD: ${{ secrets.DB_PASSWORD }}
ports:
- "3306:3306"

steps:
- uses: actions/checkout@v3

Expand Down Expand Up @@ -56,7 +45,7 @@ jobs:
with:
go-version: ${{ env.GO_VERSION }}

- name: Test
- name: 🧪 Test
working-directory: ./Backend
run: go test $(go list ./... | grep -v /tests/) -count=1 -v -coverprofile=unit_test_coverage.out

Expand All @@ -68,7 +57,19 @@ jobs:

acceptance_test:
needs: unit_test
if: github.event_name == 'pull_request' && github.event.action == 'closed' && github.event.pull_request.merged == true
if: github.event_name == 'push'

services:
mysql:
image: mysql:8.1.0
env:
MYSQL_ROOT_PASSWORD: ${{ secrets.DB_ROOT_PASSWORD }}
MYSQL_DATABASE: test
MYSQL_USER: user
MYSQL_PASSWORD: ${{ secrets.DB_PASSWORD }}
ports:
- "3306:3306"

runs-on: ubuntu-22.04
steps:
- name: Checkout code
Expand All @@ -78,11 +79,14 @@ jobs:
with:
go-version: ${{ env.GO_VERSION }}

- name: Env handle
working-directory: ./Backend
run: cp env .env

- name: Migration
working-directory: ./Backend
run: go run ./cmd/migrate/migrate.go
- name: Acceptance test
- name: 🎯 Acceptance test
working-directory: ./Backend
run: go test ./... -v -count=1 -coverprofile=coverage.out

Expand Down

0 comments on commit 85b47ed

Please sign in to comment.