-
Notifications
You must be signed in to change notification settings - Fork 30
388 lines (335 loc) · 11.8 KB
/
main.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
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
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
name: PCF
on:
push:
branches: [ "develop" ]
pull_request:
branches: [ "develop" ]
workflow_dispatch:
env:
GO_VERSION: '1.18.1'
RUBY_VERSION: '3.3'
jobs:
workflow_approval:
name: Approve workflow
runs-on: ubuntu-latest
environment: workflow-approval
steps:
- name: Approve workflow
run: echo For security reasons, all pull requests need to be approved first before running any automated CI.
fossa-scan:
continue-on-error: true
runs-on: ubuntu-latest
needs:
- workflow_approval
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{github.event.pull_request.head.sha}}
repository: ${{github.event.pull_request.head.repo.full_name}}
- name: run fossa anlyze and create report
run: |
curl -H 'Cache-Control: no-cache' https://raw.githubusercontent.com/fossas/fossa-cli/master/install-latest.sh | bash
fossa analyze --include-unused-deps --debug
fossa report attribution --format text > /tmp/THIRDPARTY
env:
FOSSA_API_KEY: ${{ secrets.FOSSA_API_KEY }}
- name: upload THIRDPARTY file
uses: actions/upload-artifact@v4
with:
name: THIRDPARTY
path: /tmp/THIRDPARTY
- name: run fossa test
run: |
fossa test --debug
env:
FOSSA_API_KEY: ${{ secrets.FOSSA_API_KEY }}
semgrep:
runs-on: ubuntu-latest
needs:
- workflow_approval
name: security-sast-semgrep
if: github.actor != 'dependabot[bot]'
steps:
- uses: actions/checkout@v3
- name: Semgrep
id: semgrep
uses: returntocorp/semgrep-action@v1
with:
publishToken: ${{ secrets.SEMGREP_PUBLISH_TOKEN }}
create-env:
needs:
- workflow_approval
runs-on: ubuntu-latest
timeout-minutes: 60
outputs:
API_ENDPOINT: ${{ steps.get-credentials.outputs.API_ENDPOINT }}
API_UAA_ENDPOINT: ${{ steps.get-credentials.outputs.API_UAA_ENDPOINT }}
API_PASSWORD: ${{ steps.get-credentials.outputs.API_PASSWORD }}
API_CLIENT_PASSWORD: ${{ steps.get-credentials.outputs.API_CLIENT_PASSWORD }}
ENV_ID: ${{ steps.get-credentials.outputs.ENV_ID }}
steps:
- name: Install Selfservice
run: |
wget https://github.com/cf-platform-eng/selfservice/releases/download/0.2.9/selfservice
chmod +x selfservice
ls -latr
- name: Get authorization token
run: |
echo "$(./selfservice auth $API_TOKEN | cut -c 8-)" >> "$GITHUB_ENV"
echo "::add-mask::$AUTH_TOKEN"
env:
API_TOKEN: ${{ secrets.API_TOKEN }}
- name: Claim environment and wait
run: |
echo ENV_ID="$(./selfservice claimAndWait isv_ci_tas_srt_4_0 | jq -r '.id')" >> "$GITHUB_ENV"
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: ${{ env.GO_VERSION }}
- name: Set up Brew
uses: Homebrew/actions/setup-homebrew@master
- name: Install hammer and cf
run: |
brew tap pivotal/hammer https://github.com/pivotal/hammer
brew install hammer
brew tap pivotal-cf/om https://github.com/pivotal-cf/om
brew install om
brew install cloudfoundry/tap/cf-cli
- name: Credentials
id: get-credentials
run: |
./selfservice get $ENV_ID | jq -r '.credentials' > env.json
echo API_ENDPOINT="https://api.$(jq -r '.sys_domain' ./env.json)" >> "$GITHUB_OUTPUT"
echo API_UAA_ENDPOINT="https://uaa.$(jq -r '.sys_domain' ./env.json)" >> "$GITHUB_OUTPUT"
API_PASSWORD="$(hammer -t ./env.json om credentials -- -p cf -t json -c .uaa.admin_credentials | jq -r '.password')"
API_PASSWORD_ENCRYPTED="$(echo $API_PASSWORD | openssl aes-256-cbc -a -pbkdf2 -salt -pass pass:$ENCRYPT_KEY)"
echo API_PASSWORD=$API_PASSWORD_ENCRYPTED >> "$GITHUB_OUTPUT"
API_CLIENT_PASSWORD="$(hammer -t ./env.json om credentials -- -p cf -t json -c .uaa.admin_client_credentials | jq -r '.password')"
API_CLIENT_PASSWORD_ENCRYPTED="$(echo $API_CLIENT_PASSWORD | openssl aes-256-cbc -a -pbkdf2 -salt -pass pass:$ENCRYPT_KEY)"
echo API_CLIENT_PASSWORD=$API_CLIENT_PASSWORD_ENCRYPTED >> "$GITHUB_OUTPUT"
echo ENV_ID=$ENV_ID >> "$GITHUB_OUTPUT"
env:
ENCRYPT_KEY: ${{ secrets.ENCRYPT_KEY }}
build:
runs-on: ubuntu-latest
needs:
- create-env
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{github.event.pull_request.head.sha}}
repository: ${{github.event.pull_request.head.repo.full_name}}
- uses: actions/setup-go@v3
with:
go-version: ${{ env.GO_VERSION }}
- run: go version
# Install Dependencies
- name: check-files
run: ls -la
- name: Install Dependencies
run: |
go mod vendor
# Builder
- name: Builder
run: make build
# Run tests
- name: Run tests
run: |
make testall
- uses: actions/upload-artifact@v4
with:
name: splunk-firehose-nozzle
path: splunk-firehose-nozzle
deploy_nozzle:
env:
API_ENDPOINT: ${{ needs.create-env.outputs.API_ENDPOINT }}
API_PASSWORD: ${{ needs.create-env.outputs.API_PASSWORD }}
API_CLIENT_PASSWORD: ${{ needs.create-env.outputs.API_CLIENT_PASSWORD }}
API_UAA_ENDPOINT: ${{ needs.create-env.outputs.API_UAA_ENDPOINT }}
API_USER: ${{ secrets.API_USER }}
CLIENT_ID: ${{ secrets.CLIENT_ID }}
CLIENT_SECRET: ${{ secrets.CLIENT_SECRET }}
SPLUNK_INDEX: ${{ secrets.SPLUNK_INDEX }}
SPLUNK_TOKEN: ${{ secrets.SPLUNK_TOKEN }}
SPLUNK_HOST: ${{ secrets.SPLUNK_HOST }}
SPLUNK_METRIC_INDEX: ${{ secrets.SPLUNK_METRIC_INDEX }}
needs:
- build
- create-env
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{github.event.pull_request.head.sha}}
repository: ${{github.event.pull_request.head.repo.full_name}}
- uses: actions/setup-go@v3
with:
go-version: ${{ env.GO_VERSION }}
- run: go version
- uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ env.RUBY_VERSION }}
- run: ruby -v
- uses: actions/download-artifact@v4
with:
name: splunk-firehose-nozzle
# Install dependencies
- name: Install dependencies
run: |
go mod vendor
# Deploy nozzle
- name: Deploy nozzle
run: |
.github/update_manifest.sh
.github/pre-req.sh
cf push -f scripts/ci_nozzle_manifest.yml -u process --random-route
env:
ENCRYPT_KEY: ${{ secrets.ENCRYPT_KEY }}
# Nozzle Log
- name: Nozzle Log
run: |
cf logs splunk-firehose-nozzle &
tile-builder:
env:
API_ENDPOINT: ${{ needs.create-env.outputs.API_ENDPOINT }}
API_PASSWORD: ${{ needs.create-env.outputs.API_PASSWORD }}
API_CLIENT_PASSWORD: ${{ needs.create-env.outputs.API_CLIENT_PASSWORD }}
API_UAA_ENDPOINT: ${{ needs.create-env.outputs.API_UAA_ENDPOINT }}
API_USER: ${{ secrets.API_USER }}
CLIENT_ID: ${{ secrets.CLIENT_ID }}
CLIENT_SECRET: ${{ secrets.CLIENT_SECRET }}
SPLUNK_INDEX: ${{ secrets.SPLUNK_INDEX }}
SPLUNK_TOKEN: ${{ secrets.SPLUNK_TOKEN }}
SPLUNK_HOST: ${{ secrets.SPLUNK_HOST }}
SPLUNK_METRIC_INDEX: ${{ secrets.SPLUNK_METRIC_INDEX }}
needs:
- deploy_nozzle
- create-env
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{github.event.pull_request.head.sha}}
repository: ${{github.event.pull_request.head.repo.full_name}}
- uses: actions/setup-go@v3
with:
go-version: ${{ env.GO_VERSION }}
- run: go version
- uses: actions/download-artifact@v4
with:
name: splunk-firehose-nozzle
# Tile builder
- name: Tile builder
run: |
.github/tile-builder.sh
- name: Get tile name
run: |
echo "tile_name=$(ls tile/product | grep ".pivotal")" >> "$GITHUB_ENV"
- name: Upload tile
uses: actions/upload-artifact@v4
with:
name: ${{ env.tile_name }}
path: tile/product/${{ env.tile_name }}
# Skip test for now!
execute_tests:
needs:
- tile-builder
- create-env
runs-on: ubuntu-latest
env:
API_ENDPOINT: ${{ needs.create-env.outputs.API_ENDPOINT }}
API_PASSWORD: ${{ needs.create-env.outputs.API_PASSWORD }}
API_CLIENT_PASSWORD: ${{ needs.create-env.outputs.API_CLIENT_PASSWORD }}
API_UAA_ENDPOINT: ${{ needs.create-env.outputs.API_UAA_ENDPOINT }}
API_USER: ${{ secrets.API_USER }}
CLIENT_ID: ${{ secrets.CLIENT_ID }}
CLIENT_SECRET: ${{ secrets.CLIENT_SECRET }}
SPLUNK_INDEX: ${{ secrets.SPLUNK_INDEX }}
SPLUNK_METRIC_INDEX: ${{ secrets.SPLUNK_METRIC_INDEX }}
SPLUNK_TOKEN: ${{ secrets.SPLUNK_TOKEN }}
SPLUNK_URL: ${{ secrets.SPLUNK_URL }}
SPLUNK_USER: ${{ secrets.SPLUNK_USER }}
SPLUNK_PASSWORD: ${{ secrets.SPLUNK_PASSWORD }}
SPLUNK_HOST: ${{ secrets.SPLUNK_HOST }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{github.event.pull_request.head.sha}}
repository: ${{github.event.pull_request.head.repo.full_name}}
- uses: actions/setup-go@v3
with:
go-version: ${{ env.GO_VERSION }}
- run: go version
- uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ env.RUBY_VERSION }}
- run: ruby -v
- uses: actions/download-artifact@v4
with:
name: splunk-firehose-nozzle
# Install dependencies
- name: Install dependencies
run: |
go mod vendor
chmod +x splunk-firehose-nozzle
# Deploy data-gen
- name: Deploy data-gen
run: |
.github/pre-req.sh
cf push -f scripts/data_gen_manifest.yml -u process -p tools/data_gen --random-route
sleep 10
cf apps
env:
ENCRYPT_KEY: ${{ secrets.ENCRYPT_KEY }}
# Nozzle Log
- name: Nozzle Log
run: |
cf logs splunk-firehose-nozzle &
# Prepare test environment
- name: Prepare test environment
run: |
.github/pre-functional-test.sh
# Executing tests
- name: Executing tests
run: |
.github/functional-test.sh
# Teardown
- name: Teardown
if: always()
run: |
API_PASSWORD_DEC=$(echo "$API_PASSWORD" | openssl aes-256-cbc -d -pbkdf2 -a -pass pass:"$ENCRYPT_KEY")
cf login --skip-ssl-validation -a "$API_ENDPOINT" -u "$API_USER" -p "$API_PASSWORD_DEC"
echo "Teardown deployment env"
cf target -o "splunk-ci-org" -s "splunk-ci-space"
cf delete splunk-firehose-nozzle -f
cf delete data_gen -f
cf delete-org splunk-ci-org -f
env:
ENCRYPT_KEY: ${{ secrets.ENCRYPT_KEY }}
teardown-env:
runs-on: ubuntu-latest
needs:
- create-env
- execute_tests
if: always()
env:
ENV_ID: ${{ needs.create-env.outputs.ENV_ID }}
steps:
- name: install-selfservice
run: |
wget https://github.com/cf-platform-eng/selfservice/releases/download/0.2.9/selfservice
chmod +x selfservice
ls -latr
- name: auth
run: |
echo "$(./selfservice auth $API_TOKEN | cut -c 8-)" >> "$GITHUB_ENV"
env:
API_TOKEN: ${{ secrets.API_TOKEN }}
- name: release environment
run: |
./selfservice release $ENV_ID