-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ci): add PR title check workflow (#12340)
* Add PR title check workflow Add PR title check workflow Add colon Add colon Request change to PR title instead of blocking PR Request change to PR title instead of blocking PR Remove change requested if title conforms to the formate Remove change requested if title conforms to the formate * fix: workflow: Ensure PR title check posts review comments fix: workflow: Ensure PR title check posts review comments * Add fail if title is invalid Add fail if title is invalid * fix: workflow: Ensure PR title check fails for invalid titles fix: workflow: Ensure PR title check fails for invalid titles * refactor: pr-title-check: Streamline workflow and reduce complexity refactor: pr-title-check: Streamline workflow and reduce complexity * Update allowed PR-types pattern Update allowed PR-types pattern * Update pr-title-check.yml Co-authored-by: Rod Vagg <[email protected]> * Use conventional commit, but allow for legacy - Allow optional "[skip changelog]" prefix - Both <type>: <scope>: and <type>(<scope>): formats - Use conventional commit "scope" instead of area - Alphabetize <type> and <scope> * docs: update pull_request_template.md Adjust pull_request_template.md according to the changes introduced with the PR title check workflow * fix(ci): update regex to support both PR title formats fix(ci): update regex to support both PR title formats * docs: seed CONTRIBUTING.md with pr title and changelog expectations (#12361) This starts on #12360 as part of landing #12340 * Update .github/workflows/pr-title-check.yml Co-authored-by: Phi-rjan <[email protected]> * Update CONTRIBUTING.md Co-authored-by: Phi-rjan <[email protected]> * Update CONTRIBUTING.md Co-authored-by: Phi-rjan <[email protected]> * Update CONTRIBUTING.md Co-authored-by: Phi-rjan <[email protected]> --------- Co-authored-by: Phi-rjan <[email protected]> * Update .github/workflows/pr-title-check.yml Co-authored-by: Steve Loeppky <[email protected]> --------- Co-authored-by: Rod Vagg <[email protected]> Co-authored-by: Steve Loeppky <[email protected]>
- Loading branch information
1 parent
d360251
commit 33851e9
Showing
4 changed files
with
75 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
name: PR Title Check | ||
|
||
on: | ||
pull_request: | ||
types: [opened, edited, synchronize, reopened] | ||
|
||
permissions: | ||
pull-requests: write | ||
|
||
jobs: | ||
check-pr-title: | ||
name: Check PR Title | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check PR Title and Manage Review | ||
uses: actions/github-script@v6 | ||
with: | ||
github-token: ${{secrets.GITHUB_TOKEN}} | ||
script: | | ||
const title = context.payload.pull_request.title; | ||
// This should match https://github.com/filecoin-project/lotus/blob/master/README.md#pr-title-conventions | ||
// 202408: Beyond Conventional Commit conventions, we also optionally suport the "scope" outside of paranenthesis for a transitionary period from legacy conventions per https://github.com/filecoin-project/lotus/pull/12340 | ||
const pattern = /^(\[skip changelog\]\s)?(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test)(\(\w+\))?!?:?\s(\w+:)?\s?[a-z].+$/; | ||
if (!pattern.test(title)) { | ||
await github.rest.pulls.createReview({ | ||
...context.repo, | ||
pull_number: context.payload.pull_request.number, | ||
body: 'Please update the PR title to match https://github.com/filecoin-project/lotus/blob/master/README.md#pr-title-conventions', | ||
event: 'REQUEST_CHANGES' | ||
}); | ||
core.setFailed('PR title does not match the required format'); | ||
} else { | ||
const reviews = await github.rest.pulls.listReviews({ | ||
...context.repo, | ||
pull_number: context.payload.pull_request.number | ||
}); | ||
const botReview = reviews.data.find(review => | ||
review.user.type === 'Bot' && | ||
review.state === 'CHANGES_REQUESTED' | ||
); | ||
if (botReview) { | ||
await github.rest.pulls.dismissReview({ | ||
...context.repo, | ||
pull_number: context.payload.pull_request.number, | ||
review_id: botReview.id, | ||
message: 'PR title now matches the required format.' | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
> 2024-08-08: this will get flushed out more soon as part of https://github.com/filecoin-project/lotus/issues/12360 | ||
### PR Title Conventions | ||
PR titles should follow [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) standard. | ||
This means the PR title should be in the form of `<type>(<scope>): <description>` | ||
- example: `fix(mempool): introduce a cache for valid signatures` | ||
- `type`: MUST be one of _build, chore, ci, docs, feat, fix, perf, refactor, revert, style, test_ | ||
- `scope`: OPTIONAL arbitrary string that is usually one of _api, chain, deps, mempool, multisig, networking, paych, proving, sealing, state, wallet_ | ||
- Breaking changes must add a `!` | ||
- Optionally the PR title can be prefixed with `[skip changelog]` if no changelog edits should be made for this change. | ||
Note that this is enforced with https://github.com/filecoin-project/lotus/blob/master/.github/workflows/pr-title-check.yml | ||
|
||
### CHANGELOG Management | ||
To expedite the release process, the CHANGELOG is built-up incrementally. | ||
We enforce that each PR updates CHANGELOG.md or signals that the change doesn't need it. | ||
If the PR affects users (e.g., new feature, bug fix, system requirements change), update the CHANGELOG.md and add details to the UNRELEASED section. | ||
If the change does not require a CHANGELOG.md entry, do one of the following: | ||
- Add `[skip changelog]` to the PR title | ||
- Add the label `skip/changelog` to the PR | ||
Note that this is enforced with https://github.com/filecoin-project/lotus/blob/master/.github/workflows/changelog.yml |