Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions .github/workflows/AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# PR Validation Workflows

## Important Considerations

### Synchronization Requirements
- **CRITICAL**: Changes to validation logic MUST be reflected in CONTRIBUTING.md](../../CONTRIBUTING.md). CONTRIBUTING.md and enforcement workflows should be kept in sync.
- Update both enforcement (workflows) AND documentation (CONTRIBUTING.md) together
- Consider impact on existing open PRs when changing validation rules

### GitHub API Limitations
- `pull_request_target` required for write permissions to post reviews
- 5-second delay before dismissing reviews to avoid race conditions
- Bot review detection relies on `user.type === 'Bot'`

### Regex Pattern Gotchas
- Case sensitivity matters: `Revert` vs `revert`
- Escaping required for special characters in descriptions
- JavaScript regex syntax differs from other tools

### Workflow Permissions
- `pr-title-check.yml` needs `pull-requests: write` for reviews
- `changelog.yml` uses default permissions (read-only)
1 change: 1 addition & 0 deletions .github/workflows/CLAUDE.md
2 changes: 1 addition & 1 deletion .github/workflows/changelog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,22 @@

jobs:
changelog:
if: contains(github.event.pull_request.title, '[skip changelog]') == false &&
if: contains(github.event.pull_request.body, '[skip changelog]') == false &&
contains(github.event.pull_request.labels.*.name, 'skip/changelog') == false &&
github.event.pull_request.draft == false
runs-on: ubuntu-latest
name: Changelog
steps:
- id: changelog
env:
GITHUB_TOKEN: ${{ github.token }}
ENDPOINT: repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/files
SELECTOR: 'map(select(.filename == "CHANGELOG.md")) | length'
run: gh api "$ENDPOINT" --jq "$SELECTOR" | xargs -I{} echo "modified={}" | tee -a $GITHUB_OUTPUT
- if: steps.changelog.outputs.modified == '0'
env:
MESSAGE: |
docs/changelogs/ was not modified in this PR. Please do one of the options in [changelog management conventions](https://github.com/filecoin-project/lotus/blob/master/CONTRIBUTING.md#changelog-management)
run: |
echo "::error::${MESSAGE//$'\n'/%0A}"
exit 1

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {}
9 changes: 6 additions & 3 deletions .github/workflows/pr-title-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,12 @@ jobs:
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].+$/;
// This should match https://github.com/filecoin-project/lotus/blob/master/CONTRIBUTING.md#pr-title-conventions
// 202408: Beyond Conventional Commit conventions, we also optionally support the "scope" outside of parenthesis for a transitionary period from legacy conventions per https://github.com/filecoin-project/lotus/pull/12340
const conventionalPattern = /^(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test)(\([\w.]+\))?!?:?\s(\w+:)?\s?["'`a-z].+$/;
// Also accept "Revert ..." titles from GitHub's revert functionality
const revertPattern = /^Revert\s".+"$/;
const pattern = new RegExp(`(${conventionalPattern.source})|(${revertPattern.source})`);

if (!pattern.test(title)) {
await github.rest.pulls.createReview({
Expand Down
7 changes: 5 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Lotus is a universally open project and welcomes contributions of all kinds: cod
- [Working with builtin-actors](#working-with-builtin-actors)
- [PR Title Conventions](#pr-title-conventions)
- [CHANGELOG Management](#changelog-management)
- [Dependency Management](#dependency-management)
- [Markdown Conventions](#markdown-conventions)
- [Table Of Contents](#table-of-contents)
- [Getting Help](#getting-help)
Expand Down Expand Up @@ -43,7 +44,9 @@ This means the PR title should be in the form of `<type>(<scope>): <description>
- `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.

Alternatively, titles can match a GitHub revert title: `Revert "<original title>"`
- example: `Revert "feat: add new feature"`

Note that this is enforced with https://github.com/filecoin-project/lotus/blob/master/.github/workflows/pr-title-check.yml

Expand All @@ -55,7 +58,7 @@ 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 `[skip changelog]` to the PR description
- 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
Expand Down