-
Notifications
You must be signed in to change notification settings - Fork 93
ci: enforce commitlint only on PR titles and descriptions #646
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| name: PR Title Check | ||
|
|
||
| on: | ||
| pull_request_target: | ||
| types: [opened, edited, synchronize, reopened] | ||
| jobs: | ||
| commitlint: | ||
| name: PR title / description conforms to semantic-release | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/setup-node@v6 | ||
| with: | ||
| node-version: "20" | ||
| - run: npm install @commitlint/config-conventional | ||
| - run: > | ||
| echo 'module.exports = { | ||
| // Workaround for https://github.com/dependabot/dependabot-core/issues/5923 | ||
| "ignores": [(message) => /^Bumps \[.+]\(.+\) from .+ to .+\.$/m.test(message)], | ||
| "rules": { | ||
| "body-max-line-length": [0, "always", Infinity], | ||
| "footer-max-line-length": [0, "always", Infinity], | ||
| "body-leading-blank": [0, "always"] | ||
| } | ||
| }' > .commitlintrc.js | ||
| - run: npx commitlint --extends @commitlint/config-conventional --verbose <<< $COMMIT_MSG | ||
| env: | ||
| COMMIT_MSG: > | ||
| ${{ github.event.pull_request.title }} | ||
|
|
||
| ${{ github.event.pull_request.body }} | ||
| - if: failure() | ||
| uses: actions/github-script@v8 | ||
| with: | ||
| script: | | ||
| const message = `**ACTION NEEDED** | ||
|
|
||
| Substrait follows the [Conventional Commits | ||
| specification](https://www.conventionalcommits.org/en/v1.0.0/) for | ||
| release automation. | ||
|
|
||
| The PR title and description are used as the merge commit message.\ | ||
| Please update your PR title and description to match the specification. | ||
| ` | ||
| // Get list of current comments | ||
| const comments = await github.paginate(github.rest.issues.listComments, { | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| issue_number: context.issue.number | ||
| }); | ||
| // Check if this job already commented | ||
| for (const comment of comments) { | ||
| if (comment.body === message) { | ||
| return // Already commented | ||
| } | ||
| } | ||
| // Post the comment about Conventional Commits | ||
| github.rest.issues.createComment({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| issue_number: context.issue.number, | ||
| body: message | ||
| }) | ||
| core.setFailed(message) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wonder if we could make this action simpler by not commenting on the PR? And instead just have the CI/CD check fail? I'm not so particular, this just seems simpler and easier to maintain that way 🤷
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm going to leave the comment for now, as it includes links to the conventional commit standard, which helps users understand what the requirements are explicitly. |
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was copied wholesale from https://github.com/substrait-io/substrait/blob/d1045ad1c080ecc06ea0515a8396644023bda8aa/.github/workflows/pr_breaking.yml