-
Notifications
You must be signed in to change notification settings - Fork 4
119 lines (116 loc) · 3.08 KB
/
main.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
114
115
116
117
118
119
name: CI
on:
push:
branches:
- 'main'
- 'develop'
pull_request:
env:
TZ: Asia/Tokyo
jobs:
mod:
name: Mod
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v4
with:
go-version: '1.20'
- uses: actions/checkout@v4
- uses: actions/[email protected]
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-gomod-${{ hashFiles('**/go.sum') }}
- run: go mod download
build:
name: Build
runs-on: ubuntu-latest
needs: [mod]
env:
GOCACHE: "/tmp/go/cache"
steps:
- uses: actions/setup-go@v4
with:
go-version: '1.20'
- uses: actions/checkout@v4
- uses: actions/[email protected]
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-gomod-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-gomod-
- uses: actions/[email protected]
with:
path: /tmp/go/cache
key: ${{ runner.os }}-go-build-${{ github.ref }}-${{ github.sha }}
restore-keys: |
${{ runner.os }}-go-build-${{ github.ref }}-
${{ runner.os }}-go-build-
- run: go build -o anke-to
- uses: actions/upload-artifact@v3
with:
name: anke-to
path: anke-to
test:
name: Test
runs-on: ubuntu-latest
needs: [mod]
services:
mysql:
image: mariadb:10.3.9
ports:
- 3306:3306
env:
MYSQL_ROOT_PASSWORD: password
MYSQL_DATABASE: anke-to
steps:
- uses: actions/setup-go@v4
with:
go-version: '1.20'
- uses: actions/checkout@v4
- uses: actions/[email protected]
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-gomod-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-gomod-
- run: go install github.com/golang/mock/[email protected]
- run: go generate ./...
- run: go test ./model ./router -v -coverprofile=coverage.txt -race -vet=off
env:
MARIADB_USERNAME: root
MARIADB_PASSWORD: password
MARIADB_HOSTNAME: 127.0.0.1
MARIADB_DATABASE: anke-to
- name: Upload coverage data
uses: codecov/[email protected]
with:
file: ./coverage.txt
yml: ./codecov.yml
- uses: actions/upload-artifact@v3
with:
name: coverage.txt
path: coverage.txt
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v4
with:
go-version: '1.20'
- uses: actions/checkout@v4
- name: golangci-lint
uses: reviewdog/[email protected]
with:
reporter: github-pr-check
github_token: ${{ secrets.GITHUB_TOKEN }}
fail_on_error: true
spectral:
name: Spectral
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Spectral checks
uses: stoplightio/[email protected]
with:
file_glob: docs/swagger/*.yaml
repo_token: ${{ secrets.GITHUB_TOKEN }}