Skip to content

Commit 0dd48f1

Browse files
authored
W-17694802 Validate WI in PR title (#132)
* chore: validate pr title * chore: tesing newline * fix: require in both * chore: ignore case
1 parent 861891f commit 0dd48f1

File tree

1 file changed

+32
-36
lines changed

1 file changed

+32
-36
lines changed

.github/workflows/validatePR.yml

Lines changed: 32 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -5,53 +5,49 @@ jobs:
55
if: ${{ !contains(github.event.pull_request.body, '[skip-validate-pr]') && !contains(github.event.pull_request.title, '[skip-validate-pr]') }}
66
runs-on: "ubuntu-latest"
77
steps:
8-
- name: Find GUS Work Item
8+
- name: Find GUS Work Item in Title
99
uses: kaisugi/action-regex-match@45cc5bacf016a4c0d2c3c9d0f8b7c2f1b79687b8
10-
id: regex-match-gus-wi
10+
id: regex-match-gus-wi-title
1111
with:
12-
text: ${{ github.event.pull_request.body }}
13-
regex: '@W-\d{7,8}@'
14-
flags: gm
12+
text: ${{ github.event.pull_request.title }}
13+
regex: 'W-\d{7,8}'
14+
flags: gmi
1515

16-
- name: Find Github Action Run
16+
- name: Find GUS Work Item in Body
1717
uses: kaisugi/action-regex-match@45cc5bacf016a4c0d2c3c9d0f8b7c2f1b79687b8
18-
id: regex-match-gha-run
18+
id: regex-match-gus-wi-body
1919
with:
2020
text: ${{ github.event.pull_request.body }}
21-
regex: 'https:\/\/github\.com\/[\w\.-]+\/[\w\.-]+\/actions\/runs\/'
22-
flags: gm
21+
regex: '@W-\d{7,8}@'
22+
flags: gmi
2323

24-
- name: Find CLI Github Issue
25-
uses: kaisugi/action-regex-match@45cc5bacf016a4c0d2c3c9d0f8b7c2f1b79687b8
26-
id: regex-match-cli-gh-issue
27-
with:
28-
text: ${{ github.event.pull_request.body }}
29-
regex: 'forcedotcom\/cli\/issues\/[0-9]+|forcedotcom\/salesforcedx-vscode\/issues\/[0-9]+'
30-
flags: gm
24+
# Disabling GHA Run and Github Issue (for now) due to E360 lookup
3125

32-
- name: Fail if no references
26+
# - name: Find Github Action Run
27+
# uses: kaisugi/action-regex-match@45cc5bacf016a4c0d2c3c9d0f8b7c2f1b79687b8
28+
# id: regex-match-gha-run
29+
# with:
30+
# text: ${{ github.event.pull_request.body }}
31+
# regex: 'https:\/\/github\.com\/[\w\.-]+\/[\w\.-]+\/actions\/runs\/'
32+
# flags: gm
33+
34+
# - name: Find CLI Github Issue
35+
# uses: kaisugi/action-regex-match@45cc5bacf016a4c0d2c3c9d0f8b7c2f1b79687b8
36+
# id: regex-match-cli-gh-issue
37+
# with:
38+
# text: ${{ github.event.pull_request.body }}
39+
# regex: 'forcedotcom\/cli\/issues\/[0-9]+|forcedotcom\/salesforcedx-vscode\/issues\/[0-9]+'
40+
# flags: gm
41+
42+
- name: Fail if no Work Item references
3343
if: |
3444
github.event.pull_request.user.login != 'dependabot[bot]' &&
3545
(github.event.pull_request.user.login != 'SF-CLI-BOT' || github.event.pull_request.user.login != 'svc-cli-bot') &&
36-
steps.regex-match-gus-wi.outputs.match == '' &&
37-
steps.regex-match-gha-run.outputs.match == '' &&
38-
steps.regex-match-cli-gh-issue.match == ''
46+
(steps.regex-match-gus-wi-title.outputs.match == '' || steps.regex-match-gus-wi-body.outputs.match == '')
3947
run: |
40-
echo "PR does not reference work item or github issue or github action run."
41-
echo "GUS WIs should be wrapped in @s, ex: @W-12345678@ or [@W-12345678@](https://some-url) or include a full GHA run link"
48+
echo "::warning::PRs need to reference a GUS Work Item in both the PR title AND body. More details in the logs above.
49+
- PR titles should start with a Work Item followed by a description, ex: W-12345678: My PR title
50+
- PR bodies must include a Work Item wrapped in @s, ex: @W-12345678@ or [@W-12345678@](https://some-url)
51+
- If you absolutely must skip this validation, add [skip-validate-pr] to the PR title or body"
4252
exit 1
4353
44-
- name: Output matches
45-
if: |
46-
steps.regex-match-gus-wi.outputs.match != '' ||
47-
steps.regex-match-gha-run.outputs.match != '' ||
48-
steps.regex-match-cli-gh-issue.match != ''
49-
run: |
50-
echo "[INFO] Gus Work Item: $STEPS_GUS_WI"
51-
echo "[INFO] Github Action Run: $STEPS_GHA_RUN"
52-
echo "[INFO] CLI Github Issue: $STEPS_CLI_GH_ISSUE"
53-
env:
54-
STEPS_GUS_WI: ${{ steps.regex-match-gus-wi.outputs.match }}
55-
STEPS_GHA_RUN: ${{ steps.regex-match-gha-run.outputs.match }}
56-
STEPS_CLI_GH_ISSUE: ${{ steps.regex-match-cli-gh-issue.match }}
57-

0 commit comments

Comments
 (0)