-
Notifications
You must be signed in to change notification settings - Fork 0
128 lines (126 loc) · 3.37 KB
/
main.yaml
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
120
121
122
123
124
125
126
127
128
name: CI
on:
push:
branches:
- main
pull_request:
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: ./go.mod
- name: Download go modules
run: go mod download
- name: Compile go packages
run: go build -o traPortfolio .
- uses: actions/upload-artifact@v4
with:
name: traPortfolio
path: traPortfolio
lint:
name: Lint
runs-on: ubuntu-latest
needs:
- build
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: ./go.mod
- uses: golangci/golangci-lint-action@v6
with:
version: latest
install-mode: goinstall
test-unit:
name: Test (Unit)
runs-on: ubuntu-latest
needs:
- build
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: ./go.mod
- name: Run tests
run: |
go test ./internal/... -coverprofile=coverage_unit.tmp.txt -race -vet=off
grep -v "mock_" < coverage_unit.tmp.txt > coverage_unit.txt
- uses: actions/upload-artifact@v4
with:
name: coverage_unit
path: coverage_unit.txt
test-integration:
name: Test (Integration)
runs-on: ubuntu-latest
needs:
- build
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: ./go.mod
- name: Run tests
run: |
go test ./integration_tests/... -coverpkg=./... -coverprofile=coverage_integration.tmp.txt -race -vet=off
grep -v "mock_" < coverage_integration.tmp.txt > coverage_integration.txt
- uses: actions/upload-artifact@v4
with:
name: coverage_integration
path: coverage_integration.txt
upload-codecov:
name: Analyze coverages
runs-on: ubuntu-latest
needs:
- test-unit
- test-integration
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: coverage_unit
- uses: actions/download-artifact@v4
with:
name: coverage_integration
- name: Upload coverage data (Unit)
uses: codecov/codecov-action@v4
with:
files: ./coverage_unit.txt
flags: unit
token: ${{ secrets.CODECOV_TOKEN }}
- name: Upload coverage data (Integration)
uses: codecov/codecov-action@v4
with:
files: ./coverage_integration.txt
flags: integration
token: ${{ secrets.CODECOV_TOKEN }}
tbls:
name: TBLS
runs-on: ubuntu-latest
needs:
- build
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: traPortfolio
- name: Setup MySQL container
run: docker compose up -d --wait mysql
- uses: k1low/setup-tbls@v1
- name: Run database linter
run: |
chmod +x ./traPortfolio
./traPortfolio --only-migrate
tbls lint
spectral:
name: Spectral
runs-on: ubuntu-latest
container:
image: stoplight/spectral:6.5.1
steps:
- uses: actions/checkout@v4
- name: Spectral checks
run: spectral lint ./docs/swagger/traPortfolio.v1.yaml