-
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.
Merge branch 'master' of github.com:filecoin-project/lotus
- Loading branch information
Showing
217 changed files
with
6,906 additions
and
2,258 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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
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,60 @@ | ||
name: PR Title Check | ||
|
||
on: | ||
pull_request_target: | ||
types: | ||
- opened | ||
- edited | ||
- reopened | ||
- ready_for_review | ||
|
||
permissions: | ||
pull-requests: write | ||
|
||
jobs: | ||
check-pr-title: | ||
if: github.event.pull_request.draft == false | ||
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/CONTRIBUTING.md#pr-title-conventions', | ||
event: 'REQUEST_CHANGES' | ||
}); | ||
core.setFailed('PR title does not match the required format'); | ||
} else if (context.payload.action === 'edited' && context.payload.changes.title) { | ||
// Only proceed with dismissal if the title was just edited | ||
await new Promise(resolve => setTimeout(resolve, 5000)); // 5 second delay | ||
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
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
Oops, something went wrong.