-
Notifications
You must be signed in to change notification settings - Fork 2
163 lines (133 loc) · 4.36 KB
/
github-ci.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
name: GitHub CI
on:
push:
pull_request:
schedule:
# https://crontab.guru/
# At 12:00 AM, only on Monday
- cron: 0 0 * * 1
workflow_dispatch:
jobs:
fmt:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}
- name: Install requirements
run: |
go install golang.org/x/tools/cmd/goimports@latest
- name: Check Go format
run: |
goimports -e -l $(pwd)
- name: Check Markdown format
uses: DavidAnson/[email protected]
with:
globs: |
**/*.md
#docs/themes/adidoks/**/*.md
audit:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Run Security Scanner
uses: securego/gosec@master
with:
args: -confidence low -enable-audit -tests -track-suppressions -no-fail -fmt sarif -sort -out results.sarif -stdout -verbose=text ./...
- name: Upload the analysis results
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: ./results.sarif
build:
runs-on: ${{ matrix.os }}
needs: [fmt, audit]
strategy:
matrix:
go-version: [stable]
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}
- name: Build
run: |
go env -w CGO_ENABLED=0
go build -o bin/ ./...
- name: Run golangci-lint
uses: golangci/golangci-lint-action@v6
with:
version: v1.61
- name: Test
run: |
go env -w CGO_ENABLED=1
go test -v -timeout 30s -race -shuffle on ./...
coverage:
runs-on: ubuntu-latest
needs: [build]
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: stable
- name: Install requirements
run: |
go install github.com/jstemmer/go-junit-report@latest
go install github.com/jandelgado/gcov2lcov@latest
- name: Generate the tests and code coverage reports
run: |
go env -w CGO_ENABLED=0
go test -v -coverpkg=./... -coverprofile=coverage.out ./...
go test -v ./... | go-junit-report > report.xml
go tool cover -html coverage.out -o coverage.html
gcov2lcov -infile=coverage.out -outfile=coverage.lcov
- name: Upload the test report to Codecov
if: ${{ !cancelled() }}
uses: codecov/test-results-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: report.xml
- name: Upload the code coverage report to Codecov
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: coverage.out
flags: unittests
name: codecov-umbrella
- name: Upload the code coverage report to Codacy
uses: codacy/[email protected]
with:
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
coverage-reports: ./coverage.lcov
- name: Upload the code coverage report to Code Climate
if: github.ref == 'refs/heads/main'
uses: paambaati/[email protected]
env:
CC_TEST_REPORTER_ID: ${{secrets.CC_TEST_REPORTER_ID}}
with:
coverageCommand: echo Code Climate
coverageLocations: |
${{github.workspace}}/*.lcov:lcov
- name: Upload the code coverage report to DeepSource
uses: deepsourcelabs/test-coverage-action@master
with:
key: go
coverage-file: coverage.out
dsn: ${{ secrets.DEEPSOURCE_DSN }}
- name: Upload the code coverage report to GitHub
uses: actions/upload-artifact@v4
with:
name: code-coverage-report
path: coverage.html
- name: Refresh the Go Report card
if: github.ref == 'refs/heads/main'
run: |
curl -X POST -F "repo=github.com/${{ github.repository }}" https://goreportcard.com/checks