Skip to content

ci: drop external action for checking PR title format#380

Merged
james-garner-canonical merged 4 commits intocanonical:mainfrom
james-garner-canonical:26-03+ci+roll-our-own-semantic-commit-names
Mar 26, 2026
Merged

ci: drop external action for checking PR title format#380
james-garner-canonical merged 4 commits intocanonical:mainfrom
james-garner-canonical:26-03+ci+roll-our-own-semantic-commit-names

Conversation

@james-garner-canonical
Copy link
Collaborator

@james-garner-canonical james-garner-canonical commented Mar 23, 2026

This PR drops the use of an external, third-party action for checking PR title format, replacing it with a small, locally-defined Python script. This has the added security benefit of letting us run this check in the safer pull_request context, rather than on pull_request_target, which the action apparently required for creating a commit status.

I'm proposing the same approach for operator in canonical/operator#2388

@james-garner-canonical james-garner-canonical changed the title ci: drop external action for checking PR title format ci?: drop external action for checking PR title format Mar 23, 2026
@james-garner-canonical james-garner-canonical changed the title ci?: drop external action for checking PR title format ci: drop external action for checking PR title format Mar 23, 2026
@james-garner-canonical james-garner-canonical changed the title ci: drop external action for checking PR title format ci(charmlibs-pathops): drop external action for checking PR title format Mar 23, 2026
@james-garner-canonical james-garner-canonical force-pushed the 26-03+ci+roll-our-own-semantic-commit-names branch from 00c687c to 6a7c739 Compare March 23, 2026 02:12
@james-garner-canonical james-garner-canonical changed the title ci(charmlibs-pathops): drop external action for checking PR title format ci: drop external action for checking PR title format Mar 23, 2026
@james-garner-canonical james-garner-canonical marked this pull request as ready for review March 23, 2026 02:28
@james-garner-canonical james-garner-canonical requested a review from a team as a code owner March 23, 2026 02:28
Copy link
Contributor

@tonyandrewmeyer tonyandrewmeyer left a comment

Choose a reason for hiding this comment

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

I really like this idea, thanks!

I tried this out locally on a few variations and it seems fine to me (a couple of small suggestions based on that). I haven't tried it in actual CI, but I think I understand what it would look like and it seems reasonable to me.

match = _PATTERN.match(title)
if not match:
print(
f'PR title does not follow Conventional Commits format.\n'
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe link them to the relevant doc that explains contributing?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good call, I've added this to both error branches.

if not match:
print(
f'PR title does not follow Conventional Commits format.\n'
f'Expected: <type>[(<scope>)][!]: <description>\n'
Copy link
Contributor

Choose a reason for hiding this comment

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

If you use, for example, Feat instead of feat, you end up here, since it doesn't match [a-z], and the error is a bit confusing, since type doesn't really imply lower-case.

What about making it [A-Za-z]? If you use Feat then you'll get the error that it's not a valid type, but the error message will be more obvious, because you'll see feat in the list.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good idea, done, thanks.

tonyandrewmeyer added a commit to canonical/charmhub-listing-review that referenced this pull request Mar 23, 2026
We currently pull in an external dependency, *and* use the
`pull_request_target` event (it doesn't touch code so should be safe,
but even so), just to validate the PR titles are conventional commits.

I don't think there are enough PRs from external contributors to make
this worthwhile. Even in a repo that does have the enforcement and has
external contributions, like canonical/operator, I've seen most people
just leave the title as-is and have fixed it for them. I think doing
that in this repo is perfectly reasonable; we enforce this though doing
it ourselves rather than automation.

If it does end up being too much work, then a locally made check, like
in canonical/charmlibs#380, seems a safer choice
than bringing in something external just for this.
@james-garner-canonical james-garner-canonical merged commit 824e1ef into canonical:main Mar 26, 2026
312 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants