Skip to content

Add CI Check for Validating PR Template #9782

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
May 16, 2025
Merged

Conversation

mraxays
Copy link
Contributor

@mraxays mraxays commented May 14, 2025

The site content is an example to test the new PR template workflow checking.


This PR adds a GitHub Actions workflow to automatically validate that pull requests follow the required PR template format. This ensures better PR hygiene and consistency by preventing incorrectly filled-out pull requests from being merged. This resolves #9449.

Checks implemented:

  • ✅ PR description includes both required checkboxes:

    • There is reasonable content
    • I have read and accepted
  • ✅ A valid-looking URL is present in the PR body

  • ✅ A non-trivial explanation (at least 10 characters) is included under the content description section

A demo can be seen at https://github.com/mraxays/js.org/pull/1

image

This PR adds a GitHub Actions workflow to automatically validate that pull requests follow the required PR template format.
@mraxays
Copy link
Contributor Author

mraxays commented May 14, 2025

Now you can see in this pr also

Comment on lines 20 to 21
const urlMatch = /https?:\/\/[^\s)]+/i.exec(body);
const urlValid = urlMatch && /^https?:\/\/[^\s]+$/.test(urlMatch[0]);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is going to match the no content / terms and conditions links, not check that the user has actually provided a link

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ya I will make changes

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we move this into the existing validate.yml workflow, renaming the existing job to cnames_active and this one to pr_template?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok

@mraxays
Copy link
Contributor Author

mraxays commented May 15, 2025

@MattIPv4 Hey can you check and verify once

Added

  1. Check both checkboxes
  2. URL must be on the exact "The site content can be seen at ..." line
  3. Explanation must follow the blockquote marker

and also move this into existing validate.yml

mraxays and others added 4 commits May 15, 2025 21:24
Co-authored-by: Matt Cowley <me@mattcowley.co.uk>
Co-authored-by: Matt Cowley <me@mattcowley.co.uk>
Co-authored-by: Matt Cowley <me@mattcowley.co.uk>
Co-authored-by: Matt Cowley <me@mattcowley.co.uk>
@mraxays
Copy link
Contributor Author

mraxays commented May 15, 2025

Suggested All Changes Updated

@MattIPv4 MattIPv4 added CI IMP opportunity to improve CI and removed discussion labels May 15, 2025
@MattIPv4
Copy link
Member

MattIPv4 commented May 15, 2025

@indus does this seem fine to you?

Branch protection will need updating to the new check names to allow this to merge

@indus
Copy link
Member

indus commented May 16, 2025

@MattIPv4
I'm not good with CI stuff and workflows - so I completely trust your opinion on this... From my side I'm happy to give it a try.

Branch protection will need updating to the new check names to allow this to merge

We currently only have the validate step in the branch protection:
grafik

But as I understand it the new checks should be made when a PR gets opened, right? What do I have to do to make this work?

@indus
Copy link
Member

indus commented May 16, 2025

But as I understand it the new checks should be made when a PR gets opened, right? What do I have to do to make this work?
That isn't possible - or is it?

I mean is the idea to give the user feedback on what is missing or is it just to disable the merge button as long as the checks show stuff is missing in the PR (which is a good thing on its own)?

New requesters need to be approved before the workflow runs and tend to ignore the outcome of the CI without a without a direct request telling them what they need to change. Would it be possible to automatically add such a comment in the PR with @user your PR is missing ... after the PR got approved?

@MattIPv4
Copy link
Member

I mean is the idea to give the user feedback on what is missing or is it just to disable the merge button as long as the checks show stuff is missing in the PR (which is a good thing on its own)?

New requesters need to be approved before the workflow runs and tend to ignore the outcome of the CI without a without a direct request telling them what they need to change. Would it be possible to automatically add such a comment in the PR with @user your PR is missing ... after the PR got approved?

Currently this is only going to block merging + show a failure in the Actions run, but I do agree a good follow-up would be to have it automatically comment to ask them for whatever was missing.

But as I understand it the new checks should be made when a PR gets opened, right? What do I have to do to make this work?

That existing validate check requirement needs to be removed, and then the new validate-cnames + validate-pr-template checks need to be added. I have access to do that 👍

@MattIPv4 MattIPv4 merged commit be1396d into js-org:master May 16, 2025
10 of 14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI IMP opportunity to improve CI enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CI for PR template
3 participants