-
Notifications
You must be signed in to change notification settings - Fork 0
185 lines (171 loc) · 5.71 KB
/
ci-tests.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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
name: CI tests
on:
pull_request:
push:
branches:
- main
env:
GO_VERSION: "1.18"
jobs:
golangci-lint:
runs-on: ubuntu-latest
steps:
- name: use gh token
env:
TOKEN: "${{ secrets.ORG_GH_TOKEN }}"
run: >
git config --global url."https://${TOKEN}@github.com".insteadOf "https://github.com"
- name: Checkout Storage
uses: actions/checkout@v2
with:
fetch-depth: 2
- name: Fetch base branch
if: ${{ github.event_name == 'pull_request' }}
run: git fetch origin ${{ github.base_ref }}
- name: Setup Golang
uses: actions/setup-go@v3
with:
go-version: ${{ env.GO_VERSION }}
- name: Download golangci-lint
run: curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin
- name: golangci-lint
if: ${{ contains(fromJSON('["push","pull_request"]'), github.event_name) }}
run: |
$(go env GOPATH)/bin/golangci-lint run --out-format checkstyle --timeout=300s --max-issues-per-linter=0 --max-same-issues=0 --issues-exit-code=0 --new-from-rev=origin/${{ github.base_ref }} ./... > golanglint.xml
- uses: actions/upload-artifact@v2
with:
name: golangcilint
retention-days: 1
path: |
golanglint.xml
test:
name: Tests ${{ matrix.storagetype }} storage - DB ${{ matrix.database }} ${{ matrix.version }} ${{ matrix.instancetype }}
needs: [golangci-lint]
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- storagetype: persistent
database: mongo
version: 4.4
- storagetype: persistent
database: mongo
version: 4.2
- storagetype: persistent
database: mongo
version: 7.0
- storagetype: persistent
database: mongo
version: 6.0
- storagetype: temporal
database: redis
version: 6.0.0
instancetype: single
- storagetype: temporal
database: redis
version: 7.0.0
instancetype: single
- storagetype: temporal
database: redis
version: 6.0.0
instancetype: cluster
- storagetype: temporal
database: redis
version: 7.0.0
instancetype: cluster
- storagetype: temporal
database: redis
version: 7.2.0
instancetype: single
- storagetype: temporal
database: redis
version: 7.0.0
instancetype: TLS
steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
fetch-depth: 2
- name: Setup Golang
uses: actions/setup-go@v3
with:
go-version: ${{ env.GO_VERSION }}
- name: Verify dependencies
run: go mod verify
- name: Build
run: go build -v ./...
- name: Install Task
uses: arduino/setup-task@v1
with:
version: 3
- if: ${{ matrix.database == 'mongo' }}
name: Start MongoDB '${{ matrix.version }}'
run: task -t bin/Taskfile-db.yml start-mongo MONGO_VERSION=${{ matrix.version }}
- if: ${{ matrix.database == 'redis' }}
name: Start Redis '${{ matrix.version }}'
run: task -t bin/Taskfile-db.yml start-redis-${{matrix.instancetype}} REDIS_VERSION=${{ matrix.version }}
- name: Run tests
env:
DB: ${{ matrix.database }}
DB_SETUP: ${{ matrix.instancetype }}
DB_VERSION: ${{ matrix.version }}
run: task test-${{ matrix.storagetype }}
- uses: actions/upload-artifact@v2
with:
name: coverage
retention-days: 1
path: coverage/**/*.cov
sonar-cloud-analysis:
runs-on: ubuntu-latest
needs: [test, golangci-lint]
steps:
- name: Checkout Tyk Storage
uses: actions/checkout@v2
with:
fetch-depth: 2
- name: Setup Golang
uses: actions/setup-go@v3
with:
go-version: ${{ env.GO_VERSION }}
- name: Download coverage artifacts
uses: actions/download-artifact@v2
with:
name: coverage
- name: Download golangcilint artifacts
uses: actions/download-artifact@v2
with:
name: golangcilint
- name: Check reports existence
id: check_files
uses: andstor/file-existence-action@v1
with:
files: "coverage/*.cov, golanglint.xml"
- name: Install Dependencies
env:
TOKEN: "${{ secrets.ORG_GH_TOKEN }}"
run: >
git config --global url."https://${TOKEN}@github.com".insteadOf "https://github.com"
go install github.com/wadey/gocovmerge@latest
- name: Install Task
uses: arduino/setup-task@v1
with:
version: 3
- name: merge reports
run: task merge-coverage
- name: SonarCloud Scan
uses: sonarsource/sonarcloud-github-action@master
with:
args: >
-Dsonar.organization=tyktechnologies
-Dsonar.projectKey=TykTechnologies_storage
-Dsonar.sources=.
-Dsonar.coverage.exclusions=**/*_test.go,**/mocks/*.go,**/tempmocks/*.go
-Dsonar.exclusions=**/mocks/*.go,**/tempmocks/*.go
-Dsonar.test.inclusions=**/*_test.go
-Dsonar.tests=.
-Dsonar.go.coverage.reportPaths=merged-coverage.cov
-Dsonar.go.golangci-lint.reportPaths=golanglint.xml
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}