From 8ff010d392afb3aa4890ba8d1c72e398c98dd066 Mon Sep 17 00:00:00 2001 From: Damian Swan AAHS Date: Sun, 3 Dec 2023 21:24:31 -0500 Subject: [PATCH 01/26] Delete .github/workflows/checkmarx-one.yml Signed-off-by: Damian Swan AAHS --- .github/workflows/checkmarx-one.yml | 55 ----------------------------- 1 file changed, 55 deletions(-) delete mode 100644 .github/workflows/checkmarx-one.yml diff --git a/.github/workflows/checkmarx-one.yml b/.github/workflows/checkmarx-one.yml deleted file mode 100644 index 46e19a82..00000000 --- a/.github/workflows/checkmarx-one.yml +++ /dev/null @@ -1,55 +0,0 @@ -# This workflow uses actions that are not certified by GitHub. -# They are provided by a third-party and are governed by -# separate terms of service, privacy policy, and support -# documentation. - -# The Checkmarx One GitHub Action enables you to trigger SAST, SCA, and KICS scans directly from the GitHub workflow. -# It provides a wrapper around the Checkmarx One CLI Tool which creates a zip archive from your source code repository -# and uploads it to Checkmarx One for scanning. The Github Action provides easy integration with GitHub while enabling -# scan customization using the full functionality and flexibility of the CLI tool. - -# This is a basic workflow to help you get started with Using Checkmarx One Action, -# documentation can be found here : https://checkmarx.com/resource/documents/en/34965-68702-checkmarx-one-github-actions.html - -name: Checkmarx Scan - -# Controls when the workflow will run -on: - pull_request: - types: [opened, reopened, synchronize] - branches: [ "main", source ] - -permissions: - contents: read - -# A workflow run is made up of one or more jobs that can run sequentially or in parallel -jobs: - # This workflow contains a single job called "build" - build: - permissions: - contents: read # for actions/checkout to fetch code - security-events: write # for github/codeql-action/upload-sarif to upload SARIF results - actions: read # only required for a private repository by github/codeql-action/upload-sarif - - # The type of runner that the job will run on - runs-on: ubuntu-latest - - # Steps represent a sequence of tasks that will be executed as part of the job - steps: - # This step checks out a copy of your repository. - - name: Checkout repository - uses: actions/checkout@v3 - # This step creates the Checkmarx One scan - - name: Checkmarx One scan - uses: checkmarx/ast-github-action@8e887bb93dacc44e0f5b64ee2b06d5815f89d4fc - with: - base_uri: https://ast.checkmarx.net # This should be replaced by your base uri for Checkmarx One - cx_client_id: ${{ secrets.CX_CLIENT_ID }} # This should be created within your Checkmarx One account : https://checkmarx.com/resource/documents/en/34965-118315-authentication-for-checkmarx-one-cli.html#UUID-a4e31a96-1f36-6293-e95a-97b4b9189060_UUID-4123a2ff-32d0-2287-8dd2-3c36947f675e - cx_client_secret: ${{ secrets.CX_CLIENT_SECRET }} # This should be created within your Checkmarx One account : https://checkmarx.com/resource/documents/en/34965-118315-authentication-for-checkmarx-one-cli.html#UUID-a4e31a96-1f36-6293-e95a-97b4b9189060_UUID-4123a2ff-32d0-2287-8dd2-3c36947f675e - cx_tenant: ${{ secrets.CX_TENANT }} # This should be replaced by your tenant for Checkmarx One - additional_params: --report-format sarif --output-path . - - name: Upload SARIF file - uses: github/codeql-action/upload-sarif@v2 - with: - # Path to SARIF file relative to the root of the repository - sarif_file: cx_result.sarif From b43ad177b784b2defc932ad5122890bc042e30aa Mon Sep 17 00:00:00 2001 From: Damian Swan AAHS Date: Sun, 3 Dec 2023 21:25:19 -0500 Subject: [PATCH 02/26] Delete .github/workflows/label.yml Signed-off-by: Damian Swan AAHS --- .github/workflows/label.yml | 22 ---------------------- 1 file changed, 22 deletions(-) delete mode 100644 .github/workflows/label.yml diff --git a/.github/workflows/label.yml b/.github/workflows/label.yml deleted file mode 100644 index 46135690..00000000 --- a/.github/workflows/label.yml +++ /dev/null @@ -1,22 +0,0 @@ -# This workflow will triage pull requests and apply a label based on the -# paths that are modified in the pull request. -# -# To use this workflow, you will need to set up a .github/labeler.yml -# file with configuration. For more information, see: -# https://github.com/actions/labeler - -name: Labeler -on: [pull_request_target] - -jobs: - label: - - runs-on: ubuntu-latest - permissions: - contents: read - pull-requests: write - - steps: - - uses: actions/labeler@v4 - with: - repo-token: "${{ secrets.GITHUB_TOKEN }}" From d6d42721a413b0391b46cb0f6be87c734255a816 Mon Sep 17 00:00:00 2001 From: Damian Swan AAHS Date: Sun, 3 Dec 2023 21:35:17 -0500 Subject: [PATCH 03/26] Create LGTM.yml Signed-off-by: Damian Swan AAHS --- .github/workflows/LGTM.yml | 66 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 .github/workflows/LGTM.yml diff --git a/.github/workflows/LGTM.yml b/.github/workflows/LGTM.yml new file mode 100644 index 00000000..6e2f2eae --- /dev/null +++ b/.github/workflows/LGTM.yml @@ -0,0 +1,66 @@ +name: LGTM Workflow + +on: + pull_request: + types: [opened, synchronize, reopened] + +jobs: + check_comments: + runs-on: ubuntu-latest + steps: + - name: Check for LGTM comment + id: check + uses: actions/github-script@v5 + with: + script: | + const prNumber = context.payload.pull_request.number; + const repo = context.repo; + + if (context.payload.pull_request.draft) { + console.log('This is a draft PR, skipping checks.'); + return false; + } + + const comments = await github.issues.listComments({ + owner: repo.owner, + repo: repo.repo, + issue_number: prNumber + }); + + for (const comment of comments.data) { + if (comment.body.toLowerCase() === 'lgtm') { + await github.reactions.createForIssueComment({ + owner: repo.owner, + repo: repo.repo, + comment_id: comment.id, + content: '+1', + }); + return true; + } + } + + return false; + + - name: Approve or request changes + uses: actions/github-script@v5 + with: + script: | + const prNumber = context.payload.pull_request.number; + const repo = context.repo; + + if (steps.check.outputs.result === 'true') { + await github.pulls.createReview({ + owner: repo.owner, + repo: repo.repo, + pull_number: prNumber, + event: 'APPROVE' + }); + } else { + await github.pulls.createReview({ + owner: repo.owner, + repo: repo.repo, + pull_number: prNumber, + event: 'REQUEST_CHANGES', + body: 'The check failed because no LGTM comment was found.' + }); + } From bf05eb06296786387331de99e92c35e70a70cacb Mon Sep 17 00:00:00 2001 From: Damian Swan AAHS Date: Sun, 3 Dec 2023 21:38:15 -0500 Subject: [PATCH 04/26] Recip Steps to Same Job Origin Signed-off-by: Damian Swan AAHS --- .github/workflows/LGTM.yml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/.github/workflows/LGTM.yml b/.github/workflows/LGTM.yml index 6e2f2eae..3e251a0d 100644 --- a/.github/workflows/LGTM.yml +++ b/.github/workflows/LGTM.yml @@ -27,6 +27,8 @@ jobs: issue_number: prNumber }); + let found = false; + for (const comment of comments.data) { if (comment.body.toLowerCase() === 'lgtm') { await github.reactions.createForIssueComment({ @@ -35,11 +37,12 @@ jobs: comment_id: comment.id, content: '+1', }); - return true; + found = true; + break; } } - return false; + return found; - name: Approve or request changes uses: actions/github-script@v5 @@ -47,8 +50,9 @@ jobs: script: | const prNumber = context.payload.pull_request.number; const repo = context.repo; + const found = steps.check.outputs.result === 'true'; - if (steps.check.outputs.result === 'true') { + if (found) { await github.pulls.createReview({ owner: repo.owner, repo: repo.repo, From ea6b2ae0465fb3fe2f4dc96d6a8bf86bb92d923e Mon Sep 17 00:00:00 2001 From: Damian Swan AAHS Date: Sun, 3 Dec 2023 21:44:28 -0500 Subject: [PATCH 05/26] Hotfix yml to match standards SupRep according to fabricator Signed-off-by: Damian Swan AAHS --- .github/workflows/LGTM.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/LGTM.yml b/.github/workflows/LGTM.yml index 3e251a0d..9a602963 100644 --- a/.github/workflows/LGTM.yml +++ b/.github/workflows/LGTM.yml @@ -5,7 +5,7 @@ on: types: [opened, synchronize, reopened] jobs: - check_comments: + check_and_review: runs-on: ubuntu-latest steps: - name: Check for LGTM comment @@ -45,6 +45,7 @@ jobs: return found; - name: Approve or request changes + id: review uses: actions/github-script@v5 with: script: | From 724d749f7ca426a254cb93b89245cde3c2896864 Mon Sep 17 00:00:00 2001 From: Damian Swan AAHS Date: Sun, 3 Dec 2023 21:46:33 -0500 Subject: [PATCH 06/26] Run github.steps in env.var Signed-off-by: Damian Swan AAHS --- .github/workflows/LGTM.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/LGTM.yml b/.github/workflows/LGTM.yml index 9a602963..5f7cd7b3 100644 --- a/.github/workflows/LGTM.yml +++ b/.github/workflows/LGTM.yml @@ -43,6 +43,8 @@ jobs: } return found; + env: + LGTM_FOUND: ${{ steps.check.outputs.result }} - name: Approve or request changes id: review @@ -51,7 +53,7 @@ jobs: script: | const prNumber = context.payload.pull_request.number; const repo = context.repo; - const found = steps.check.outputs.result === 'true'; + const found = process.env.LGTM_FOUND === 'true'; if (found) { await github.pulls.createReview({ From eba6272adbe433a238e4a7cfdc5fea4e87002513 Mon Sep 17 00:00:00 2001 From: Damian Swan AAHS Date: Sun, 3 Dec 2023 21:49:22 -0500 Subject: [PATCH 07/26] Use OktoKit to access GITHUB_TOKEN & Github.API Signed-off-by: Damian Swan AAHS --- .github/workflows/LGTM.yml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/workflows/LGTM.yml b/.github/workflows/LGTM.yml index 5f7cd7b3..03cfeb19 100644 --- a/.github/workflows/LGTM.yml +++ b/.github/workflows/LGTM.yml @@ -50,20 +50,25 @@ jobs: id: review uses: actions/github-script@v5 with: + github-token: ${{ secrets.GITHUB_TOKEN }} script: | + const github = require('@actions/github'); + const core = require('@actions/core'); + const context = github.context; const prNumber = context.payload.pull_request.number; const repo = context.repo; const found = process.env.LGTM_FOUND === 'true'; + const octokit = github.getOctokit(core.getInput('github-token')); if (found) { - await github.pulls.createReview({ + await octokit.pulls.createReview({ owner: repo.owner, repo: repo.repo, pull_number: prNumber, event: 'APPROVE' }); } else { - await github.pulls.createReview({ + await octokit.pulls.createReview({ owner: repo.owner, repo: repo.repo, pull_number: prNumber, From 2c7138d0ef99dcd51b8032157e42a2ace9cb2a53 Mon Sep 17 00:00:00 2001 From: Damian Swan AAHS Date: Sun, 3 Dec 2023 21:52:05 -0500 Subject: [PATCH 08/26] Remove Redeclaration of @actions/github Signed-off-by: Damian Swan AAHS --- .github/workflows/LGTM.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/LGTM.yml b/.github/workflows/LGTM.yml index 03cfeb19..e8f2ff5b 100644 --- a/.github/workflows/LGTM.yml +++ b/.github/workflows/LGTM.yml @@ -52,7 +52,6 @@ jobs: with: github-token: ${{ secrets.GITHUB_TOKEN }} script: | - const github = require('@actions/github'); const core = require('@actions/core'); const context = github.context; const prNumber = context.payload.pull_request.number; From fa10de5af29f5434ac9964311b85e370412fbf05 Mon Sep 17 00:00:00 2001 From: Damian Swan AAHS Date: Sun, 3 Dec 2023 21:53:52 -0500 Subject: [PATCH 09/26] Undubplicate @actions/core Signed-off-by: Damian Swan AAHS --- .github/workflows/LGTM.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/LGTM.yml b/.github/workflows/LGTM.yml index e8f2ff5b..c9c358a5 100644 --- a/.github/workflows/LGTM.yml +++ b/.github/workflows/LGTM.yml @@ -52,7 +52,6 @@ jobs: with: github-token: ${{ secrets.GITHUB_TOKEN }} script: | - const core = require('@actions/core'); const context = github.context; const prNumber = context.payload.pull_request.number; const repo = context.repo; From 4380aeaecd83899bf5cc018904aa4e490071e9bf Mon Sep 17 00:00:00 2001 From: Damian Swan AAHS Date: Sun, 3 Dec 2023 21:56:34 -0500 Subject: [PATCH 10/26] Update to remove redundent declarations Signed-off-by: Damian Swan AAHS --- .github/workflows/LGTM.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/LGTM.yml b/.github/workflows/LGTM.yml index c9c358a5..e5b40fb1 100644 --- a/.github/workflows/LGTM.yml +++ b/.github/workflows/LGTM.yml @@ -52,9 +52,6 @@ jobs: with: github-token: ${{ secrets.GITHUB_TOKEN }} script: | - const context = github.context; - const prNumber = context.payload.pull_request.number; - const repo = context.repo; const found = process.env.LGTM_FOUND === 'true'; const octokit = github.getOctokit(core.getInput('github-token')); From 472220932e3ef466beb6ebbd2e268a53bd9e06dd Mon Sep 17 00:00:00 2001 From: Damian Swan AAHS Date: Sun, 3 Dec 2023 22:00:51 -0500 Subject: [PATCH 11/26] Replace OktoKit with def@/github Signed-off-by: Damian Swan AAHS --- .github/workflows/LGTM.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/LGTM.yml b/.github/workflows/LGTM.yml index e5b40fb1..0d016f2e 100644 --- a/.github/workflows/LGTM.yml +++ b/.github/workflows/LGTM.yml @@ -53,17 +53,16 @@ jobs: github-token: ${{ secrets.GITHUB_TOKEN }} script: | const found = process.env.LGTM_FOUND === 'true'; - const octokit = github.getOctokit(core.getInput('github-token')); if (found) { - await octokit.pulls.createReview({ + await github.pulls.createReview({ owner: repo.owner, repo: repo.repo, pull_number: prNumber, event: 'APPROVE' }); } else { - await octokit.pulls.createReview({ + await github.pulls.createReview({ owner: repo.owner, repo: repo.repo, pull_number: prNumber, From 9f1159237b9f959780b1cd212064c213d63d02dd Mon Sep 17 00:00:00 2001 From: Damian Swan AAHS Date: Sun, 3 Dec 2023 22:02:37 -0500 Subject: [PATCH 12/26] Fix Pulls Func Signed-off-by: Damian Swan AAHS --- .github/workflows/LGTM.yml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/LGTM.yml b/.github/workflows/LGTM.yml index 0d016f2e..0255dfa6 100644 --- a/.github/workflows/LGTM.yml +++ b/.github/workflows/LGTM.yml @@ -55,18 +55,17 @@ jobs: const found = process.env.LGTM_FOUND === 'true'; if (found) { - await github.pulls.createReview({ + await github.pulls.createReviewRequest({ owner: repo.owner, repo: repo.repo, pull_number: prNumber, - event: 'APPROVE' + reviewers: ['octocat'] }); } else { - await github.pulls.createReview({ + await github.pulls.requestReviewers({ owner: repo.owner, repo: repo.repo, pull_number: prNumber, - event: 'REQUEST_CHANGES', - body: 'The check failed because no LGTM comment was found.' + reviewers: ['octocat'] }); } From f8b32497adc0970fd6a67cb91ac06a5017ef4027 Mon Sep 17 00:00:00 2001 From: Damian Swan AAHS Date: Sun, 3 Dec 2023 22:05:06 -0500 Subject: [PATCH 13/26] Fix Undefined Var to @ Signed-off-by: Damian Swan AAHS --- .github/workflows/LGTM.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/LGTM.yml b/.github/workflows/LGTM.yml index 0255dfa6..cdc328b3 100644 --- a/.github/workflows/LGTM.yml +++ b/.github/workflows/LGTM.yml @@ -55,11 +55,11 @@ jobs: const found = process.env.LGTM_FOUND === 'true'; if (found) { - await github.pulls.createReviewRequest({ + await github.pulls.createReview({ owner: repo.owner, repo: repo.repo, pull_number: prNumber, - reviewers: ['octocat'] + event: 'APPROVE' }); } else { await github.pulls.requestReviewers({ From 4ac48c74bffa3755a40f70ab11712c039cefe422 Mon Sep 17 00:00:00 2001 From: Damian Swan AAHS Date: Sun, 3 Dec 2023 22:06:13 -0500 Subject: [PATCH 14/26] Checking for unbound modification of @ Signed-off-by: Damian Swan AAHS --- .github/workflows/LGTM.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/LGTM.yml b/.github/workflows/LGTM.yml index cdc328b3..df4ba00b 100644 --- a/.github/workflows/LGTM.yml +++ b/.github/workflows/LGTM.yml @@ -52,6 +52,8 @@ jobs: with: github-token: ${{ secrets.GITHUB_TOKEN }} script: | + const prNumber = context.payload.pull_request.number; + const repo = context.repo; const found = process.env.LGTM_FOUND === 'true'; if (found) { From 57987628656f8b858986dcef52d8de25f1e54e42 Mon Sep 17 00:00:00 2001 From: Damian Swan AAHS Date: Sun, 3 Dec 2023 22:12:06 -0500 Subject: [PATCH 15/26] SImplify @ Signed-off-by: Damian Swan AAHS --- .github/workflows/LGTM.yml | 89 ++++++++++---------------------------- 1 file changed, 23 insertions(+), 66 deletions(-) diff --git a/.github/workflows/LGTM.yml b/.github/workflows/LGTM.yml index df4ba00b..52f3d846 100644 --- a/.github/workflows/LGTM.yml +++ b/.github/workflows/LGTM.yml @@ -1,73 +1,30 @@ -name: LGTM Workflow +name: PR Check on: - pull_request: - types: [opened, synchronize, reopened] + pull_request_target: jobs: - check_and_review: + check-comments: runs-on: ubuntu-latest steps: - - name: Check for LGTM comment - id: check - uses: actions/github-script@v5 - with: - script: | - const prNumber = context.payload.pull_request.number; - const repo = context.repo; - - if (context.payload.pull_request.draft) { - console.log('This is a draft PR, skipping checks.'); - return false; - } - - const comments = await github.issues.listComments({ - owner: repo.owner, - repo: repo.repo, - issue_number: prNumber - }); - - let found = false; - - for (const comment of comments.data) { - if (comment.body.toLowerCase() === 'lgtm') { - await github.reactions.createForIssueComment({ - owner: repo.owner, - repo: repo.repo, - comment_id: comment.id, - content: '+1', - }); - found = true; - break; - } - } - - return found; + - name: Get PR details + id: pr + run: | + PR_JSON=$(gh pr view https://github.com/${{ github.repository }}/pull/${{ github.event.pull_request.number }} --json isDraft,comments) + echo "::set-output name=is_draft::$(echo $PR_JSON | jq .isDraft)" + echo "::set-output name=comments::$(echo $PR_JSON | jq -r .comments.nodes[].body)" env: - LGTM_FOUND: ${{ steps.check.outputs.result }} - - - name: Approve or request changes - id: review - uses: actions/github-script@v5 - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - script: | - const prNumber = context.payload.pull_request.number; - const repo = context.repo; - const found = process.env.LGTM_FOUND === 'true'; - - if (found) { - await github.pulls.createReview({ - owner: repo.owner, - repo: repo.repo, - pull_number: prNumber, - event: 'APPROVE' - }); - } else { - await github.pulls.requestReviewers({ - owner: repo.owner, - repo: repo.repo, - pull_number: prNumber, - reviewers: ['octocat'] - }); - } + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Check for LGTM + run: | + if [[ "${{ steps.pr.outputs.is_draft }}" == "true" ]]; then + echo "Draft PR: skipping" + exit 0 + fi + if echo "${{ steps.pr.outputs.comments }}" | grep -q "LGTM"; then + echo "Found LGTM comment, check passes" + exit 0 + else + echo "No LGTM comment found, check fails" + exit 1 + fi From d50530d965ce9b7aca158b1d11e3e48114d09020 Mon Sep 17 00:00:00 2001 From: Damian Swan AAHS Date: Sun, 3 Dec 2023 22:14:00 -0500 Subject: [PATCH 16/26] Update LGTM.yml Signed-off-by: Damian Swan AAHS --- .github/workflows/LGTM.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/LGTM.yml b/.github/workflows/LGTM.yml index 52f3d846..7200ddb8 100644 --- a/.github/workflows/LGTM.yml +++ b/.github/workflows/LGTM.yml @@ -2,6 +2,7 @@ name: PR Check on: pull_request_target: + types: [opened, synchronize, reopened] jobs: check-comments: From a02daf78a4d01fa4abb48db204d52d580e6dd7c3 Mon Sep 17 00:00:00 2001 From: Damian Swan AAHS Date: Sun, 3 Dec 2023 22:17:49 -0500 Subject: [PATCH 17/26] Update LGTM.yml Signed-off-by: Damian Swan AAHS --- .github/workflows/LGTM.yml | 48 +++++++++++++++++++------------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/.github/workflows/LGTM.yml b/.github/workflows/LGTM.yml index 7200ddb8..c0b0a560 100644 --- a/.github/workflows/LGTM.yml +++ b/.github/workflows/LGTM.yml @@ -1,31 +1,31 @@ -name: PR Check - +name: LGTM Check on: - pull_request_target: + pull_request: types: [opened, synchronize, reopened] jobs: check-comments: runs-on: ubuntu-latest steps: - - name: Get PR details - id: pr - run: | - PR_JSON=$(gh pr view https://github.com/${{ github.repository }}/pull/${{ github.event.pull_request.number }} --json isDraft,comments) - echo "::set-output name=is_draft::$(echo $PR_JSON | jq .isDraft)" - echo "::set-output name=comments::$(echo $PR_JSON | jq -r .comments.nodes[].body)" - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Check for LGTM - run: | - if [[ "${{ steps.pr.outputs.is_draft }}" == "true" ]]; then - echo "Draft PR: skipping" - exit 0 - fi - if echo "${{ steps.pr.outputs.comments }}" | grep -q "LGTM"; then - echo "Found LGTM comment, check passes" - exit 0 - else - echo "No LGTM comment found, check fails" - exit 1 - fi + - name: Check for LGTM comment + uses: actions/github-script@v5 + with: + script: | + const issue_number = context.issue.number; + const owner = context.repo.owner; + const repo = context.repo.repo; + + const comments = await github.rest.issues.listComments({ + issue_number: issue_number, + owner: owner, + repo: repo + }); + + for (const comment of comments.data) { + if (comment.body.includes('LGTM')) { + console.log('LGTM comment found!'); + return; + } + } + + throw new Error('No LGTM comment found!'); From 2ebba3f46ceaabb544bda3148418e58f28880344 Mon Sep 17 00:00:00 2001 From: Damian Swan AAHS Date: Sun, 3 Dec 2023 22:20:02 -0500 Subject: [PATCH 18/26] Check if Draft PR Signed-off-by: Damian Swan AAHS --- .github/workflows/LGTM.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/.github/workflows/LGTM.yml b/.github/workflows/LGTM.yml index c0b0a560..31e4ff8d 100644 --- a/.github/workflows/LGTM.yml +++ b/.github/workflows/LGTM.yml @@ -15,6 +15,17 @@ jobs: const owner = context.repo.owner; const repo = context.repo.repo; + const pull_request = await github.rest.pulls.get({ + owner: owner, + repo: repo, + pull_number: issue_number + }); + + if (pull_request.data.draft) { + console.log('Pull request is a draft, passing check.'); + return; + } + const comments = await github.rest.issues.listComments({ issue_number: issue_number, owner: owner, From 1e21c9cf634e70d7a1baedfcdecc80d4eb28f38b Mon Sep 17 00:00:00 2001 From: Damian Swan AAHS Date: Sun, 3 Dec 2023 22:24:16 -0500 Subject: [PATCH 19/26] Try Luck w/ @github/review Signed-off-by: Damian Swan AAHS --- .github/workflows/LGTM.yml | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/.github/workflows/LGTM.yml b/.github/workflows/LGTM.yml index 31e4ff8d..6556a996 100644 --- a/.github/workflows/LGTM.yml +++ b/.github/workflows/LGTM.yml @@ -15,17 +15,6 @@ jobs: const owner = context.repo.owner; const repo = context.repo.repo; - const pull_request = await github.rest.pulls.get({ - owner: owner, - repo: repo, - pull_number: issue_number - }); - - if (pull_request.data.draft) { - console.log('Pull request is a draft, passing check.'); - return; - } - const comments = await github.rest.issues.listComments({ issue_number: issue_number, owner: owner, @@ -35,8 +24,22 @@ jobs: for (const comment of comments.data) { if (comment.body.includes('LGTM')) { console.log('LGTM comment found!'); + await github.rest.pulls.createReview({ + owner: owner, + repo: repo, + pull_number: issue_number, + event: 'APPROVE', + body: 'LGTM comment found, approving!' + }); return; } } + await github.rest.pulls.createReview({ + owner: owner, + repo: repo, + pull_number: issue_number, + event: 'REQUEST_CHANGES', + body: 'No LGTM comment found, please add one.' + }); throw new Error('No LGTM comment found!'); From c810268b64c595738afd29cb6a7c6de4a23c74bb Mon Sep 17 00:00:00 2001 From: Damian Swan AAHS Date: Sun, 3 Dec 2023 22:36:03 -0500 Subject: [PATCH 20/26] Create HTML.yml Signed-off-by: Damian Swan AAHS --- .github/workflows/HTML.yml | 43 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 .github/workflows/HTML.yml diff --git a/.github/workflows/HTML.yml b/.github/workflows/HTML.yml new file mode 100644 index 00000000..68b63273 --- /dev/null +++ b/.github/workflows/HTML.yml @@ -0,0 +1,43 @@ +name: HTML Prereq +on: + pull_request: + types: [opened, synchronize] + +jobs: + check-html: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Check modified HTML files + id: check + run: | + echo "Checking modified HTML files..." + git diff --name-only HEAD^ | grep '\.html$' | while read html_file; do + echo "Checking $html_file" + missing_lines=() + grep -q '' "$html_file" || missing_lines+=('') + grep -q '
.*
' "$html_file" || missing_lines+=('
and
tag') + grep -q '←Back' "$html_file" || missing_lines+=('←Back') + grep -q '

