-
Notifications
You must be signed in to change notification settings - Fork 22
244 lines (212 loc) · 7.47 KB
/
test.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
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
name: JFrog CLI Security Tests
on:
push:
branches:
- '**'
tags-ignore:
- '**'
# Triggers the workflow on labeled PRs only.
pull_request_target:
types: [ labeled ]
# Ensures that only the latest commit is running for each PR at a time.
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}-${{ github.ref }}
cancel-in-progress: true
# Environment variables shared across all jobs.
env:
GOPROXY: direct
GO_COMMON_TEST_ARGS: "-v github.com/jfrog/jfrog-cli-security --race --timeout 30m --jfrog.url=${{ secrets.PLATFORM_URL }} --jfrog.adminToken=${{ secrets.PLATFORM_ADMIN_TOKEN }}"
GRADLE_OPTS: -Dorg.gradle.daemon=false
CI: true
JFROG_CLI_LOG_LEVEL: DEBUG
jobs:
Pretest:
if: contains(github.event.pull_request.labels.*.name, 'safe to test') || github.event_name == 'push'
runs-on: ubuntu-latest
steps:
- name: Remove 'safe to test' label
uses: actions-ecosystem/action-remove-labels@v1
if: ${{ github.event_name != 'push' }}
with:
labels: "safe to test"
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Setup Go with cache
uses: jfrog/.github/actions/install-go-with-cache@main
- name: Run Go vet
run: go vet -v ./...
Unit_Tests:
name: "[${{ matrix.os }}] Unit Tests"
needs: Pretest
runs-on: ${{ matrix.os }}-latest
strategy:
fail-fast: false
matrix:
os: [ ubuntu, windows, macos ]
steps:
# Prepare the environment
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Install and Setup Dependencies
uses: ./.github/actions/install-and-setup
# Test and generate code coverage
- name: Run tests
run: go test ${{ env.GO_COMMON_TEST_ARGS }} -cover -coverprofile=cover-unit-tests --test.unit
- name: Archive Code Coverage Results
uses: actions/upload-artifact@v4
if: matrix.os == 'ubuntu'
with:
name: unit-tests-code-coverage
path: cover-unit-tests
Audit_Command_Integration_Tests:
name: "[${{ matrix.os }}] ${{ matrix.suite.name }} Audit Command Integration Tests"
needs: Pretest
runs-on: ${{ matrix.os }}-latest
strategy:
fail-fast: false
matrix:
os: [ ubuntu, windows, macos ]
suite:
- name: 'General Suite (Detection, MultiTech, NoTech...)'
testFlags: '--test.audit'
- name: 'JAS Suite'
testFlags: '--test.audit.Jas'
- name: 'Java Script Suite (Npm, Pnpm, Yarn)'
testFlags: '--test.audit.JavaScript'
- name: 'Python Suite (Pip, Pipenv, Poetry)'
testFlags: '--test.audit.Python'
- name: 'Java Suite (Maven, Gradle)'
testFlags: '--test.audit.Java'
- name: 'Go Suite (Go Modules, Dep, Glide)'
testFlags: '--test.audit.Go'
- name: 'C/C++/C# Suite (Conan, NuGet, Dotnet)'
testFlags: '--test.audit.C'
steps:
# Prepare the environment
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Install and Setup Dependencies
uses: ./.github/actions/install-and-setup
# Test
- name: Run tests
run: go test ${{ env.GO_COMMON_TEST_ARGS }} ${{ matrix.suite.testFlags }}
Artifactory_Integration_Tests:
name: "[${{ matrix.os }}] Artifactory Integration Tests"
needs: Pretest
runs-on: ${{ matrix.os }}-latest
strategy:
fail-fast: false
matrix:
os: [ ubuntu, windows, macos ]
steps:
# Prepare the environment
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Install and Setup Dependencies
uses: ./.github/actions/install-and-setup
# Test
- name: Run tests
run: go test ${{ env.GO_COMMON_TEST_ARGS }} --test.artifactory --ci.runId=${{ runner.os }}-sec-test
Xray_Commands_Integration_Tests:
name: "[${{ matrix.os }}] Xray Commands Integration Tests"
needs: Pretest
runs-on: ${{ matrix.os }}-latest
strategy:
fail-fast: false
matrix:
os: [ ubuntu, windows, macos ]
steps:
# Prepare the environment
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Install and Setup Dependencies
uses: ./.github/actions/install-and-setup
# Test
- name: Run tests
run: go test ${{ env.GO_COMMON_TEST_ARGS }} --test.xray
Xsc_Integration_Tests:
name: "[${{ matrix.os }}] XSC Integration Tests"
needs: Pretest
runs-on: ${{ matrix.os }}-latest
strategy:
fail-fast: false
matrix:
os: [ ubuntu, windows, macos ]
steps:
# Prepare the environment
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Install and Setup Dependencies
uses: ./.github/actions/install-and-setup
# Test
- name: Run tests
run: go test ${{ env.GO_COMMON_TEST_ARGS }} --test.xsc
Other_Scan_Commands_Integration_Tests:
name: "[${{ matrix.os }}] Other Scan Commands Integration Tests"
needs: Pretest
runs-on: ${{ matrix.os }}-latest
strategy:
fail-fast: false
matrix:
os: [ ubuntu, windows, macos ]
steps:
# Prepare the environment
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Install and Setup Dependencies
uses: ./.github/actions/install-and-setup
# Test
- name: Run tests
run: go test ${{ env.GO_COMMON_TEST_ARGS }} --test.scan
if: ${{ matrix.os != 'ubuntu' }}
- name: Run security tests (with Docker Scan)
run: go test ${{ env.GO_COMMON_TEST_ARGS }} --test.scan --test.dockerScan --test.containerRegistry=${{ secrets.CONTAINER_REGISTRY }} --ci.runId=${{ runner.os }}-sec-test
if: ${{ matrix.os == 'ubuntu' }}
Other_Commands_Integration_Tests:
name: "[${{ matrix.os }}] Other Commands Integration Tests"
needs: Pretest
runs-on: ${{ matrix.os }}-latest
strategy:
fail-fast: false
matrix:
os: [ ubuntu, windows, macos ]
steps:
# Prepare the environment
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Install and Setup Dependencies
uses: ./.github/actions/install-and-setup
# Test
- name: Run tests
run: go test ${{ env.GO_COMMON_TEST_ARGS }} --test.curation --test.enrich --test.git
Code_Coverage:
name: Generate Code Coverage Report
if: github.event_name == 'pull_request_target'
runs-on: ubuntu-latest
needs: [Unit_Tests]
permissions:
contents: read
actions: read # to download code coverage results from jobs
pull-requests: write # write permission needed to comment on PR
steps:
- name: Generate Unit Tests Code Coverage Report
uses: fgrosse/[email protected]
with:
coverage-artifact-name: unit-tests-code-coverage
coverage-file-name: cover-unit-tests