forked from Game-as-a-Service/The-Message
-
Notifications
You must be signed in to change notification settings - Fork 0
113 lines (93 loc) · 2.76 KB
/
test-go-unit.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
name: ⚙️ Backend CI
on:
push:
paths:
- Backend/**
- .github/workflows/test-go-unit.yml
pull_request:
paths:
- Backend/**
- .github/workflows/test-go-unit.yml
env:
GO_VERSION: 1.22
jobs:
build:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
- name: Env handle
working-directory: ./Backend
run: cp .env.example .env
- name: Install dependencies
working-directory: ./Backend
run: |
go mod tidy
go mod download
go mod vendor
- name: Build
working-directory: ./Backend
run: go build -v ./...
unit_test:
needs: build
runs-on: ubuntu-22.04
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Go environment
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
- name: 🧪 Test
working-directory: ./Backend
run: go test $(go list ./... | grep -v /tests/) -count=1 -v -coverprofile=unit_test_coverage.out
- name: Upload unit test coverage report as artifact
uses: actions/upload-artifact@v2
with:
name: unit-test-coverage-report
path: ./Backend/unit_test_coverage.out
acceptance_test:
needs: unit_test
if: github.event_name == 'push'
services:
mysql:
image: mysql:8.1
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
uses: actions/checkout@v4
- name: Setup Go environment
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
- name: Env handle
working-directory: ./Backend
run: cp .env.example .env
- name: Wait for MySQL
run: |
wget https://raw.githubusercontent.com/vishnubob/wait-for-it/master/wait-for-it.sh
chmod +x wait-for-it.sh
./wait-for-it.sh 127.0.0.1:3306 --timeout=60
- name: Migration
working-directory: ./Backend
run: |
go run ./cmd/migrate/migrate.go
go run ./cmd/migrate/game_card_seeder.go
- name: 🎯 Acceptance test
working-directory: ./Backend
run: go test ./... -v -count=1 -coverprofile=coverage.out
- name: Upload acceptance test coverage report as artifact
uses: actions/upload-artifact@v2
with:
name: acceptance-test-coverage-report
path: ./Backend/coverage.out