Updated:

' "$html_file" || missing_lines+=('

Updated:

') + grep -q 'document.getElementById("udate").innerHTML = document.getElementById("udate").innerHTML + document.lastModified;' "$html_file" || missing_lines+=('document.getElementById("udate").innerHTML = document.getElementById("udate").innerHTML + document.lastModified;') + if [ ${#missing_lines[@]} -ne 0 ]; then + echo "::set-output name=review_status::REQUEST_CHANGES" + echo "::set-output name=review_body::Failing review for $html_file due to missing lines: ${missing_lines[@]}" + exit 0 + fi + done + echo "::set-output name=review_status::COMMENT" + echo "::set-output name=review_body::All required lines are present in the modified HTML files." + + - name: Create review + uses: octokit/request-action@v2.x + with: + route: POST /repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/reviews + review_event: ${{ steps.check.outputs.review_status }} + body: ${{ steps.check.outputs.review_body }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 55e5e6e5c65dbf8873702d1b344a3fad316bf686 Mon Sep 17 00:00:00 2001 From: Damian Swan AAHS Date: Sun, 3 Dec 2023 22:37:32 -0500 Subject: [PATCH 21/26] Create empty.html Signed-off-by: Damian Swan AAHS --- empty.html | 1 + 1 file changed, 1 insertion(+) create mode 100644 empty.html diff --git a/empty.html b/empty.html new file mode 100644 index 00000000..8aec60ba --- /dev/null +++ b/empty.html @@ -0,0 +1 @@ +empty test of workflow From 33ce2f7460d3fe1e2060978f8c9c361a40950f0f Mon Sep 17 00:00:00 2001 From: Damian Swan AAHS Date: Sun, 3 Dec 2023 22:38:52 -0500 Subject: [PATCH 22/26] Delete .github/workflows/LGTM.yml Signed-off-by: Damian Swan AAHS --- .github/workflows/LGTM.yml | 45 -------------------------------------- 1 file changed, 45 deletions(-) delete mode 100644 .github/workflows/LGTM.yml diff --git a/.github/workflows/LGTM.yml b/.github/workflows/LGTM.yml deleted file mode 100644 index 6556a996..00000000 --- a/.github/workflows/LGTM.yml +++ /dev/null @@ -1,45 +0,0 @@ -name: LGTM Check -on: - pull_request: - types: [opened, synchronize, reopened] - -jobs: - check-comments: - runs-on: ubuntu-latest - steps: - - name: Check for LGTM comment - uses: actions/github-script@v5 - with: - script: | - const issue_number = context.issue.number; - const owner = context.repo.owner; - const repo = context.repo.repo; - - const comments = await github.rest.issues.listComments({ - issue_number: issue_number, - owner: owner, - repo: repo - }); - - for (const comment of comments.data) { - if (comment.body.includes('LGTM')) { - console.log('LGTM comment found!'); - await github.rest.pulls.createReview({ - owner: owner, - repo: repo, - pull_number: issue_number, - event: 'APPROVE', - body: 'LGTM comment found, approving!' - }); - return; - } - } - - await github.rest.pulls.createReview({ - owner: owner, - repo: repo, - pull_number: issue_number, - event: 'REQUEST_CHANGES', - body: 'No LGTM comment found, please add one.' - }); - throw new Error('No LGTM comment found!'); From b5e2fd426c0e8ae5798ec95f5ffd883c6c22d3e0 Mon Sep 17 00:00:00 2001 From: Damian Swan AAHS Date: Sun, 3 Dec 2023 22:40:04 -0500 Subject: [PATCH 23/26] Update empty.html Signed-off-by: Damian Swan AAHS --- empty.html | 1 + 1 file changed, 1 insertion(+) diff --git a/empty.html b/empty.html index 8aec60ba..cedc7f1f 100644 --- a/empty.html +++ b/empty.html @@ -1 +1,2 @@ +modified for recheq empty test of workflow From 50dd9a0b737ef2e7b0f324668408de1a622f77b5 Mon Sep 17 00:00:00 2001 From: Damian Swan AAHS Date: Sun, 3 Dec 2023 22:42:59 -0500 Subject: [PATCH 24/26] Update HTML.yml Signed-off-by: Damian Swan AAHS --- .github/workflows/HTML.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/HTML.yml b/.github/workflows/HTML.yml index 68b63273..aa53a243 100644 --- a/.github/workflows/HTML.yml +++ b/.github/workflows/HTML.yml @@ -37,7 +37,7 @@ jobs: uses: octokit/request-action@v2.x with: route: POST /repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/reviews - review_event: ${{ steps.check.outputs.review_status }} + event: ${{ steps.check.outputs.review_status }} body: ${{ steps.check.outputs.review_body }} env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 3fe1584f940198b858a56a5ccc225c02d038db19 Mon Sep 17 00:00:00 2001 From: Damian Swan AAHS Date: Sun, 3 Dec 2023 22:50:31 -0500 Subject: [PATCH 25/26] Update HTML.yml Signed-off-by: Damian Swan AAHS --- .github/workflows/HTML.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/HTML.yml b/.github/workflows/HTML.yml index aa53a243..cb018923 100644 --- a/.github/workflows/HTML.yml +++ b/.github/workflows/HTML.yml @@ -33,11 +33,14 @@ jobs: echo "::set-output name=review_status::COMMENT" echo "::set-output name=review_body::All required lines are present in the modified HTML files." + - name: Create review uses: octokit/request-action@v2.x with: - route: POST /repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/reviews - event: ${{ steps.check.outputs.review_status }} + owner: owner, + repo: repo, + pull_number: issue_number, + event: 'REQUEST_CHANGES', body: ${{ steps.check.outputs.review_body }} env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 347b1b26d671336ff97dd5057d51f2874986fe66 Mon Sep 17 00:00:00 2001 From: Damian Swan AAHS Date: Sun, 3 Dec 2023 22:51:20 -0500 Subject: [PATCH 26/26] Delete .github/workflows/HTML.yml Signed-off-by: Damian Swan AAHS --- .github/workflows/HTML.yml | 46 -------------------------------------- 1 file changed, 46 deletions(-) delete mode 100644 .github/workflows/HTML.yml diff --git a/.github/workflows/HTML.yml b/.github/workflows/HTML.yml deleted file mode 100644 index cb018923..00000000 --- a/.github/workflows/HTML.yml +++ /dev/null @@ -1,46 +0,0 @@ -name: HTML Prereq -on: - pull_request: - types: [opened, synchronize] - -jobs: - check-html: - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - - name: Check modified HTML files - id: check - run: | - echo "Checking modified HTML files..." - git diff --name-only HEAD^ | grep '\.html$' | while read html_file; do - echo "Checking $html_file" - missing_lines=() - grep -q '' "$html_file" || missing_lines+=('') - grep -q '
.*
' "$html_file" || missing_lines+=('
and
tag') - grep -q '←Back' "$html_file" || missing_lines+=('←Back') - grep -q '

Updated:

' "$html_file" || missing_lines+=('

Updated:

') - grep -q 'document.getElementById("udate").innerHTML = document.getElementById("udate").innerHTML + document.lastModified;' "$html_file" || missing_lines+=('document.getElementById("udate").innerHTML = document.getElementById("udate").innerHTML + document.lastModified;') - if [ ${#missing_lines[@]} -ne 0 ]; then - echo "::set-output name=review_status::REQUEST_CHANGES" - echo "::set-output name=review_body::Failing review for $html_file due to missing lines: ${missing_lines[@]}" - exit 0 - fi - done - echo "::set-output name=review_status::COMMENT" - echo "::set-output name=review_body::All required lines are present in the modified HTML files." - - - - name: Create review - uses: octokit/request-action@v2.x - with: - owner: owner, - repo: repo, - pull_number: issue_number, - event: 'REQUEST_CHANGES', - body: ${{ steps.check.outputs.review_body }} - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}