-
Notifications
You must be signed in to change notification settings - Fork 8
285 lines (240 loc) · 7.7 KB
/
build.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
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
# Copyright 2022 Snyk Ltd.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
name: Build
on:
workflow_dispatch:
pull_request:
jobs:
lint:
name: lint
runs-on: ubuntu-latest
steps:
- name: Prepare git
run: git config --global core.autocrlf false
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: "./go.mod"
cache: "true"
- name: Lint source code
run: |
make tools lint
unit-tests:
name: unit tests
needs: [lint]
runs-on: ubuntu-latest
steps:
- name: Prepare git
run: git config --global core.autocrlf false
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: "./go.mod"
cache: "true"
- name: Set up Snyk CLI
uses: snyk/actions/setup@master
- name: Cache Pact CLI tools
id: cache-pact
uses: actions/cache@v4
with:
path: ~/pact
key: ${{ runner.os }}-pact
- name: Set up Pact CLI tools
shell: bash
if: steps.cache-pact.outputs.cache-hit != 'true'
run: |
make tools
- name: Run tests
env:
DEEPROXY_API_URL: ${{secrets.DEEPROXY_API_URL}}
SNYK_TOKEN: ${{secrets.SNYK_TOKEN }}
SNYK_TOKEN_CONSISTENT_IGNORES: ${{secrets.SNYK_TOKEN_CONSISTENT_IGNORES }}
run: |
export PATH=$PATH:~/pact/bin
# this is required to be able to test the clipboard
export DISPLAY=:99
sudo Xvfb -ac :99 -screen 0 1280x1024x24 > /dev/null 2>&1 &
sudo apt-get install -y xsel xclip wl-clipboard
make clean test
integration-tests:
name: integration-tests
needs: [lint]
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- name: Prepare git
run: git config --global core.autocrlf false
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: "./go.mod"
- name: Cache Pact CLI tools
if: matrix.os != 'windows-latest'
id: cache-pact
uses: actions/cache@v4
with:
path: ~/pact
key: ${{ runner.os }}-pact
- name: Set up Pact CLI tools
shell: bash
if: steps.cache-pact.outputs.cache-hit != 'true' && matrix.os != 'windows-latest'
run: |
make tools
- name: Run integration & smoke tests with Pact
if: matrix.os == 'ubuntu-latest'
env:
DEEPROXY_API_URL: ${{secrets.DEEPROXY_API_URL}}
SNYK_TOKEN: ${{secrets.SNYK_TOKEN }}
INTEG_TESTS: "true"
SMOKE_TESTS: "true"
run: |
export PATH=$PATH:~/pact/bin
# this is required to be able to test the clipboard
export DISPLAY=:99
sudo Xvfb -ac :99 -screen 0 1280x1024x24 > /dev/null 2>&1 &
sudo apt-get install -y xsel xclip wl-clipboard
make clean test
- name: Run integration tests with Pact
if: matrix.os == 'macos-latest'
env:
DEEPROXY_API_URL: ${{secrets.DEEPROXY_API_URL}}
SNYK_TOKEN: ${{secrets.SNYK_TOKEN }}
INTEG_TESTS: "true"
SMOKE_TESTS: "true"
run: |
export PATH=$PATH:~/pact/bin
# this is required to be able to test the clipboard
export DISPLAY=:99
sudo Xvfb -ac :99 -screen 0 1280x1024x24 > /dev/null 2>&1 &
make clean test
- name: Run integration tests without Pact
if: matrix.os == 'windows-latest'
env:
DEEPROXY_API_URL: ${{secrets.DEEPROXY_API_URL}}
SNYK_TOKEN: ${{secrets.SNYK_TOKEN }}
INTEG_TESTS: "true"
SMOKE_TESTS: "true"
run: |
make clean test
proxy-test:
name: proxy-test
needs: [lint]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Run proxy tests
env:
SNYK_TOKEN: ${{secrets.SNYK_TOKEN }}
run: |
make clean proxy-test
race-tests:
name: race-test
needs: [lint]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Pact CLI tools
shell: bash
run: |
make tools
- name: Cache Pact CLI tools
id: cache-pact
uses: actions/cache@v4
with:
path: ~/pact
key: ${{ runner.os }}-pact
- name: Run race tests
env:
SNYK_TOKEN: ${{secrets.SNYK_TOKEN }}
run: |
export PATH=$PATH:~/pact/bin
# this is required to be able to test the clipboard
export DISPLAY=:99
sudo Xvfb -ac :99 -screen 0 1280x1024x24 > /dev/null 2>&1 &
sudo apt-get install -y xsel xclip wl-clipboard
make clean race-test
update-licenses:
name: update licenses
needs: [unit-tests]
runs-on: ubuntu-latest
steps:
- name: Prepare git
run: git config --global core.autocrlf false
- uses: actions/checkout@v4
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.ref }}
token: ${{ secrets.HAMMERHEAD_GITHUB_PAT_SNYKLS }}
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: "./go.mod"
- name: update licenses
run: |
make tools license-update
- name: commit license changes
uses: EndBug/add-and-commit@v9
with:
default_author: github_actor
committer_name: Github Actions
committer_email: [email protected]
message: "docs: updated licenses"
add: "licenses"
push: true
test-release:
name: test-release
needs: [lint, unit-tests]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # does an unshallow checkout with tags & branches
- name: Determine Go version
run: |
sed -En 's/^go[[:space:]]+([[:digit:].]+)$/GO_VERSION=\1/p' go.mod >> $GITHUB_ENV
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
- name: Create License Report
id: create_license_report
run: |
make tools
LICENSES=$(make licenses)
echo 'LICENSES<<EOF' >> $GITHUB_OUTPUT
echo $LICENSES >> $GITHUB_OUTPUT
echo 'EOF' >> $GITHUB_OUTPUT
echo $LICENSES
- name: Do test release with goreleaser
uses: goreleaser/goreleaser-action@v6
env:
LICENSES: ${{ steps.create_license_report.outputs.LICENSES }}
with:
version: "v2.4.7"
args: release --clean --snapshot
- name: Output compiled licenses
run: |
chmod +x build/snyk-ls_linux_amd64_v1/snyk-ls
build/snyk-ls_linux_amd64_v1/snyk-ls -licenses
- name: Dry-run upload script
env:
AWS_REGION: ${{ secrets.AWS_REGION }}
AWS_S3_BUCKET_NAME: ${{ secrets.AWS_S3_BUCKET_NAME }}
run: |
.github/upload-to-s3.sh --dryrun