Skip to content
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

Add GitHub action to check PR for formatted title #6991

Closed

Conversation

sylvainsf
Copy link
Contributor

Description

Checks incoming PRs for nicely formatted title.

Type of change

  • This pull request is a minor refactor, code cleanup, test improvement, or other maintenance task and doesn't change the functionality of Radius (issue link optional).

Auto-generated summary

copilot:all

@sylvainsf sylvainsf requested review from a team as code owners January 4, 2024 18:38
const issue_number = context.payload.pull_request.number;
const owner = context.repo.owner;
const repo = context.repo.repo;
let body = '';
Copy link
Contributor

Choose a reason for hiding this comment

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

This can be defined within the first if. We don't use it outside of the if cases below.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure what you mean, if it's defined in the first if then it's not available in the other cases. Maybe I'm misunderstanding your comment?

Copy link
Contributor

Choose a reason for hiding this comment

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

Apologies for not being very clear. I couldn't see body being used outside of the if case. It can be moved inside the first if I think. Like this:

if (!regex.test(title)) {
            let body = '';
            if (regexNoSpace.test(title)) {
              body = 'Your PR title is missing a space after the keyword. Please update it to: [Add | Remove | Update | Fix] <Title>. For example: Remove Old feature';
            } else if (regexLowerCase.test(title)) {
              body = 'The keyword in your PR title is not capitalized. Please update it to: [Add | Remove | Update | Fix] <Title>. For example: Update Existing feature';
            } else {
              body = 'Your PR does not have a [Add | Remove | Update | Fix] <Title>. Please add one to help streamline our changelog. For example: Fix Bug in feature';
            }
            github.issues.createComment({ issue_number, owner, repo, body });
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's true, though I have a habit of declaring all variables outside of conditionals as it reduces cognitive load to declare everything you're going to work with ahead of the logic.

@shalabhms shalabhms self-requested a review January 4, 2024 23:57
@shalabhms shalabhms changed the title [Add] Create github action to check PR for formatted title Add GitHub action to check PR for formatted title Jan 4, 2024
shalabhms
shalabhms previously approved these changes Jan 4, 2024
} else {
body = 'Your PR does not have a [Add | Remove | Update | Fix] <Title>. Please add one to help streamline our changelog. For example: Fix Bug in feature';
}
github.issues.createComment({ issue_number, owner, repo, body });
Copy link
Contributor

Choose a reason for hiding this comment

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

In addition to adding a comment can we also fail this action? If the action still succeeds we probably can't count on a comment enforcing this behavior.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am of the philosophy to warn first and move to blocking if warning doesn't yield results. Several engineers also expressed concern at blocks causing friction, we can always add blocking in the near future if the comments alone don't work.

Copy link
Contributor

@AaronCrawfis AaronCrawfis Feb 21, 2024

Choose a reason for hiding this comment

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

If we're not going to block on the title, this is a recommendation and not a requirement. If we want consistency in the PR titles, this should be a requirement. If it's a requirement recommendation, what's the ask for reviewers? Ignore the title and approve anyway? If it's anything else, where the reviewer asks the contributor to update the title, then this needs to be a requirement.

Copy link
Contributor

@kachawla kachawla Feb 21, 2024

Choose a reason for hiding this comment

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

I agree with making it a requirement (can be in a quick follow up PR if we want to test this first). I'd also prefer if we expand the keywords to allow verbing (adding/removing) which is very commonly used by many developers.

@sylvainsf sylvainsf force-pushed the sylvainsf-pr-format-check branch from 9e669a7 to 2d0b306 Compare January 10, 2024 17:12
@AaronCrawfis
Copy link
Contributor

Can we also update the contribution documentation to note that PR titles should follow a specific format now? If we want to enforce consistent titles we should make sure we document it.

@radius-functional-tests
Copy link

radius-functional-tests bot commented Feb 21, 2024

Radius functional test overview

🔍 Go to test action run

Name Value
Repository sylvainsf/radius
Commit ref 92c46b7
Unique ID 936d44f9a3
Image tag pr-936d44f9a3
Click here to see the list of tools in the current test run
  • gotestsum 1.10.0
  • KinD: v0.20.0
  • Dapr: 1.12.0
  • Azure KeyVault CSI driver: 1.4.2
  • Azure Workload identity webhook: 1.1.0
  • Bicep recipe location ghcr.io/radius-project/dev/test/functional/shared/recipes/<name>:pr-936d44f9a3
  • Terraform recipe location http://tf-module-server.radius-test-tf-module-server.svc.cluster.local/<name>.zip (in cluster)
  • applications-rp test image location: ghcr.io/radius-project/dev/applications-rp:pr-936d44f9a3
  • controller test image location: ghcr.io/radius-project/dev/controller:pr-936d44f9a3
  • ucp test image location: ghcr.io/radius-project/dev/ucpd:pr-936d44f9a3
  • deployment-engine test image location: ghcr.io/radius-project/deployment-engine:latest

Test Status

⌛ Building Radius and pushing container images for functional tests...
✅ Container images build succeeded
⌛ Publishing Bicep Recipes for functional tests...
✅ Recipe publishing succeeded
⌛ Starting msgrp functional tests...
⌛ Starting kubernetes functional tests...
⌛ Starting ucp functional tests...
⌛ Starting datastoresrp functional tests...
⌛ Starting samples functional tests...
⌛ Starting daprrp functional tests...
⌛ Starting shared functional tests...
✅ msgrp functional tests succeeded
✅ kubernetes functional tests succeeded
✅ samples functional tests succeeded
✅ ucp functional tests succeeded
✅ datastoresrp functional tests succeeded
✅ daprrp functional tests succeeded
✅ shared functional tests succeeded

@sylvainsf
Copy link
Contributor Author

@AaronCrawfis Yes, I'll add that when I add this bot to the documents repo.

@AaronCrawfis
Copy link
Contributor

Yes, I'll add that when I add this bot to the documents repo.

We should update this repo as well here: https://github.com/radius-project/radius/tree/main/docs/contributing/contributing-pull-requests

Copy link

This pull request has been automatically marked as stale because it has been inactive for 90 days. Remove stale label or comment or this PR will be closed in 7 days.

@github-actions github-actions bot added the stale label May 31, 2024
@github-actions github-actions bot closed this Jun 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants