Skip to content

chore(pr-title): This title should pass pr title checks#124

Merged
chris3ware merged 21 commits intoci-pr-titlefrom
test-pr-title
Feb 13, 2025
Merged

chore(pr-title): This title should pass pr title checks#124
chris3ware merged 21 commits intoci-pr-titlefrom
test-pr-title

Conversation

@chris3ware
Copy link
Copy Markdown
Member

@chris3ware chris3ware commented Feb 11, 2025

PR to test the regex patterns in the pr-title action. The following need to be tested:

  • Subject is sentence case. i.e. starts with an uppercase character
  • Scope is required
  • Max length of title is 72 characters

@chris3ware chris3ware requested a review from a team as a code owner February 11, 2025 21:32
@chris3ware chris3ware changed the title test(pr-title): A PR to Test the new PR title functionality test(pr-title): a PR to Test the new PR title functionality Feb 11, 2025
@3ware 3ware deleted a comment from github-actions Bot Feb 12, 2025
@chris3ware chris3ware changed the title test(pr-title): a PR to Test the new PR title functionality test: A PR to Test the new PR title functionality Feb 12, 2025
@chris3ware chris3ware changed the title test: A PR to Test the new PR title functionality test(pr-title): A PR to Test the new PR title functionality with a really long title that is too long for a commit messages and should be shorter Feb 12, 2025
@chris3ware
Copy link
Copy Markdown
Member Author

The default error message from the pr-title action is not very helpful when the PR title is too long. (it just displays the message advising about the conventional syntax). Going to try and add a custom message for titles being too many characters.

Add a run step to find the length of the PR title. This will be used in
a step to display a custom error message if the title is too long. The
default error message from the action is not helpful in this case.
If the PR title is too long (> 72) then a message is displayed in the
PR comment with this information. In all other cases, the error message
from the action is used.
@chris3ware chris3ware changed the title test(pr-title): A PR to Test the new PR title functionality with a really long title that is too long for a commit messages and should be shorter invalid(pr-title): A PR to Test the new PR title functionality with invalid type Feb 12, 2025
@chris3ware chris3ware changed the title invalid(pr-title): A PR to Test the new PR title functionality with invalid type invalid(pr-title): Invalid type Feb 12, 2025
@chris3ware
Copy link
Copy Markdown
Member Author

The conditional display of the "too long" error message and the "conventional" error message works - but the formatting of the conventional error needs to be fixed.

The comment id should be set to the `created_comment_id` if a comment
was created, otherwise it should be set to the `previous_comment_id`.
@chris3ware chris3ware changed the title invalid(pr-title): Invalid type invalid(pr-title): Invalid type title Feb 12, 2025
The expression within the code block in the PR comment is being
evaluated as a string. The contents of the output should be displayed.
The conditional logic to dynamically generate the message for the pr
comment was too complex. This changes simplifies the logic by setting
the variable if the title is too long and using that, or if the title
is the correct length, using the error message from the semantic pr
action to set the value of the variable. The pr comment action will use
whatever the value is set to - no expression required.
This will always evaluate to true as seen in the previous run. The
length does not need checking because validate PR only runs when the
length is correct. Therefore the comment will be deleted if the syntax
follows the conventional specification.
@chris3ware chris3ware changed the title invalid(pr-title): Invalid type title invalid(pr-title): Invalid type title but really really really really really really really really really really really long Feb 12, 2025
@chris3ware
Copy link
Copy Markdown
Member Author

Propose to split checking the length of the pull request title and checking the conventional syntax into 2 separate jobs.

Why? Because there are too many if statements controlling the execution of steps and logic is becoming overly complex. It is also proving extremely difficult to add the error output of the conventional action to an environment variable - later to be used in the pull request comment. This "just works" when added natively as it was previously.

Job one, will check the length of the pull request title and add a comment to the PR if the length is too long.
Job two, will only run if job one completes and function exactly as it did before we decided to add the length check.

✅ No complicated flow control logic on each step
✅ No regex
✅ Bliss

This simplifies the workflow by creating a separate job to check the
PR title length. The validation job will only run if this job does not
exit. The logic before with regex and if statements was too complex.
@chris3ware
Copy link
Copy Markdown
Member Author

Successful length check

Screenshot 2025-02-13 at 08 48 27

@chris3ware chris3ware changed the title invalid(pr-title): Invalid type title but really really really really really really really really really really really long chore(pr-title): test lower case subject Feb 13, 2025
@chris3ware
Copy link
Copy Markdown
Member Author

Successful lower case subject test

Screenshot 2025-02-13 at 08 51 29

@chris3ware chris3ware changed the title chore(pr-title): test lower case subject chore: Test no scope Feb 13, 2025
@chris3ware
Copy link
Copy Markdown
Member Author

Successful empty scope test

Screenshot 2025-02-13 at 08 53 30

@chris3ware chris3ware changed the title chore: Test no scope chore(pr-title): This title should pass pr title checks Feb 13, 2025
@chris3ware chris3ware merged commit a1f5da7 into ci-pr-title Feb 13, 2025
@chris3ware chris3ware deleted the test-pr-title branch February 13, 2025 09:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant