-
Notifications
You must be signed in to change notification settings - Fork 1
393 lines (358 loc) · 14.7 KB
/
nightly-v1.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
389
390
391
392
393
name: Zowe Nightly Pipeline for v1
on:
schedule:
# this sets to 12.10am everyday UTC time, 8.10pm EST
- cron: '10 0 * * *'
workflow_dispatch:
inputs:
skip-promote:
description: Skip release?
type: boolean
required: false
default: false
skip-test:
description: Skip test?
type: boolean
required: false
default: false
env:
LOCAL_RELEASE_FOLDER: .release
DAY_RUN_BLD_FULL_TEST: Sun
FORCE_BUILD_TIME_THRESHOLD: 24
jobs:
if-to-run-build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: 'Determine if today is the day we absolutely need to run build+test'
id: absolutely-need-to-run
run: |
DAYOFWEEK=$(date +"%a")
if [[ "$DAYOFWEEK" == "${{ env.DAY_RUN_BLD_FULL_TEST }}" ]] ; then
echo RUN_BUILD=YES >> $GITHUB_ENV
echo "INSTALL_TEST=Zowe Release Tests" >> $GITHUB_OUTPUT
echo "Today is $DAYOFWEEK, need to run build and full release test suite"
else
echo "INSTALL_TEST=Zowe Nightly Tests" >> $GITHUB_OUTPUT
echo "Today is $DAYOFWEEK, do not need to run build and full release test suite"
fi
- name: Download manifest file
if: ${{ env.RUN_BUILD != 'YES' }}
run: curl https://raw.githubusercontent.com/${{ env.USER_REPO }}/${{ env.BRANCH_NAME }}/manifest.json.template -o manifest.json
env:
USER_REPO: zowe/zowe-install-packaging
BRANCH_NAME: v1.x/staging
- name: Decide if we need to run build
id: run-check
if: ${{ env.RUN_BUILD != 'YES' }}
uses: ./decide-if-to-run-build
with:
time-difference-threshold-min: ${{ env.FORCE_BUILD_TIME_THRESHOLD }}
- id: set-outputs
run: echo "RUN_BUILD=${{ env.RUN_BUILD }}" >> $GITHUB_OUTPUT
outputs:
RUN_BUILD: ${{ steps.set-outputs.outputs.RUN_BUILD }}
INSTALL_TEST: ${{ steps.absolutely-need-to-run.outputs.INSTALL_TEST }}
run-nightly-pipeline:
runs-on: ubuntu-latest
needs: if-to-run-build
if: ${{ needs.if-to-run-build.outputs.RUN_BUILD == 'YES' }}
steps:
- name: 'Setup jFrog CLI'
uses: jfrog/setup-jfrog-cli@v2
env:
JF_ENV_1: ${{ secrets.JF_ARTIFACTORY_TOKEN }}
#============================================================================
- name: '[Build 1] Call build workflow'
uses: zowe-actions/shared-actions/workflow-remote-call-wait@main
id: call-build
with:
github-token: ${{ secrets.ZOWE_ROBOT_TOKEN }}
owner: zowe
repo: zowe-install-packaging
workflow-filename: build-packaging.yml
branch-name: v1.x/staging
poll-frequency: 3
inputs-json-string: '{"BUILD_SMPE":"true","BUILD_PSWI":"false","BUILD_DOCKER":"true","BUILD_DOCKER_SOURCES":"false","BUILD_KUBERNETES":"true","KEEP_TEMP_PAX_FOLDER":"false"}'
# env:
# DEBUG: zowe-actions:shared-actions:workflow-remote-call-wait
- name: '[Build 2] Report build failure if applied'
if: ${{ steps.call-build.outputs.workflow-run-conclusion != 'success' }}
uses: actions/github-script@v5
with:
script: |
core.setFailed('Build workflow ${{ steps.call-build.outputs.workflow-run-num }} is not successful')
#============================================================================
- name: '[Promote:Prep 1] Get zowe version of the build triggered from this nightly pipeline'
if: ${{ github.event.inputs.skip-promote != 'true' }}
run: |
echo ZOWE_ART_DIR=$(jfrog rt search \
--build="zowe-install-packaging/v1.x/staging/${{ steps.call-build.outputs.workflow-run-num }}" \
"libs-snapshot-local/org/zowe/*/zowe*pax" | jq -r ".[].path" | sed "s#libs-snapshot-local/org/zowe/##g" | cut -f1 -d"/") >> $GITHUB_ENV
- name: '[Promote:Prep 2] Checkout'
if: ${{ github.event.inputs.skip-promote != 'true' }}
uses: actions/checkout@v2
- name: '[Promote:Prep 3] Replace JFROG_CLI_BUILD_NAME'
if: ${{ github.event.inputs.skip-promote != 'true' }}
run: echo JFROG_CLI_BUILD_NAME=${{ github.event.repository.name }}/${GITHUB_REF_NAME} >> $GITHUB_ENV
- name: '[Promote:Prep 4] Convert release json template then print'
if: ${{ github.event.inputs.skip-promote != 'true' }}
run: |
sed -e "s#{ZOWE_ARTIFACT_DIR}#${{ env.ZOWE_ART_DIR }}#g" \
zowe-release-v1-template.json > zowe-release-v1.json
echo "Current zowe-release-v1.json is:"
cat zowe-release-v1.json
echo ZOWE_RELEASE_JSON=zowe-release-v1.json >> $GITHUB_ENV
- name: '[Promote:Prep 5] Create various folders for later steps to use'
if: ${{ github.event.inputs.skip-promote != 'true' }}
run: |
# create folders under root project dir
mkdir ${{ env.LOCAL_RELEASE_FOLDER }}
- name: '[Promote:Validate 1] Validate zowe artifacts'
if: ${{ github.event.inputs.skip-promote != 'true' }}
id: validate
uses: ./validate
with:
build-name: zowe-install-packaging/v1.x/staging
build-num: ${{ steps.call-build.outputs.workflow-run-num }}
release-version: nightly-v1
validate-artifactory-folder: false
validate-release-ver-tag: false
validate-commit-hash: false
validate-smpe-promote-tar: false
validate-docker-amd64-sources: false
validate-docker-s390x: false
validate-docker-s390x-sources: false
validate-cli-python-sdk: false
validate-cli-nodejs-sdk: false
validate-cli-nodejs-sdk-typedoc: false
validate-pswi: false
# Above step 'Validate' will generate a file (name is stored in its outputs.PROMOTE_JSON_FILE_NAME_FULL)
# file name is: promote-artifacts.json
# this can be used in many later step: promote
- name: '[Promote:Validate 2] Print promote-artifacts.json'
if: ${{ github.event.inputs.skip-promote != 'true' }}
run: cat ${{ steps.validate.outputs.PROMOTE_JSON_FILE_NAME_FULL }}
- name: '[Promote:Promote 1] Promote (jfrog rt copy)'
if: ${{ github.event.inputs.skip-promote != 'true' }}
timeout-minutes: 10
id: promote
uses: ./promote
with:
promote-json-file-name-full: ${{ steps.validate.outputs.PROMOTE_JSON_FILE_NAME_FULL }}
release-version: nightly
# promote step above will also create a release artifacts download spec file for next message step to consume
# file name is stored in its outputs.RELEASE_ARTIFACTS_DOWNLOAD_SPEC_FILE
# file name will be: release-artifacts-download-spec.json
- name: '[Promote:Promote 2] Print release-artifacts-download-spec.json'
if: ${{ github.event.inputs.skip-promote != 'true' }}
run: cat ${{ steps.promote.outputs.RELEASE_ARTIFACTS_DOWNLOAD_SPEC_FILE }}
- name: '[Promote:Message] Make slack message'
if: ${{ github.event.inputs.skip-promote != 'true' }}
timeout-minutes: 2
id: message
uses: ./message
with:
release-artifact-download-file: ${{ steps.promote.outputs.RELEASE_ARTIFACTS_DOWNLOAD_SPEC_FILE }}
release-version: nightly-v1
build-num: ${{ steps.call-build.outputs.workflow-run-num }}
#============================================================================
- name: '[Test 1] Call test workflow'
uses: zowe-actions/shared-actions/workflow-remote-call-wait@main
if: ${{ github.event.inputs.skip-test != 'true' }}
id: call-test
with:
github-token: ${{ secrets.ZOWE_ROBOT_TOKEN }}
owner: zowe
repo: zowe-install-packaging
workflow-filename: cicd-test.yml
branch-name: v1.x/staging
poll-frequency: 10
inputs-json-string: '{"install-test":"${{ needs.if-to-run-build.outputs.INSTALL_TEST }}","custom-zowe-artifactory-pattern-or-build-number":"${{ steps.call-build.outputs.workflow-run-num }}"}'
# env:
# DEBUG: zowe-actions:shared-actions:workflow-remote-call-wait
- name: '[Test 2] Report test failure if applied'
if: ${{ steps.call-test.outputs.workflow-run-conclusion != 'success' && github.event.inputs.skip-test != 'true' }}
uses: actions/github-script@v5
with:
script: |
core.setFailed('Test workflow ${{ steps.call-test.outputs.workflow-run-num }} is not successful')
#============================================================================
- name: '[Message 1] prepare slack message body'
if: always()
run: |
echo TODAYS_DATE=$(date +'%m/%d/%Y') >> $GITHUB_ENV
echo STAGING_VER=$(jfrog rt search \
--sort-by=created --sort-order=desc --limit=1 \
"libs-snapshot-local/org/zowe/*/zowe-1*pax" \
| jq -r ".[].path" \
| sed "s#libs-snapshot-local/org/zowe/##g" \
| cut -f1 -d"/" \
| cut -f1 -d"-") \
>> $GITHUB_ENV
- name: '[Message 2] Send slack message'
uses: slackapi/[email protected]
if: always()
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
with:
channel-id: ${{ secrets.ZOWE_BUILD_CHANNEL_ID }}
payload: |
{
"blocks": [
{
"type": "header",
"text": {
"type": "plain_text",
"text": "Zowe Nightly Pipeline Daily Report"
}
},
{
"type": "section",
"fields": [
{
"type": "mrkdwn",
"text": "*Version:*\n ${{ env.STAGING_VER }}"
},
{
"type": "mrkdwn",
"text": "*Date:*\n ${{ env.TODAYS_DATE }}"
}
]
},
{
"type": "divider"
},
{
"type": "section",
"fields": [
{
"type": "mrkdwn",
"text": "*Build*"
},
{
"type": "mrkdwn",
"text": "Result: ${{ steps.call-build.outputs.workflow-run-conclusion || 'failed' }}"
}
]
},
{
"type": "actions",
"elements": [
{
"type": "button",
"text": {
"type": "plain_text",
"text": "Build Workflow Log"
},
"url": "${{ steps.call-build.outputs.workflow-run-html-url || 'https://www.github.com/404' }}"
}
]
},
{
"type": "divider"
},
{
"type": "section",
"fields": [
{
"type": "mrkdwn",
"text": "*Test*"
},
{
"type": "mrkdwn",
"text": "Result: ${{ steps.call-test.outputs.workflow-run-conclusion || 'test is still running, or skipped' }}"
}
]
},
{
"type": "actions",
"elements": [
{
"type": "button",
"text": {
"type": "plain_text",
"text": "Test Workflow Log"
},
"url": "${{ steps.call-test.outputs.workflow-run-html-url || env.html_url || 'https://www.github.com/404' }}"
}
]
},
{
"type": "divider"
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "*Promoted Artifacts*"
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "${{ steps.message.outputs.slack-message || 'No artifacts getting promoted.' }}"
}
}
]
}
post-slack-if-dont-need-build:
runs-on: ubuntu-latest
needs: if-to-run-build
if: ${{ needs.if-to-run-build.outputs.RUN_BUILD == 'NO' }}
steps:
- name: 'Setup jFrog CLI'
uses: jfrog/setup-jfrog-cli@v2
env:
JF_ENV_1: ${{ secrets.JF_ARTIFACTORY_TOKEN }}
- name: Prepare slack message body
run: |
echo TODAYS_DATE=$(date +'%m/%d/%Y') >> $GITHUB_ENV
echo STAGING_VER=$(jfrog rt search \
--sort-by=created --sort-order=desc --limit=1 \
"libs-snapshot-local/org/zowe/*/zowe-1*pax" \
| jq -r ".[].path" \
| sed "s#libs-snapshot-local/org/zowe/##g" \
| cut -f1 -d"/" \
| cut -f1 -d"-") \
>> $GITHUB_ENV
- name: Send slack message
uses: slackapi/[email protected]
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
with:
channel-id: ${{ secrets.ZOWE_BUILD_CHANNEL_ID }}
payload: |
{
"blocks": [
{
"type": "header",
"text": {
"type": "plain_text",
"text": "Zowe Nightly Pipeline Daily Report"
}
},
{
"type": "section",
"fields": [
{
"type": "mrkdwn",
"text": "*Version:*\n ${{ env.STAGING_VER }}"
},
{
"type": "mrkdwn",
"text": "*Date:*\n ${{ env.TODAYS_DATE }}"
}
]
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "Across all projects in the Zowe organization, there is no new commits occured in the last ${{ env.FORCE_BUILD_TIME_THRESHOLD }} hours. Thus, we skip the build and test today."
}
}
]
}