-
Notifications
You must be signed in to change notification settings - Fork 3
96 lines (94 loc) · 2.5 KB
/
go_with_confidence.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
name: Go with Confidence
on:
push:
branches:
- main
pull_request:
types: [opened, synchronize, reopened]
jobs:
unit-test:
name: Unit Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: 1.x
- name: Cache Go modules
uses: actions/cache@v3
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- run: go mod download
- run: make unit-test
- uses: actions/upload-artifact@v3
with:
name: unit-test-coverage
path: unit-test-coverage.out
api-test:
name: API Test
runs-on: ubuntu-latest
services:
postgres:
image: postgres:latest
env:
POSTGRES_USER: my_user
POSTGRES_PASSWORD: my_password
POSTGRES_DB: my_db
ports:
- 54321:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
redis:
image: redis:latest
ports:
- 63791:6379
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: 1.x
- name: Cache Go modules
uses: actions/cache@v3
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- run: go mod download
- run: go run main.go migrate --config=config/config.testing.yaml
- run: make api-test
- uses: actions/upload-artifact@v3
with:
name: api-test-coverage
path: api-test-coverage.out
sonarqube-analysis:
name: SonarQube Analysis
needs: [unit-test, api-test]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/download-artifact@v3
with:
name: unit-test-coverage
path: .
- uses: actions/download-artifact@v3
with:
name: api-test-coverage
path: .
- uses: sonarsource/sonarqube-scan-action@master
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}