-
Notifications
You must be signed in to change notification settings - Fork 4
181 lines (177 loc) · 5.25 KB
/
test.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
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
name: test
on:
workflow_call:
inputs:
go-version:
description: 'Go version to use'
required: true
type: string
scan-severity:
description: 'Trivy scan severity'
required: true
type: string
golangci_version:
description: 'golangci version to use'
required: true
type: string
permissions:
contents: read
jobs:
unit:
runs-on: ubuntu-latest
permissions:
security-events: write
services:
postgres:
image: postgres
env:
POSTGRES_DB: test
POSTGRES_PORT: 5432
POSTGRES_USER: test
POSTGRES_PASSWORD: test
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- name: Setup Go
uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753 # v4.0.1
with:
go-version: ${{ inputs.go-version }}
- run: go version
- name: Cache Go Modules
uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1
with:
path: |
~/go/pkg/mod
~/.cache/go-build
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Checkout Code
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.4.0
- name: Tidy Modules
run: |
make tidy
- name: Install Grype
uses: anchore/scan-action/download-grype@4be3c24559b430723e51858969965e163b196957 # v3.3.5
- name: Unit Test
run: |
make test
- name: Parse Coverage
uses: codecov/codecov-action@eaaf4bedf32dbdc6b720b63067d99c4d77d6047d # v3.1.4
with:
flags: unittests # optional
lint:
runs-on: ubuntu-latest
permissions:
security-events: write
steps:
- name: Setup Go
uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753 # v4.0.1
with:
go-version: ${{ inputs.go-version }}
- run: go version
- name: Cache Go Modules
uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1
with:
path: |
~/go/pkg/mod
~/.cache/go-build
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Checkout Code
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.4.0
- name: Tidy Modules
run: |
make tidy
- name: Config Go Lint
id: golangci_config
uses: andstor/file-existence-action@20b4d2e596410855db8f9ca21e96fbe18e12930b # v2.0
with:
files: .golangci.yaml
- name: Lint Go
if: steps.golangci_config.outputs.files_exists == 'true'
uses: golangci/golangci-lint-action@639cd343e1d3b897ff35927a75193d57cfcba299 # v3.6.0
with:
version: ${{ inputs.golangci_version }}
- name: Config YAML Lint
id: yamllint_config
uses: andstor/file-existence-action@20b4d2e596410855db8f9ca21e96fbe18e12930b # v2.0
with:
files: .yamllint
- name: Lint YAML
if: steps.yamllint_config.outputs.files_exists == 'true'
uses: karancode/yamllint-github-action@fdef6bc189425ecc84cc4543b2674566c0827053 # master
with:
yamllint_config_filepath: .yamllint
e2e:
runs-on: ubuntu-latest
permissions:
security-events: write
services:
postgres:
image: postgres
env:
POSTGRES_DB: test
POSTGRES_PORT: 5432
POSTGRES_USER: test
POSTGRES_PASSWORD: test
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- name: Setup Go
uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753 # v4.0.1
with:
go-version: ${{ inputs.go-version }}
- run: go version
- name: Cache Go Modules
uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1
with:
path: |
~/go/pkg/mod
~/.cache/go-build
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Checkout Code
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.4.0
- name: Tidy Modules
run: |
make tidy
- name: Build Binary
run: |-
make build
- name: Run Integration Tests
run: |-
tools/e2e
scan:
runs-on: ubuntu-latest
permissions:
security-events: write
steps:
- name: Checkout Code
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.4.0
- name: Scan Repo
uses: aquasecurity/trivy-action@41f05d9ecffa2ed3f1580af306000f734b733e54 # v0.11.2
with:
scan-type: 'fs'
ignore-unfixed: true
hide-progress: true
format: 'sarif'
output: 'trivy-results.sarif'
severity: ${{ inputs.scan-severity }}
exit-code: '1'
- name: Upload Report
uses: github/codeql-action/upload-sarif@6c089f53dd51dc3fc7e599c3cb5356453a52ca9e # v2.11.6
with:
sarif_file: 'trivy-results.sarif'