From 577ce7c7bc20605f6c2058234b910a519c65e27c Mon Sep 17 00:00:00 2001 From: MarkAckert <mark.ackert@broadcom.com> Date: Fri, 26 Apr 2024 12:33:36 -0400 Subject: [PATCH 01/15] update cicd with new commenting structure Signed-off-by: MarkAckert <mark.ackert@broadcom.com> --- .github/workflows/build-packaging.yml | 134 +++++++++++--------- .github/workflows/cicd-test.yml | 148 ++++++++++++----------- .github/workflows/pr-comment-cleanup.yml | 77 ++++++++++++ 3 files changed, 228 insertions(+), 131 deletions(-) create mode 100644 .github/workflows/pr-comment-cleanup.yml diff --git a/.github/workflows/build-packaging.yml b/.github/workflows/build-packaging.yml index 1b64e08db8..c2197544ad 100644 --- a/.github/workflows/build-packaging.yml +++ b/.github/workflows/build-packaging.yml @@ -63,10 +63,35 @@ jobs: set-run-conditions: runs-on: ubuntu-latest outputs: + pr-number: ${{ steps.get-pr-num.outputs.result }} pr-labels: ${{ steps.get-labels.outputs.result }} should-build: ${{ steps.check-build.outputs.run_build }} should-test: ${{ steps.check-test.outputs.run_test}} steps: + - name: 'Get PR Number' + id: get-pr-num + uses: actions/github-script@v7 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + if ('${{ github.event_name}}' == 'pull_request') { + return '${{ github.event.pull_request.number }}' + } + else if ('${{ github.event.inputs.ORIGIN_ISSUE_TRIGGER}}' == 'true') { + const res = await github.rest.pulls.list({ + state: 'open', + head: 'zowe:${{ github.ref_name }}', + owner: 'zowe', + repo: 'zowe-install-packaging' + }).then((resp) => { + const pr = resp.data.find((item) => item.head.ref == '${{ github.ref_name }}') + return `${pr.number}` + }) + return res; + } else { + return '' + } + - name: 'Get labels' id: get-labels uses: actions/github-script@v7 @@ -136,19 +161,11 @@ jobs: run: | COMMIT_HASH=$(git rev-parse --verify HEAD) CURRENT_TIME=$(date +%s) - if [[ -z "${{ github.event.pull_request.number }}" ]]; then - # meaning the workflow is NOT triggered from pull_request - # sometimes user can manually trigger a workflow on a branch that a PR is open, - # thus try to find out if a PR is opened against this running branch - pr_num=$(curl -s -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/${{ github.repository }}/pulls?head=${{ github.repository_owner }}:${{ github.ref }} | jq -r '.[] | .number') - if [[ -z "$pr_num" ]]; then - # meaning PR is not open, we collect the branch name - CURRENT_BRANCH=${GITHUB_REF_NAME} - else - CURRENT_BRANCH=PR-$pr_num - fi + if [[ -z "${{ needs.set-run-conditions.outputs.pr-number }}" ]]; then + # meaning PR is not open, we collect the branch name + CURRENT_BRANCH=${GITHUB_REF_NAME} else - CURRENT_BRANCH=PR-${{ github.event.pull_request.number }} + CURRENT_BRANCH=PR-${{ needs.set-run-conditions.outputs.pr-number }} fi sed -e "s#{BUILD_BRANCH}#${CURRENT_BRANCH}#g" \ @@ -231,11 +248,11 @@ jobs: echo INPUTS_KEEP_TEMP_PAX_FOLDER=${{ github.event.inputs.KEEP_TEMP_PAX_FOLDER }} >> $GITHUB_ENV echo BUILD_WHAT=$BUILD_WHAT >> $GITHUB_OUTPUT - - - name: '[Prep 7] Comment on PR to indicate build is started' + + - name: '[Prep 7a] Create build status comment body' uses: actions/github-script@v5 - id: create-comment - if: (github.event_name == 'workflow_dispatch' || github.event_name == 'pull_request') && startsWith(env.CURRENT_BRANCH, 'PR-') + id: create-comment-body + if: ${{ needs.set-run-conditions.outputs.pr-number != '' }} with: github-token: ${{ secrets.GITHUB_TOKEN }} script: | @@ -257,15 +274,29 @@ jobs: const finish_time_UTC = finish_time.toLocaleString('en-GB', { timeZone: 'Europe/London' }).split(', ')[1] + " GMT" const finish_time_PST = finish_time.toLocaleString('en-US', { timeZone: 'America/Los_Angeles' }).split(', ')[1] + " PST" - const prNum='${{ env.CURRENT_BRANCH }}'.split('-')[1] - - const { data: comment } = await github.rest.issues.createComment({ - issue_number: prNum, - owner: context.repo.owner, - repo: context.repo.repo, - body: `${{ steps.process-inputs.outputs.BUILD_WHAT }} build ${context.runNumber} is started, please wait... \n Estimated build time: ${total_bld_time} mins. Check back around: \n ${finish_time_EST} | ${finish_time_CET} | ${finish_time_UTC} | ${finish_time_PST} \n (This comment will get updated once build result is out) \n Link to workflow run: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}` - }); - return comment.id; + return `${{ steps.process-inputs.outputs.BUILD_WHAT }} build ${context.runNumber} is started, please wait... \n Estimated build time: ${total_bld_time} mins. Check back around: \n ${finish_time_EST} | ${finish_time_CET} | ${finish_time_UTC} | ${finish_time_PST} \n (This comment will get updated once build result is out) \n Link to workflow run: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}` + + - name: '[Prep 7b] Find Comment' + uses: peter-evans/find-comment@v3 + if: ${{ steps.create-comment-body.outputs.result != '' }} + id: fc + with: + token: ${{ secrets.GITHUB_TOKEN }} + issue-number: ${{ needs.set-run-conditions.outputs.pr-number }} + comment-author: 'github-actions[bot]' + body-includes: Build status + + - name: '[Prep 7c] Create or update comment' + uses: peter-evans/create-or-update-comment@v4 + if: ${{ steps.create-comment-body.outputs.result != '' }} + with: + token: ${{ secrets.GITHUB_TOKEN }} + comment-id: ${{ steps.fc.outputs.comment-id }} + issue-number: ${{ github.event.pull_request.number }} + body: | + Build status + ${{ steps.create-comment-body.outputs.result }} + edit-mode: replace - name: '[PAX/SMPE Download 1] Download from jfrog according to manifest' timeout-minutes: 5 @@ -393,44 +424,31 @@ jobs: env: DEBUG: 'zowe-actions:shared-actions:publish' - - name: '[Post Prep 7] Update PR comment to indicate build succeeded' - uses: actions/github-script@v5 - if: steps.create-comment.outputs.result != '' && success() - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - script: | - github.rest.issues.updateComment({ - owner: context.repo.owner, - repo: context.repo.repo, - comment_id: ${{ steps.create-comment.outputs.result }}, - body: `${{ steps.process-inputs.outputs.BUILD_WHAT }} build ${context.runNumber} SUCCEEDED. \n Link to workflow run: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}` - }); - - - name: '[Post Prep 7] Update PR comment to indicate build failed' + - name: '[Post Prep 7] Update PR comment to indicate final build status' uses: actions/github-script@v5 - if: steps.create-comment.outputs.result != '' && failure() + if: steps.fc.outputs.comment-id != '' with: github-token: ${{ secrets.GITHUB_TOKEN }} script: | - github.rest.issues.updateComment({ - owner: context.repo.owner, - repo: context.repo.repo, - comment_id: ${{ steps.create-comment.outputs.result }}, - body: `${{ steps.process-inputs.outputs.BUILD_WHAT }} build ${context.runNumber} FAILED. \n Link to workflow run: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}` - }); - - - name: '[Post Prep 7] Update PR comment to indicate build cancelled' - uses: actions/github-script@v5 - if: steps.create-comment.outputs.result != '' && cancelled() + let status = "SUCCEEDED"; + if (${{ contains(steps.*.outcome, 'failure') }} == true) { + status = "FAILED" + } else if (${{ contains(steps.*.outcome, 'cancelled')}} == true) { + status = "CANCELLED" + } + return `${{ steps.process-inputs.outputs.BUILD_WHAT }} build ${context.runNumber} ${status}. \n Link to workflow run: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}` + + - name: '[Post Prep 7b] Create or update comment' + uses: peter-evans/create-or-update-comment@v4 + if: steps.fc.outputs.comment-id != '' with: - github-token: ${{ secrets.GITHUB_TOKEN }} - script: | - github.rest.issues.updateComment({ - owner: context.repo.owner, - repo: context.repo.repo, - comment_id: ${{ steps.create-comment.outputs.result }}, - body: `${{ steps.process-inputs.outputs.BUILD_WHAT }} build ${context.runNumber} CANCELLED. \n Link to workflow run: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}` - }); + token: ${{ secrets.GITHUB_TOKEN }} + comment-id: ${{ steps.fc.outputs.comment-id }} + issue-number: ${{ github.event.pull_request.number }} + body: | + Build status + ${{ steps.create-comment-body.outputs.result }} + edit-mode: replace # only run auto integration tests when the workflow is triggered by pull request # default running Convenience Pax on any zzow server diff --git a/.github/workflows/cicd-test.yml b/.github/workflows/cicd-test.yml index ef54f73d4f..1491745a3b 100644 --- a/.github/workflows/cicd-test.yml +++ b/.github/workflows/cicd-test.yml @@ -127,6 +127,32 @@ jobs: fail-fast: false environment: ${{ matrix.server }} steps: + - name: 'Get PR Number' + id: get-pr-num + uses: actions/github-script@v7 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + if ('${{ github.event_name }}' == 'pull_request') { + return '${{ github.event.pull_request.number }}' + } + else { + const res = await github.rest.pulls.list({ + state: 'open', + head: 'zowe:${{ github.ref_name }}', + owner: 'zowe', + repo: 'zowe-install-packaging' + }).then((resp) => { + if (resp.status < 300) { + const pr = resp.data.find((item) => item.head.ref == '${{ github.ref_name }}') + return `${pr.number}` + } else { + return '' + } + }) + return res; + } + - name: '[Prep 1] Checkout' uses: actions/checkout@v2 @@ -222,10 +248,10 @@ jobs: working-directory: ${{ runner.temp }}/cli run: npm install -g zowe-cli*.tgz - - name: '[Comment] Post comments on PR about what tests are gonna be run' + - name: '[Comment 1] Post comments on PR about what tests are gonna be run' uses: actions/github-script@v5 id: create-comment - if: startsWith(env.CURRENT_BRANCH, 'PR-') + if: ${{ steps.get-pr-num.outputs.result != ''}} with: github-token: ${{ secrets.GITHUB_TOKEN }} script: | @@ -235,7 +261,7 @@ jobs: installTest = 'Convenience Pax' } - var prNum='${{ env.CURRENT_BRANCH }}'.split('-')[1] + var prNum='${{ steps.get-pr-num.outputs.result }}' var body=`Test workflow ${context.runNumber} is started.\n` body += `Running install test: ${installTest} \n` @@ -245,14 +271,29 @@ jobs: body += `ETA: unknown (This ETA will get updated once the machine lock is acquired) \n` body += `Link to workflow run: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}` - const { data: comment } = await github.rest.issues.createComment({ - issue_number: prNum, - owner: context.repo.owner, - repo: context.repo.repo, - body: body - }); + return body - return comment.id; + - name: '[Comment 1] Find Comment' + uses: peter-evans/find-comment@v3 + if: ${{ steps.create-comment.outputs.result != '' }} + id: fc + with: + token: ${{ secrets.GITHUB_TOKEN }} + issue-number: ${{ steps.get-pr-num.outputs.result }} + comment-author: 'github-actions[bot]' + body-includes: Test status + + - name: '[Comment 1] Create or update comment' + uses: peter-evans/create-or-update-comment@v4 + if: ${{ steps.create-comment.outputs.result != '' }} + with: + token: ${{ secrets.GITHUB_TOKEN }} + comment-id: ${{ steps.fc.outputs.comment-id }} + issue-number: ${{ steps.get-pr-num.outputs.result }} + body: | + Test status + ${{ steps.create-comment.outputs.result }} + edit-mode: replace - name: '[LOCK] Lock marist servers' uses: zowe-actions/shared-actions/lock-resource@main @@ -262,7 +303,7 @@ jobs: lock-resource-name: zowe-install-test-${{ steps.more-test-prep.outputs.TEST_SERVER }}-lock lock-avg-retry-interval: 60 - - name: '[Comment] Update comment after lock is acquired' + - name: '[Comment 2] Update comment after lock is acquired' uses: actions/github-script@v5 if: steps.create-comment.outputs.result != '' with: @@ -335,7 +376,7 @@ jobs: github.rest.issues.updateComment({ owner: context.repo.owner, repo: context.repo.repo, - comment_id: ${{ steps.create-comment.outputs.result }}, + comment_id: ${{ steps.fc.outputs.comment-id }}, body: body }); @@ -378,39 +419,20 @@ jobs: name: InstallTestReports-${{ env.TEST_NAME }}-${{ steps.more-test-prep.outputs.TEST_SERVER_NICKNAME }}-${{ github.run_id }}-${{ env.CURRENT_TIME }} path: ${{ env.INSTALL_TEST_PATH }}/reports/ - - name: '[Comment] Update PR comment to indicate test succeeded' + - name: '[Post Prep 7] Update PR comment to indicate final build status' uses: actions/github-script@v5 - if: steps.create-comment.outputs.result != '' && success() + if: steps.fc.outputs.comment-id != '' + id: create-final-status-comment with: github-token: ${{ secrets.GITHUB_TOKEN }} script: | - var installTest = "${{ github.event.inputs.install-test }}" - var eta - if (installTest == '') { - // if null, this is very likely to be triggered by pr auto test - installTest = 'Convenience Pax' - } + let status = "SUCCEEDED"; + if (${{ contains(steps.*.outcome, 'failure') }} == true) { + status = "FAILED" + } else if (${{ contains(steps.*.outcome, 'cancelled')}} == true) { + status = "CANCELLED" + } - var body=`Test workflow ${context.runNumber} is started.\n` - body += `Running install test: ${installTest} \n` - body += `The zowe artifact being used by this test workflow: ${{ steps.more-test-prep.outputs.ZOWE_ARTIFACTORY_FINAL }} \n` - body += `Running on machine: ${{ steps.more-test-prep.outputs.TEST_SERVER }} \n` - body += `Result: SUCCESS \n` - body += `Link to workflow run: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}` - - github.rest.issues.updateComment({ - owner: context.repo.owner, - repo: context.repo.repo, - comment_id: ${{ steps.create-comment.outputs.result }}, - body: body - }); - - - name: '[Comment] Update PR comment to indicate test failed' - uses: actions/github-script@v5 - if: steps.create-comment.outputs.result != '' && failure() - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - script: | var installTest = "${{ github.event.inputs.install-test }}" var eta if (installTest == '') { @@ -422,42 +444,22 @@ jobs: body += `Running install test: ${installTest} \n` body += `The zowe artifact being used by this test workflow: ${{ steps.more-test-prep.outputs.ZOWE_ARTIFACTORY_FINAL }} \n` body += `Running on machine: ${{ steps.more-test-prep.outputs.TEST_SERVER }} \n` - body += `Result: FAILURE \n` + body += `Result: ${status} \n` body += `Link to workflow run: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}` - github.rest.issues.updateComment({ - owner: context.repo.owner, - repo: context.repo.repo, - comment_id: ${{ steps.create-comment.outputs.result }}, - body: body - }); - - - name: '[Comment] Update PR comment to indicate test cancelled' - uses: actions/github-script@v5 - if: steps.create-comment.outputs.result != '' && cancelled() + return body + + - name: '[Post Prep 7b] Create or update comment' + uses: peter-evans/create-or-update-comment@v4 + if: steps.fc.outputs.comment-id != '' with: - github-token: ${{ secrets.GITHUB_TOKEN }} - script: | - var installTest = "${{ github.event.inputs.install-test }}" - var eta - if (installTest == '') { - // if null, this is very likely to be triggered by pr auto test - installTest = 'Convenience Pax' - } - - var body=`Test workflow ${context.runNumber} is started.\n` - body += `Running install test: ${installTest} \n` - body += `The zowe artifact being used by this test workflow: ${{ steps.more-test-prep.outputs.ZOWE_ARTIFACTORY_FINAL }} \n` - body += `Running on machine: ${{ steps.more-test-prep.outputs.TEST_SERVER }} \n` - body += `Result: CANCELLED \n` - body += `Link to workflow run: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}` - - github.rest.issues.updateComment({ - owner: context.repo.owner, - repo: context.repo.repo, - comment_id: ${{ steps.create-comment.outputs.result }}, - body: body - }); + token: ${{ secrets.GITHUB_TOKEN }} + comment-id: ${{ steps.fc.outputs.comment-id }} + issue-number: ${{ steps.get-pr-num.outputs.result }} + body: | + Build status + ${{ steps.create-final-status-comment.outputs.result }} + edit-mode: replace # keep-curl: # runs-on: ubuntu-latest diff --git a/.github/workflows/pr-comment-cleanup.yml b/.github/workflows/pr-comment-cleanup.yml new file mode 100644 index 0000000000..7c191c5d17 --- /dev/null +++ b/.github/workflows/pr-comment-cleanup.yml @@ -0,0 +1,77 @@ +name: PR Comment Cleanup + +permissions: + issues: write + pull-requests: write + +on: + workflow_dispatch: + inputs: + pr-number: + description: The PR number to clean up + type: string + required: true + + +jobs: + + cleanup-pr-comments: + runs-on: ubuntu-latest + + steps: + - name: Repository checkout + uses: actions/checkout@v3 + + - name: Verify Pull Request Metadata + id: pr-check + uses: actions/github-script@v7 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + const res = await github.rest.pulls.get({ + owner: 'zowe', + repo: 'zowe-install-packaging' + pull_number: ${{ github.event.inputs.pr-number }} + }).then((resp) => { + if (resp < 300) { + return 'OK'; + } + return `NOT_FOUND` + }) + return res; + + - name: Remove all comments from github-actions[bot] + uses: actions/github-script@v7 + if: ${{ steps.pr-check.outputs.result == 'OK' }} + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + const comments = await github.rest.issues.listComments({ + owner: 'zowe', + repo: 'zowe-install-packaging', + issue_number: '3812', + }).then((resp) => { + return resp.data; + }); + + comments.filter((comment) => { + console.log(`${comment.user.login}:${comment.id}`); + return comment.user.login === 'github-actions[bot]' + }).forEach(async (comment) => { + console.log(`Deleting ${comment.id}`); + await github.rest.issues.deleteComment({ + owner: 'zowe', + repo: 'zowe-install-packaging', + comment_id: comment.id, + }).then((resp) => { + if (resp.status >= 400) { + console.log(`Error trying to delete ${comment.id}`); + console.log(`${resp.status}`); + } + }) + }) + + + + + From 5ed87a244b47ed65e5b03c057355f679f15dc95a Mon Sep 17 00:00:00 2001 From: MarkAckert <mark.ackert@broadcom.com> Date: Wed, 1 May 2024 11:46:57 -0400 Subject: [PATCH 02/15] remove token from find-comment Signed-off-by: MarkAckert <mark.ackert@broadcom.com> --- .github/workflows/build-packaging.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/build-packaging.yml b/.github/workflows/build-packaging.yml index c2197544ad..f033e88155 100644 --- a/.github/workflows/build-packaging.yml +++ b/.github/workflows/build-packaging.yml @@ -281,7 +281,6 @@ jobs: if: ${{ steps.create-comment-body.outputs.result != '' }} id: fc with: - token: ${{ secrets.GITHUB_TOKEN }} issue-number: ${{ needs.set-run-conditions.outputs.pr-number }} comment-author: 'github-actions[bot]' body-includes: Build status From 0e91aa10273687ca99303b1ed05108d9454944ba Mon Sep 17 00:00:00 2001 From: MarkAckert <mark.ackert@broadcom.com> Date: Wed, 1 May 2024 12:17:26 -0400 Subject: [PATCH 03/15] hard-code to test root cause Signed-off-by: MarkAckert <mark.ackert@broadcom.com> --- .github/workflows/build-packaging.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-packaging.yml b/.github/workflows/build-packaging.yml index f033e88155..2f0b340de3 100644 --- a/.github/workflows/build-packaging.yml +++ b/.github/workflows/build-packaging.yml @@ -281,7 +281,7 @@ jobs: if: ${{ steps.create-comment-body.outputs.result != '' }} id: fc with: - issue-number: ${{ needs.set-run-conditions.outputs.pr-number }} + issue-number: 3813 comment-author: 'github-actions[bot]' body-includes: Build status From f018ceaf6e18f32b3742824e75c59a5f9395649c Mon Sep 17 00:00:00 2001 From: MarkAckert <mark.ackert@broadcom.com> Date: Wed, 1 May 2024 12:28:16 -0400 Subject: [PATCH 04/15] try changing type of pr number Signed-off-by: MarkAckert <mark.ackert@broadcom.com> --- .github/workflows/build-packaging.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-packaging.yml b/.github/workflows/build-packaging.yml index 2f0b340de3..381a7b704b 100644 --- a/.github/workflows/build-packaging.yml +++ b/.github/workflows/build-packaging.yml @@ -75,7 +75,7 @@ jobs: github-token: ${{ secrets.GITHUB_TOKEN }} script: | if ('${{ github.event_name}}' == 'pull_request') { - return '${{ github.event.pull_request.number }}' + return ${{ github.event.pull_request.number }} } else if ('${{ github.event.inputs.ORIGIN_ISSUE_TRIGGER}}' == 'true') { const res = await github.rest.pulls.list({ @@ -85,7 +85,7 @@ jobs: repo: 'zowe-install-packaging' }).then((resp) => { const pr = resp.data.find((item) => item.head.ref == '${{ github.ref_name }}') - return `${pr.number}` + return ${pr.number} }) return res; } else { @@ -281,7 +281,7 @@ jobs: if: ${{ steps.create-comment-body.outputs.result != '' }} id: fc with: - issue-number: 3813 + issue-number: ${{ needs.set-run-conditions.outputs.pr-number }} comment-author: 'github-actions[bot]' body-includes: Build status From 0de2b08a785340a42bef6b553d972d548be889a7 Mon Sep 17 00:00:00 2001 From: MarkAckert <mark.ackert@broadcom.com> Date: Wed, 1 May 2024 12:31:37 -0400 Subject: [PATCH 05/15] fix formatting Signed-off-by: MarkAckert <mark.ackert@broadcom.com> --- .github/workflows/build-packaging.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-packaging.yml b/.github/workflows/build-packaging.yml index 381a7b704b..d8ffc96b41 100644 --- a/.github/workflows/build-packaging.yml +++ b/.github/workflows/build-packaging.yml @@ -85,7 +85,7 @@ jobs: repo: 'zowe-install-packaging' }).then((resp) => { const pr = resp.data.find((item) => item.head.ref == '${{ github.ref_name }}') - return ${pr.number} + return pr.number }) return res; } else { From 956a4013f034e06b5d40b9ef2880f2abd4de7e19 Mon Sep 17 00:00:00 2001 From: MarkAckert <mark.ackert@broadcom.com> Date: Wed, 1 May 2024 12:48:02 -0400 Subject: [PATCH 06/15] fix BUILD_WHAT Signed-off-by: MarkAckert <mark.ackert@broadcom.com> --- .github/workflows/build-packaging.yml | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build-packaging.yml b/.github/workflows/build-packaging.yml index d8ffc96b41..c291651a62 100644 --- a/.github/workflows/build-packaging.yml +++ b/.github/workflows/build-packaging.yml @@ -193,7 +193,6 @@ jobs: } - name: '[Prep 6a] Process labels for ci build (pull, push, comment)' - id: process-labels if: github.event_name != 'workflow_dispatch' run: | BUILD_WHAT="PAX" @@ -216,10 +215,9 @@ jobs: echo "INPUTS_KEEP_TEMP_PAX_FOLDER=${{ contains(fromJson(needs.set-run-conditions.outputs.pr-labels), 'Build: Debug-Remote') }}" >> $GITHUB_ENV - echo BUILD_WHAT=$BUILD_WHAT >> $GITHUB_OUTPUT + echo BUILD_WHAT=$BUILD_WHAT >> $GITHUB_ENV - name: '[Prep 6b] Process github.event.inputs for manually triggered build' - id: process-inputs if: github.event_name == 'workflow_dispatch' run: | BUILD_WHAT="${{ steps.process-labels.outputs.BUILD_WHAT_LABELS }}" @@ -247,7 +245,7 @@ jobs: echo INPUTS_KEEP_TEMP_PAX_FOLDER=${{ github.event.inputs.KEEP_TEMP_PAX_FOLDER }} >> $GITHUB_ENV - echo BUILD_WHAT=$BUILD_WHAT >> $GITHUB_OUTPUT + echo BUILD_WHAT=$BUILD_WHAT >> $GITHUB_ENV - name: '[Prep 7a] Create build status comment body' uses: actions/github-script@v5 @@ -274,7 +272,7 @@ jobs: const finish_time_UTC = finish_time.toLocaleString('en-GB', { timeZone: 'Europe/London' }).split(', ')[1] + " GMT" const finish_time_PST = finish_time.toLocaleString('en-US', { timeZone: 'America/Los_Angeles' }).split(', ')[1] + " PST" - return `${{ steps.process-inputs.outputs.BUILD_WHAT }} build ${context.runNumber} is started, please wait... \n Estimated build time: ${total_bld_time} mins. Check back around: \n ${finish_time_EST} | ${finish_time_CET} | ${finish_time_UTC} | ${finish_time_PST} \n (This comment will get updated once build result is out) \n Link to workflow run: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}` + return `${{ github.env.BUILD_WHAT }} build ${context.runNumber} is started, please wait... \\n Estimated build time: ${total_bld_time} mins. Check back around: \n ${finish_time_EST} | ${finish_time_CET} | ${finish_time_UTC} | ${finish_time_PST} \n (This comment will get updated once build result is out) \n Link to workflow run: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}` - name: '[Prep 7b] Find Comment' uses: peter-evans/find-comment@v3 @@ -435,7 +433,7 @@ jobs: } else if (${{ contains(steps.*.outcome, 'cancelled')}} == true) { status = "CANCELLED" } - return `${{ steps.process-inputs.outputs.BUILD_WHAT }} build ${context.runNumber} ${status}. \n Link to workflow run: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}` + return `${{ github.env.BUILD_WHAT }} build ${context.runNumber} ${status}. \n Link to workflow run: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}` - name: '[Post Prep 7b] Create or update comment' uses: peter-evans/create-or-update-comment@v4 From 2db24f00c7af1faed2cdab23d0c5ecc81adce0dc Mon Sep 17 00:00:00 2001 From: MarkAckert <mark.ackert@broadcom.com> Date: Wed, 1 May 2024 12:50:51 -0400 Subject: [PATCH 07/15] change env context Signed-off-by: MarkAckert <mark.ackert@broadcom.com> --- .github/workflows/build-packaging.yml | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build-packaging.yml b/.github/workflows/build-packaging.yml index c291651a62..14fccbfea5 100644 --- a/.github/workflows/build-packaging.yml +++ b/.github/workflows/build-packaging.yml @@ -55,9 +55,6 @@ on: required: false type: boolean -env: - PR_LABELS: - jobs: set-run-conditions: @@ -272,7 +269,7 @@ jobs: const finish_time_UTC = finish_time.toLocaleString('en-GB', { timeZone: 'Europe/London' }).split(', ')[1] + " GMT" const finish_time_PST = finish_time.toLocaleString('en-US', { timeZone: 'America/Los_Angeles' }).split(', ')[1] + " PST" - return `${{ github.env.BUILD_WHAT }} build ${context.runNumber} is started, please wait... \\n Estimated build time: ${total_bld_time} mins. Check back around: \n ${finish_time_EST} | ${finish_time_CET} | ${finish_time_UTC} | ${finish_time_PST} \n (This comment will get updated once build result is out) \n Link to workflow run: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}` + return `${{ env.BUILD_WHAT }} build ${context.runNumber} is started, please wait... \\n Estimated build time: ${total_bld_time} mins. Check back around: \n ${finish_time_EST} | ${finish_time_CET} | ${finish_time_UTC} | ${finish_time_PST} \n (This comment will get updated once build result is out) \n Link to workflow run: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}` - name: '[Prep 7b] Find Comment' uses: peter-evans/find-comment@v3 @@ -433,7 +430,7 @@ jobs: } else if (${{ contains(steps.*.outcome, 'cancelled')}} == true) { status = "CANCELLED" } - return `${{ github.env.BUILD_WHAT }} build ${context.runNumber} ${status}. \n Link to workflow run: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}` + return `${{ env.BUILD_WHAT }} build ${context.runNumber} ${status}. \n Link to workflow run: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}` - name: '[Post Prep 7b] Create or update comment' uses: peter-evans/create-or-update-comment@v4 From d0871823b89f59f2af8825bdf6aa0b7979bf94f4 Mon Sep 17 00:00:00 2001 From: MarkAckert <mark.ackert@broadcom.com> Date: Wed, 1 May 2024 13:50:38 -0400 Subject: [PATCH 08/15] refactor comment formatting Signed-off-by: MarkAckert <mark.ackert@broadcom.com> --- .github/workflows/build-packaging.yml | 11 +++- .github/workflows/cicd-test.yml | 79 +++++++++++++++------------ 2 files changed, 52 insertions(+), 38 deletions(-) diff --git a/.github/workflows/build-packaging.yml b/.github/workflows/build-packaging.yml index 14fccbfea5..ac08016a99 100644 --- a/.github/workflows/build-packaging.yml +++ b/.github/workflows/build-packaging.yml @@ -269,7 +269,12 @@ jobs: const finish_time_UTC = finish_time.toLocaleString('en-GB', { timeZone: 'Europe/London' }).split(', ')[1] + " GMT" const finish_time_PST = finish_time.toLocaleString('en-US', { timeZone: 'America/Los_Angeles' }).split(', ')[1] + " PST" - return `${{ env.BUILD_WHAT }} build ${context.runNumber} is started, please wait... \\n Estimated build time: ${total_bld_time} mins. Check back around: \n ${finish_time_EST} | ${finish_time_CET} | ${finish_time_UTC} | ${finish_time_PST} \n (This comment will get updated once build result is out) \n Link to workflow run: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}` + return + `${{ env.BUILD_WHAT }} build ${context.runNumber} is started, please wait... + Estimated build time: ${total_bld_time} mins. Check back around: + ${finish_time_EST} | ${finish_time_CET} | ${finish_time_UTC} | ${finish_time_PST} + (This comment will get updated once build result is out) + Link to workflow run: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}` - name: '[Prep 7b] Find Comment' uses: peter-evans/find-comment@v3 @@ -430,7 +435,9 @@ jobs: } else if (${{ contains(steps.*.outcome, 'cancelled')}} == true) { status = "CANCELLED" } - return `${{ env.BUILD_WHAT }} build ${context.runNumber} ${status}. \n Link to workflow run: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}` + return + `${{ env.BUILD_WHAT }} build ${context.runNumber} ${status}. + Link to workflow run: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}` - name: '[Post Prep 7b] Create or update comment' uses: peter-evans/create-or-update-comment@v4 diff --git a/.github/workflows/cicd-test.yml b/.github/workflows/cicd-test.yml index 1491745a3b..ec57258fad 100644 --- a/.github/workflows/cicd-test.yml +++ b/.github/workflows/cicd-test.yml @@ -134,7 +134,7 @@ jobs: github-token: ${{ secrets.GITHUB_TOKEN }} script: | if ('${{ github.event_name }}' == 'pull_request') { - return '${{ github.event.pull_request.number }}' + return ${{ github.event.pull_request.number }} } else { const res = await github.rest.pulls.list({ @@ -145,7 +145,7 @@ jobs: }).then((resp) => { if (resp.status < 300) { const pr = resp.data.find((item) => item.head.ref == '${{ github.ref_name }}') - return `${pr.number}` + return pr.number } else { return '' } @@ -263,15 +263,15 @@ jobs: var prNum='${{ steps.get-pr-num.outputs.result }}' - var body=`Test workflow ${context.runNumber} is started.\n` - body += `Running install test: ${installTest} \n` - body += `The zowe artifact being used by this test workflow: ${{ steps.more-test-prep.outputs.ZOWE_ARTIFACTORY_FINAL }} \n` - body += `Running on machine: ${{ steps.more-test-prep.outputs.TEST_SERVER }} \n` - body += `Acquiring the test server lock first, please wait... \n ` - body += `ETA: unknown (This ETA will get updated once the machine lock is acquired) \n` - body += `Link to workflow run: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}` + return + `Test workflow ${context.runNumber} is started. + Running install test: ${installTest} + The zowe artifact being used by this test workflow: ${{ steps.more-test-prep.outputs.ZOWE_ARTIFACTORY_FINAL }} + Running on machine: ${{ steps.more-test-prep.outputs.TEST_SERVER }} + Acquiring the test server lock first, please wait... + ETA: unknown (This ETA will get updated once the machine lock is acquired) + Link to workflow run: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}` - return body - name: '[Comment 1] Find Comment' uses: peter-evans/find-comment@v3 @@ -305,6 +305,7 @@ jobs: - name: '[Comment 2] Update comment after lock is acquired' uses: actions/github-script@v5 + id: estimate-comment if: steps.create-comment.outputs.result != '' with: github-token: ${{ secrets.GITHUB_TOKEN }} @@ -359,26 +360,31 @@ jobs: } else { eta = 'unknown' + expectedTimeString = `Check back later.` } - var body=`Test workflow ${context.runNumber} is started.\n` - body += `Running install test: ${installTest} \n` - body += `The zowe artifact being used by this test workflow: ${{ steps.more-test-prep.outputs.ZOWE_ARTIFACTORY_FINAL }} \n` - body += `Running on machine: ${{ steps.more-test-prep.outputs.TEST_SERVER }} \n` - body += `Lock acquired, start the test now, please wait... \n ` - body += `ETA: ${eta} mins \n` - if (expectedTimeString != '') { - body += `${expectedTimeString} \n` - } - body += `Result: <PENDING> (will get updated once test is finished) \n` - body += `Link to workflow run: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}` - - github.rest.issues.updateComment({ - owner: context.repo.owner, - repo: context.repo.repo, - comment_id: ${{ steps.fc.outputs.comment-id }}, - body: body - }); + return + `Test workflow ${context.runNumber} is started. + Running install test: ${installTest} + The zowe artifact being used by this test workflow: ${{ steps.more-test-prep.outputs.ZOWE_ARTIFACTORY_FINAL }} + Running on machine: ${{ steps.more-test-prep.outputs.TEST_SERVER }} + Lock acquired, start the test now, please wait... + ETA: ${eta} mins + ${expectedTimeString} + Result: <PENDING> (will get updated once test is finished) + Link to workflow run: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}` + + - name: '[Comment 3] Create or update comment' + uses: peter-evans/create-or-update-comment@v4 + if: steps.fc.outputs.comment-id != '' + with: + token: ${{ secrets.GITHUB_TOKEN }} + comment-id: ${{ steps.fc.outputs.comment-id }} + issue-number: ${{ steps.get-pr-num.outputs.result }} + body: | + Test status + ${{ steps.estimate-comment.outputs.result }} + edit-mode: replace - name: '[Test] Test starts from here' timeout-minutes: 180 @@ -440,14 +446,15 @@ jobs: installTest = 'Convenience Pax' } - var body=`Test workflow ${context.runNumber} is started.\n` - body += `Running install test: ${installTest} \n` - body += `The zowe artifact being used by this test workflow: ${{ steps.more-test-prep.outputs.ZOWE_ARTIFACTORY_FINAL }} \n` - body += `Running on machine: ${{ steps.more-test-prep.outputs.TEST_SERVER }} \n` - body += `Result: ${status} \n` - body += `Link to workflow run: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}` + return + `Test workflow ${context.runNumber} is started. + Running install test: ${installTest} + The zowe artifact being used by this test workflow: ${{ steps.more-test-prep.outputs.ZOWE_ARTIFACTORY_FINAL }} + Running on machine: ${{ steps.more-test-prep.outputs.TEST_SERVER }} + Result: ${status} + Link to workflow run: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}` + - return body - name: '[Post Prep 7b] Create or update comment' uses: peter-evans/create-or-update-comment@v4 @@ -457,7 +464,7 @@ jobs: comment-id: ${{ steps.fc.outputs.comment-id }} issue-number: ${{ steps.get-pr-num.outputs.result }} body: | - Build status + Test status ${{ steps.create-final-status-comment.outputs.result }} edit-mode: replace From 424f2adcac63fb8e58b5a9d3c31604cf6d487dac Mon Sep 17 00:00:00 2001 From: MarkAckert <mark.ackert@broadcom.com> Date: Wed, 1 May 2024 13:54:14 -0400 Subject: [PATCH 09/15] string placement Signed-off-by: MarkAckert <mark.ackert@broadcom.com> --- .github/workflows/build-packaging.yml | 6 ++---- .github/workflows/cicd-test.yml | 9 +++------ 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/.github/workflows/build-packaging.yml b/.github/workflows/build-packaging.yml index ac08016a99..54f23646b8 100644 --- a/.github/workflows/build-packaging.yml +++ b/.github/workflows/build-packaging.yml @@ -269,8 +269,7 @@ jobs: const finish_time_UTC = finish_time.toLocaleString('en-GB', { timeZone: 'Europe/London' }).split(', ')[1] + " GMT" const finish_time_PST = finish_time.toLocaleString('en-US', { timeZone: 'America/Los_Angeles' }).split(', ')[1] + " PST" - return - `${{ env.BUILD_WHAT }} build ${context.runNumber} is started, please wait... + return `${{ env.BUILD_WHAT }} build ${context.runNumber} is started, please wait... Estimated build time: ${total_bld_time} mins. Check back around: ${finish_time_EST} | ${finish_time_CET} | ${finish_time_UTC} | ${finish_time_PST} (This comment will get updated once build result is out) @@ -435,8 +434,7 @@ jobs: } else if (${{ contains(steps.*.outcome, 'cancelled')}} == true) { status = "CANCELLED" } - return - `${{ env.BUILD_WHAT }} build ${context.runNumber} ${status}. + return `${{ env.BUILD_WHAT }} build ${context.runNumber} ${status}. Link to workflow run: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}` - name: '[Post Prep 7b] Create or update comment' diff --git a/.github/workflows/cicd-test.yml b/.github/workflows/cicd-test.yml index ec57258fad..8b150a2e43 100644 --- a/.github/workflows/cicd-test.yml +++ b/.github/workflows/cicd-test.yml @@ -263,8 +263,7 @@ jobs: var prNum='${{ steps.get-pr-num.outputs.result }}' - return - `Test workflow ${context.runNumber} is started. + return `Test workflow ${context.runNumber} is started. Running install test: ${installTest} The zowe artifact being used by this test workflow: ${{ steps.more-test-prep.outputs.ZOWE_ARTIFACTORY_FINAL }} Running on machine: ${{ steps.more-test-prep.outputs.TEST_SERVER }} @@ -363,8 +362,7 @@ jobs: expectedTimeString = `Check back later.` } - return - `Test workflow ${context.runNumber} is started. + return `Test workflow ${context.runNumber} is started. Running install test: ${installTest} The zowe artifact being used by this test workflow: ${{ steps.more-test-prep.outputs.ZOWE_ARTIFACTORY_FINAL }} Running on machine: ${{ steps.more-test-prep.outputs.TEST_SERVER }} @@ -446,8 +444,7 @@ jobs: installTest = 'Convenience Pax' } - return - `Test workflow ${context.runNumber} is started. + return `Test workflow ${context.runNumber} is started. Running install test: ${installTest} The zowe artifact being used by this test workflow: ${{ steps.more-test-prep.outputs.ZOWE_ARTIFACTORY_FINAL }} Running on machine: ${{ steps.more-test-prep.outputs.TEST_SERVER }} From b569a9fc8e4c8fbdeb83becef59320fa4740913a Mon Sep 17 00:00:00 2001 From: MarkAckert <mark.ackert@broadcom.com> Date: Wed, 1 May 2024 14:07:52 -0400 Subject: [PATCH 10/15] use files instead of github_output for comments Signed-off-by: MarkAckert <mark.ackert@broadcom.com> --- .github/workflows/build-packaging.yml | 18 +++++++-------- .github/workflows/cicd-test.yml | 32 +++++++++++++-------------- 2 files changed, 24 insertions(+), 26 deletions(-) diff --git a/.github/workflows/build-packaging.yml b/.github/workflows/build-packaging.yml index 54f23646b8..facb9c3e3c 100644 --- a/.github/workflows/build-packaging.yml +++ b/.github/workflows/build-packaging.yml @@ -269,7 +269,9 @@ jobs: const finish_time_UTC = finish_time.toLocaleString('en-GB', { timeZone: 'Europe/London' }).split(', ')[1] + " GMT" const finish_time_PST = finish_time.toLocaleString('en-US', { timeZone: 'America/Los_Angeles' }).split(', ')[1] + " PST" - return `${{ env.BUILD_WHAT }} build ${context.runNumber} is started, please wait... + const fs = require('fs'); + fs.writeFileSync('/tmp/comment.txt', `Build status + ${{ env.BUILD_WHAT }} build ${context.runNumber} is started, please wait... Estimated build time: ${total_bld_time} mins. Check back around: ${finish_time_EST} | ${finish_time_CET} | ${finish_time_UTC} | ${finish_time_PST} (This comment will get updated once build result is out) @@ -291,9 +293,7 @@ jobs: token: ${{ secrets.GITHUB_TOKEN }} comment-id: ${{ steps.fc.outputs.comment-id }} issue-number: ${{ github.event.pull_request.number }} - body: | - Build status - ${{ steps.create-comment-body.outputs.result }} + body-path: /tmp/comment.txt edit-mode: replace - name: '[PAX/SMPE Download 1] Download from jfrog according to manifest' @@ -434,8 +434,10 @@ jobs: } else if (${{ contains(steps.*.outcome, 'cancelled')}} == true) { status = "CANCELLED" } - return `${{ env.BUILD_WHAT }} build ${context.runNumber} ${status}. - Link to workflow run: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}` + const fs = require('fs'); + fs.writeFileSync('/tmp/comment.txt', `Build status + ${{ env.BUILD_WHAT }} build ${context.runNumber} ${status}. + Link to workflow run: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}` - name: '[Post Prep 7b] Create or update comment' uses: peter-evans/create-or-update-comment@v4 @@ -444,9 +446,7 @@ jobs: token: ${{ secrets.GITHUB_TOKEN }} comment-id: ${{ steps.fc.outputs.comment-id }} issue-number: ${{ github.event.pull_request.number }} - body: | - Build status - ${{ steps.create-comment-body.outputs.result }} + body-path: /tmp/comment.txt edit-mode: replace # only run auto integration tests when the workflow is triggered by pull request diff --git a/.github/workflows/cicd-test.yml b/.github/workflows/cicd-test.yml index 8b150a2e43..7a65c3e7da 100644 --- a/.github/workflows/cicd-test.yml +++ b/.github/workflows/cicd-test.yml @@ -263,13 +263,15 @@ jobs: var prNum='${{ steps.get-pr-num.outputs.result }}' - return `Test workflow ${context.runNumber} is started. + const fs = require('fs'); + fs.writeFileSync('/tmp/comment.txt', `Test status + Test workflow ${context.runNumber} is started. Running install test: ${installTest} The zowe artifact being used by this test workflow: ${{ steps.more-test-prep.outputs.ZOWE_ARTIFACTORY_FINAL }} Running on machine: ${{ steps.more-test-prep.outputs.TEST_SERVER }} Acquiring the test server lock first, please wait... ETA: unknown (This ETA will get updated once the machine lock is acquired) - Link to workflow run: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}` + Link to workflow run: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}`); - name: '[Comment 1] Find Comment' @@ -289,9 +291,7 @@ jobs: token: ${{ secrets.GITHUB_TOKEN }} comment-id: ${{ steps.fc.outputs.comment-id }} issue-number: ${{ steps.get-pr-num.outputs.result }} - body: | - Test status - ${{ steps.create-comment.outputs.result }} + body-path: /tmp/comment.txt edit-mode: replace - name: '[LOCK] Lock marist servers' @@ -361,8 +361,9 @@ jobs: eta = 'unknown' expectedTimeString = `Check back later.` } - - return `Test workflow ${context.runNumber} is started. + const fs = require('fs'); + fs.writeFileSync('/tmp/comment.txt', `Test status + Test workflow ${context.runNumber} is started. Running install test: ${installTest} The zowe artifact being used by this test workflow: ${{ steps.more-test-prep.outputs.ZOWE_ARTIFACTORY_FINAL }} Running on machine: ${{ steps.more-test-prep.outputs.TEST_SERVER }} @@ -370,7 +371,7 @@ jobs: ETA: ${eta} mins ${expectedTimeString} Result: <PENDING> (will get updated once test is finished) - Link to workflow run: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}` + Link to workflow run: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}`); - name: '[Comment 3] Create or update comment' uses: peter-evans/create-or-update-comment@v4 @@ -379,9 +380,7 @@ jobs: token: ${{ secrets.GITHUB_TOKEN }} comment-id: ${{ steps.fc.outputs.comment-id }} issue-number: ${{ steps.get-pr-num.outputs.result }} - body: | - Test status - ${{ steps.estimate-comment.outputs.result }} + body-path: /tmp/comment.txt edit-mode: replace - name: '[Test] Test starts from here' @@ -443,13 +442,14 @@ jobs: // if null, this is very likely to be triggered by pr auto test installTest = 'Convenience Pax' } - - return `Test workflow ${context.runNumber} is started. + const fs = require('fs'); + fs.writeFileSync('/tmp/comment.txt', `Test status + Test workflow ${context.runNumber} is started. Running install test: ${installTest} The zowe artifact being used by this test workflow: ${{ steps.more-test-prep.outputs.ZOWE_ARTIFACTORY_FINAL }} Running on machine: ${{ steps.more-test-prep.outputs.TEST_SERVER }} Result: ${status} - Link to workflow run: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}` + Link to workflow run: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}`); @@ -460,9 +460,7 @@ jobs: token: ${{ secrets.GITHUB_TOKEN }} comment-id: ${{ steps.fc.outputs.comment-id }} issue-number: ${{ steps.get-pr-num.outputs.result }} - body: | - Test status - ${{ steps.create-final-status-comment.outputs.result }} + body-path: /tmp/comment.txt edit-mode: replace # keep-curl: From adaf27dd34861727cb930ac6a0a0875af86b885e Mon Sep 17 00:00:00 2001 From: MarkAckert <mark.ackert@broadcom.com> Date: Wed, 1 May 2024 14:11:17 -0400 Subject: [PATCH 11/15] uncaught syntax errors Signed-off-by: MarkAckert <mark.ackert@broadcom.com> --- .github/workflows/build-packaging.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-packaging.yml b/.github/workflows/build-packaging.yml index facb9c3e3c..bae7ceaf83 100644 --- a/.github/workflows/build-packaging.yml +++ b/.github/workflows/build-packaging.yml @@ -275,7 +275,7 @@ jobs: Estimated build time: ${total_bld_time} mins. Check back around: ${finish_time_EST} | ${finish_time_CET} | ${finish_time_UTC} | ${finish_time_PST} (This comment will get updated once build result is out) - Link to workflow run: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}` + Link to workflow run: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}`); - name: '[Prep 7b] Find Comment' uses: peter-evans/find-comment@v3 @@ -437,7 +437,7 @@ jobs: const fs = require('fs'); fs.writeFileSync('/tmp/comment.txt', `Build status ${{ env.BUILD_WHAT }} build ${context.runNumber} ${status}. - Link to workflow run: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}` + Link to workflow run: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}`); - name: '[Post Prep 7b] Create or update comment' uses: peter-evans/create-or-update-comment@v4 From 510ea9244d06a18f80ab4810507c3fbd2d887972 Mon Sep 17 00:00:00 2001 From: MarkAckert <mark.ackert@broadcom.com> Date: Wed, 1 May 2024 14:14:05 -0400 Subject: [PATCH 12/15] maintain correct trigger behavior Signed-off-by: MarkAckert <mark.ackert@broadcom.com> --- .github/workflows/build-packaging.yml | 3 +++ .github/workflows/cicd-test.yml | 8 ++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-packaging.yml b/.github/workflows/build-packaging.yml index bae7ceaf83..6ba9940a15 100644 --- a/.github/workflows/build-packaging.yml +++ b/.github/workflows/build-packaging.yml @@ -276,6 +276,7 @@ jobs: ${finish_time_EST} | ${finish_time_CET} | ${finish_time_UTC} | ${finish_time_PST} (This comment will get updated once build result is out) Link to workflow run: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}`); + return 'OK' - name: '[Prep 7b] Find Comment' uses: peter-evans/find-comment@v3 @@ -438,6 +439,8 @@ jobs: fs.writeFileSync('/tmp/comment.txt', `Build status ${{ env.BUILD_WHAT }} build ${context.runNumber} ${status}. Link to workflow run: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}`); + return 'OK' + - name: '[Post Prep 7b] Create or update comment' uses: peter-evans/create-or-update-comment@v4 diff --git a/.github/workflows/cicd-test.yml b/.github/workflows/cicd-test.yml index 7a65c3e7da..3eed4767ea 100644 --- a/.github/workflows/cicd-test.yml +++ b/.github/workflows/cicd-test.yml @@ -272,7 +272,8 @@ jobs: Acquiring the test server lock first, please wait... ETA: unknown (This ETA will get updated once the machine lock is acquired) Link to workflow run: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}`); - + + return 'OK' - name: '[Comment 1] Find Comment' uses: peter-evans/find-comment@v3 @@ -372,6 +373,8 @@ jobs: ${expectedTimeString} Result: <PENDING> (will get updated once test is finished) Link to workflow run: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}`); + + return 'OK' - name: '[Comment 3] Create or update comment' uses: peter-evans/create-or-update-comment@v4 @@ -450,7 +453,8 @@ jobs: Running on machine: ${{ steps.more-test-prep.outputs.TEST_SERVER }} Result: ${status} Link to workflow run: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}`); - + + return 'OK' - name: '[Post Prep 7b] Create or update comment' From c6e396ec6fca111b74fb298baf0a3bb59e106e98 Mon Sep 17 00:00:00 2001 From: MarkAckert <mark.ackert@broadcom.com> Date: Wed, 1 May 2024 16:07:12 -0400 Subject: [PATCH 13/15] always run pr comment after failed test Signed-off-by: MarkAckert <mark.ackert@broadcom.com> --- .github/workflows/cicd-test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/cicd-test.yml b/.github/workflows/cicd-test.yml index 3eed4767ea..3a2f402437 100644 --- a/.github/workflows/cicd-test.yml +++ b/.github/workflows/cicd-test.yml @@ -427,7 +427,7 @@ jobs: - name: '[Post Prep 7] Update PR comment to indicate final build status' uses: actions/github-script@v5 - if: steps.fc.outputs.comment-id != '' + if: always() id: create-final-status-comment with: github-token: ${{ secrets.GITHUB_TOKEN }} @@ -459,7 +459,7 @@ jobs: - name: '[Post Prep 7b] Create or update comment' uses: peter-evans/create-or-update-comment@v4 - if: steps.fc.outputs.comment-id != '' + if: always() with: token: ${{ secrets.GITHUB_TOKEN }} comment-id: ${{ steps.fc.outputs.comment-id }} From 9d99485e138c1348b2c7d1de63add30913a90a9f Mon Sep 17 00:00:00 2001 From: MarkAckert <mark.ackert@broadcom.com> Date: Thu, 2 May 2024 11:19:25 -0400 Subject: [PATCH 14/15] add ids to steps so they appear in steps.* Signed-off-by: MarkAckert <mark.ackert@broadcom.com> --- .github/workflows/cicd-test.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/cicd-test.yml b/.github/workflows/cicd-test.yml index 3a2f402437..b68e4bf5d3 100644 --- a/.github/workflows/cicd-test.yml +++ b/.github/workflows/cicd-test.yml @@ -228,6 +228,7 @@ jobs: npm run lint - name: '[Download 1] Download zowe.pax or smpe-zowe.zip' + id: download-server-artifacts uses: zowe-actions/shared-actions/jfrog-download@main with: source-path-or-pattern: ${{ steps.more-test-prep.outputs.ZOWE_ARTIFACTORY_FINAL }} @@ -236,6 +237,7 @@ jobs: expected-count: 1 - name: '[Download 2] Download cli package' + id: download-cli-artifacts uses: zowe-actions/shared-actions/jfrog-download@main with: source-path-or-pattern: ${{ steps.more-test-prep.outputs.ZOWE_CLI_ARTIFACTORY_FINAL }} @@ -296,6 +298,7 @@ jobs: edit-mode: replace - name: '[LOCK] Lock marist servers' + id: lock-system uses: zowe-actions/shared-actions/lock-resource@main with: lock-repository: ${{ github.repository }} @@ -387,6 +390,7 @@ jobs: edit-mode: replace - name: '[Test] Test starts from here' + id: test-suite timeout-minutes: 180 working-directory: ${{ env.INSTALL_TEST_PATH }} run: npm test -- --testPathPattern --detectOpenHandles dist/__tests__/$(echo "${{ matrix.test }}" | sed "s/.ts/.js/g") From a24cd3693ff70f698584c50f371f056d990b7fbb Mon Sep 17 00:00:00 2001 From: MarkAckert <mark.ackert@broadcom.com> Date: Thu, 13 Jun 2024 14:35:44 -0400 Subject: [PATCH 15/15] remove hardcoded pr number Signed-off-by: MarkAckert <mark.ackert@broadcom.com> --- .github/workflows/pr-comment-cleanup.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr-comment-cleanup.yml b/.github/workflows/pr-comment-cleanup.yml index 7c191c5d17..53e2869b32 100644 --- a/.github/workflows/pr-comment-cleanup.yml +++ b/.github/workflows/pr-comment-cleanup.yml @@ -49,7 +49,7 @@ jobs: const comments = await github.rest.issues.listComments({ owner: 'zowe', repo: 'zowe-install-packaging', - issue_number: '3812', + issue_number: '${{ github.event.inputs.pr-number }}', }).then((resp) => { return resp.data; });