forked from Checkmarx/kics
-
Notifications
You must be signed in to change notification settings - Fork 0
124 lines (122 loc) · 4.15 KB
/
go-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
name: go-ci
on:
pull_request:
branches: [master]
jobs:
lint:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Go 1.19.x
uses: actions/setup-go@v3
with:
go-version: 1.19.x
- name: golangci-lint
uses: golangci/[email protected]
with:
version: v1.50.1
args: -c .golangci.yml --timeout 20m
go-generate:
name: go-generate
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.19.x
uses: actions/setup-go@v3
with:
go-version: 1.19.x
- name: Check out code
uses: actions/checkout@v3
with:
persist-credentials: false
fetch-depth: 0
- name: Generate mocks and marshall/unmarshall code
run: make generate
unit-tests:
name: unit-tests
strategy:
matrix:
go-version: [1.19.x]
os: [ubuntu-latest, windows-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Set up Go 1.19.x
uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go-version }}
- name: Check out code into the Go module directory
uses: actions/checkout@v3
with:
persist-credentials: false
- uses: dorny/paths-filter@v2
id: changes
with:
filters: |
src:
- 'pkg/terraformer/**'
- name: Get cache paths
id: go-cache-paths
run: |
echo "::set-output name=go-build::$(go env GOCACHE)"
echo "::set-output name=go-mod::$(go env GOMODCACHE)"
- name: Cache dependencies
uses: actions/cache@v3
with:
path: ${{ steps.go-cache-paths.outputs.go-build }}
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.OS }}-build-${{ env.cache-name }}
${{ runner.OS }}-build-
${{ runner.OS }}-
- name: Get Modules
run: |
go mod vendor
- name: Set Windows Page size
if: matrix.os == 'windows-latest'
uses: al-cheb/[email protected]
with:
minimum-size: 32GB
maximum-size: 32GB
disk-root: "C:"
- name: Test and Generate Report
if: matrix.os != 'windows-latest' && steps.changes.outputs.src == 'true'
run: |
go test -mod=vendor -v -timeout 1500s $(go list ./... | grep -v e2e) -count=1 -coverprofile=cover.out | tee unit-test.log
result_code=${PIPESTATUS[0]}
exit $result_code
- name: Test and Generate Report Dev
if: matrix.os != 'windows-latest' && steps.changes.outputs.src == 'false'
run: |
go test -tags dev -mod=vendor -v -timeout 1500s $(go list -tags dev ./... | grep -v e2e) -count=1 -coverprofile=cover.out | tee unit-test.log
result_code=${PIPESTATUS[0]}
exit $result_code
- name: Test and Generate Report Windows
if: matrix.os == 'windows-latest' && steps.changes.outputs.src == 'true'
run: |
go test -mod=vendor -v -timeout 1500s $(go list ./... | grep -v e2e) -count=1 -coverprofile=cover.out | tee unit-test.log
- name: Test and Generate Report Windows Dev
if: matrix.os == 'windows-latest' && steps.changes.outputs.src == 'false'
run: |
go test -mod=vendor -tags dev -v -timeout 1500s $(go list -tags dev ./... | grep -v e2e) -count=1 -coverprofile=cover.out | tee unit-test.log
- name: Archive test logs
if: always()
uses: actions/upload-artifact@v3
with:
name: unit-test-${{ runner.os }}-${{ github.event.pull_request.head.sha }}.log
path: unit-test.log
security-scan:
name: security-scan
runs-on: ubuntu-latest
env:
GO111MODULE: on
steps:
- name: Checkout Source
uses: actions/checkout@v3
- name: Run Gosec Security Scanner
uses: securego/gosec@master
with:
args: "-no-fail -fmt sarif -out results.sarif ./..."
- name: Upload SARIF file
uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: results.sarif