From feb1e52186a1298d8a90db2cab0a09a04bc91a71 Mon Sep 17 00:00:00 2001 From: Eric Willhoit Date: Tue, 28 Jan 2025 15:27:45 -0600 Subject: [PATCH 1/4] chore: validate pr title --- .github/workflows/validatePR.yml | 65 +++++++++++++++----------------- 1 file changed, 31 insertions(+), 34 deletions(-) diff --git a/.github/workflows/validatePR.yml b/.github/workflows/validatePR.yml index 94e1f50..9a95c6a 100644 --- a/.github/workflows/validatePR.yml +++ b/.github/workflows/validatePR.yml @@ -5,53 +5,50 @@ jobs: if: ${{ !contains(github.event.pull_request.body, '[skip-validate-pr]') && !contains(github.event.pull_request.title, '[skip-validate-pr]') }} runs-on: "ubuntu-latest" steps: - - name: Find GUS Work Item + - name: Find GUS Work Item in Title uses: kaisugi/action-regex-match@45cc5bacf016a4c0d2c3c9d0f8b7c2f1b79687b8 - id: regex-match-gus-wi + id: regex-match-gus-wi-title with: - text: ${{ github.event.pull_request.body }} - regex: '@W-\d{7,8}@' + text: ${{ github.event.pull_request.title }} + regex: 'W-\d{7,8}' flags: gm - - name: Find Github Action Run + - name: Find GUS Work Item in Body uses: kaisugi/action-regex-match@45cc5bacf016a4c0d2c3c9d0f8b7c2f1b79687b8 - id: regex-match-gha-run + id: regex-match-gus-wi-body with: text: ${{ github.event.pull_request.body }} - regex: 'https:\/\/github\.com\/[\w\.-]+\/[\w\.-]+\/actions\/runs\/' + regex: '@W-\d{7,8}@' flags: gm - - name: Find CLI Github Issue - uses: kaisugi/action-regex-match@45cc5bacf016a4c0d2c3c9d0f8b7c2f1b79687b8 - id: regex-match-cli-gh-issue - with: - text: ${{ github.event.pull_request.body }} - regex: 'forcedotcom\/cli\/issues\/[0-9]+|forcedotcom\/salesforcedx-vscode\/issues\/[0-9]+' - flags: gm + # Disabling GHA Run and Github Issue (for now) due to E360 lookup + + # - name: Find Github Action Run + # uses: kaisugi/action-regex-match@45cc5bacf016a4c0d2c3c9d0f8b7c2f1b79687b8 + # id: regex-match-gha-run + # with: + # text: ${{ github.event.pull_request.body }} + # regex: 'https:\/\/github\.com\/[\w\.-]+\/[\w\.-]+\/actions\/runs\/' + # flags: gm + + # - name: Find CLI Github Issue + # uses: kaisugi/action-regex-match@45cc5bacf016a4c0d2c3c9d0f8b7c2f1b79687b8 + # id: regex-match-cli-gh-issue + # with: + # text: ${{ github.event.pull_request.body }} + # regex: 'forcedotcom\/cli\/issues\/[0-9]+|forcedotcom\/salesforcedx-vscode\/issues\/[0-9]+' + # flags: gm - - name: Fail if no references + - name: Fail if no Work Item references if: | github.event.pull_request.user.login != 'dependabot[bot]' && (github.event.pull_request.user.login != 'SF-CLI-BOT' || github.event.pull_request.user.login != 'svc-cli-bot') && - steps.regex-match-gus-wi.outputs.match == '' && - steps.regex-match-gha-run.outputs.match == '' && - steps.regex-match-cli-gh-issue.match == '' + steps.regex-match-gus-wi-title.outputs.match == '' && + steps.regex-match-gus-wi-body.outputs.match == '' run: | - echo "PR does not reference work item or github issue or github action run." - echo "GUS WIs should be wrapped in @s, ex: @W-12345678@ or [@W-12345678@](https://some-url) or include a full GHA run link" + echo "::warning::PRs need to reference a GUS Work Item in both the PR title AND body\n + - PR titles should start with a Work Item followed by a description, ex: W-12345678: My PR title\n + - PR bodies must include a Work Item wrapped in @s, ex: @W-12345678@ or [@W-12345678@](https://some-url)\n + - If you absolutely must skip this validation, add [skip-validate-pr] to the PR title or body" exit 1 - - name: Output matches - if: | - steps.regex-match-gus-wi.outputs.match != '' || - steps.regex-match-gha-run.outputs.match != '' || - steps.regex-match-cli-gh-issue.match != '' - run: | - echo "[INFO] Gus Work Item: $STEPS_GUS_WI" - echo "[INFO] Github Action Run: $STEPS_GHA_RUN" - echo "[INFO] CLI Github Issue: $STEPS_CLI_GH_ISSUE" - env: - STEPS_GUS_WI: ${{ steps.regex-match-gus-wi.outputs.match }} - STEPS_GHA_RUN: ${{ steps.regex-match-gha-run.outputs.match }} - STEPS_CLI_GH_ISSUE: ${{ steps.regex-match-cli-gh-issue.match }} - From 166fe9e37334fdc5184cbe4cda835a0354035f63 Mon Sep 17 00:00:00 2001 From: Eric Willhoit Date: Fri, 31 Jan 2025 09:29:14 -0600 Subject: [PATCH 2/4] chore: tesing newline --- .github/workflows/validatePR.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/validatePR.yml b/.github/workflows/validatePR.yml index 9a95c6a..aa44a05 100644 --- a/.github/workflows/validatePR.yml +++ b/.github/workflows/validatePR.yml @@ -46,9 +46,9 @@ jobs: steps.regex-match-gus-wi-title.outputs.match == '' && steps.regex-match-gus-wi-body.outputs.match == '' run: | - echo "::warning::PRs need to reference a GUS Work Item in both the PR title AND body\n - - PR titles should start with a Work Item followed by a description, ex: W-12345678: My PR title\n - - PR bodies must include a Work Item wrapped in @s, ex: @W-12345678@ or [@W-12345678@](https://some-url)\n + echo "::warning::PRs need to reference a GUS Work Item in both the PR title AND body%0A + - PR titles should start with a Work Item followed by a description, ex: W-12345678: My PR title%0A + - PR bodies must include a Work Item wrapped in @s, ex: @W-12345678@ or [@W-12345678@](https://some-url)%0A - If you absolutely must skip this validation, add [skip-validate-pr] to the PR title or body" exit 1 From 5740977b2762e2b20297aa06cb57dfa67c1b3e9e Mon Sep 17 00:00:00 2001 From: Eric Willhoit Date: Fri, 31 Jan 2025 09:37:14 -0600 Subject: [PATCH 3/4] fix: require in both --- .github/workflows/validatePR.yml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/validatePR.yml b/.github/workflows/validatePR.yml index aa44a05..70c066a 100644 --- a/.github/workflows/validatePR.yml +++ b/.github/workflows/validatePR.yml @@ -43,12 +43,11 @@ jobs: if: | github.event.pull_request.user.login != 'dependabot[bot]' && (github.event.pull_request.user.login != 'SF-CLI-BOT' || github.event.pull_request.user.login != 'svc-cli-bot') && - steps.regex-match-gus-wi-title.outputs.match == '' && - steps.regex-match-gus-wi-body.outputs.match == '' + (steps.regex-match-gus-wi-title.outputs.match == '' || steps.regex-match-gus-wi-body.outputs.match == '') run: | - echo "::warning::PRs need to reference a GUS Work Item in both the PR title AND body%0A - - PR titles should start with a Work Item followed by a description, ex: W-12345678: My PR title%0A - - PR bodies must include a Work Item wrapped in @s, ex: @W-12345678@ or [@W-12345678@](https://some-url)%0A + echo "::warning::PRs need to reference a GUS Work Item in both the PR title AND body. More details in the logs above. + - PR titles should start with a Work Item followed by a description, ex: W-12345678: My PR title + - PR bodies must include a Work Item wrapped in @s, ex: @W-12345678@ or [@W-12345678@](https://some-url) - If you absolutely must skip this validation, add [skip-validate-pr] to the PR title or body" exit 1 From c8f9c48d80d14195b71ebd4db694a8957f57918e Mon Sep 17 00:00:00 2001 From: Eric Willhoit Date: Fri, 31 Jan 2025 09:41:57 -0600 Subject: [PATCH 4/4] chore: ignore case --- .github/workflows/validatePR.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/validatePR.yml b/.github/workflows/validatePR.yml index 70c066a..1374a50 100644 --- a/.github/workflows/validatePR.yml +++ b/.github/workflows/validatePR.yml @@ -11,7 +11,7 @@ jobs: with: text: ${{ github.event.pull_request.title }} regex: 'W-\d{7,8}' - flags: gm + flags: gmi - name: Find GUS Work Item in Body uses: kaisugi/action-regex-match@45cc5bacf016a4c0d2c3c9d0f8b7c2f1b79687b8 @@ -19,7 +19,7 @@ jobs: with: text: ${{ github.event.pull_request.body }} regex: '@W-\d{7,8}@' - flags: gm + flags: gmi # Disabling GHA Run and Github Issue (for now) due to E360 lookup