-
Notifications
You must be signed in to change notification settings - Fork 90
130 lines (119 loc) · 3.78 KB
/
linter.yaml
File metadata and controls
130 lines (119 loc) · 3.78 KB
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
name: Linter
on:
push:
tags:
- v*
branches:
- master
- main
pull_request:
workflow_dispatch:
permissions:
contents: read
checks: write
env:
TYK_PMP_ANALYTICSSTORAGETYPE: redis
TYK_PMP_ANALYTICSSTORAGECONFIG_TYPE: redis
TYK_PMP_ANALYTICSSTORAGECONFIG_HOST: localhost
TYK_PMP_ANALYTICSSTORAGECONFIG_PORT: 6379
jobs:
gotest:
name: Go Test
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
go: [1.25]
services:
redis:
image: redis:5
ports:
- 6379:6379
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
mongo:
image: mongo:4.2
ports:
- 27017:27017
steps:
- uses: actions/setup-go@40f1582b2485089dde7abd97c1529aa768e1baff # v5
with:
go-version: ${{ matrix.go }}
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
- name: Cache
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Go Test
id: test
run: |
PKGS="$(go list ./...)"
OPTS="-count=1 -failfast -v"
GOTESTSUM="go run gotest.tools/gotestsum@v1.13.0"
for pkg in ${PKGS}; do
tags=""
if [[ ${pkg} == *"goplugin" ]]; then
tags="--tags 'goplugin'"
fi
coveragefile=`echo "$pkg" | awk -F/ '{print $NF}'`
echo go test ${OPTS} -json -timeout 15m -coverprofile=${coveragefile}.cov ${pkg} ${tags}
${GOTESTSUM} --junitfile ${coveragefile}.xml --raw-command go test ${OPTS} --json -timeout 15m -coverprofile=${coveragefile}.cov ${pkg} ${tags}
done
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
with:
name: coverage
path: "*cov"
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
if: ${{ always() }}
with:
name: junit
path: "*xml"
- name: Github report view
if: ${{ always() }}
uses: phoenix-actions/test-reporting@1e9b578818d03d6df50ce8e60d024a000bf3ab63 # v8
with:
name: Unit Test Results
path: "*.xml"
reporter: java-junit
golangci:
runs-on: ubuntu-latest
needs: gotest
if: ${{ always() }}
steps:
- name: Checkout code
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with:
fetch-depth: 0
- name: golangci-lint
uses: golangci/golangci-lint-action@4afd733a84b1f43292c63897423277bb7f4313a9 # v8
timeout-minutes: 20
with:
version: v2.5.0
only-new-issues: ${{ github.event_name == 'pull_request' }}
# Output formats configured in .golangci.yaml (v2 approach)
# Generates: text to stdout + checkstyle JSON for SonarQube
args: --issues-exit-code=0 -v ./...
skip-cache: false
skip-save-cache: false
- name: Upload golangci-lint report
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
if: always()
with:
name: golangci-report
retention-days: 1
path: golanglint.xml
sonarcloud:
if: ${{ always() }}
needs: [gotest, golangci]
uses: TykTechnologies/github-actions/.github/workflows/sonarcloud.yaml@d3fa20888fa2878e877e22bb7702141217290e7c # main
with:
exclusions: ""
secrets:
GH_TOKEN: ${{ secrets.ORG_GH_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}