Repository navigation
ci: add DCO check, Mergify automation, and branch naming enforcement #424
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
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
fed364c
ci: add DCO sign-off check to PR workflow and pre-commit
CatherineSue fe4e6c6
ci: add Mergify rules for branch naming, DCO failure, merge conflicts…
CatherineSue c0bb7e1
ci: add branch naming convention check to pre-commit
CatherineSue e4664f8
fix(ci): add get-pr-commits step required by tim-actions/dco
CatherineSue 3918df5
fix(ci): anchor DCO sign-off regex to end of line
CatherineSue 331a543
fix(ci): address review feedback from CodeRabbit
CatherineSue 7d79715
ci: restore auto-close for branch naming violations
CatherineSue a270c50
fix(ci): use block scalar for dco-check entry to fix YAML parsing
CatherineSue 3f18956
ci: extract DCO check into standalone workflow
CatherineSue File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or 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,78 @@ | ||
| pull_request_rules: | ||
| - name: Enforce branch naming convention | ||
| description: Branch must follow <type>/<description> or <username>/<description> format | ||
| conditions: | ||
| - head ~!= ^[a-z0-9]([a-z0-9._-]*[a-z0-9])?/[a-z0-9._-]+$ | ||
| - head != main | ||
| actions: | ||
| comment: | ||
| message: | | ||
| Hi @{{author}}, the branch `{{head}}` does not follow our naming convention. | ||
|
|
||
| Please use one of the following formats: | ||
| - `<type>/<description>` — e.g. `feat/add-auth`, `fix/null-pointer` | ||
| - `<username>/<description>` — e.g. `changsu/fix-routing` | ||
|
|
||
| Allowed types: `feat`, `fix`, `chore`, `docs`, `refactor`, `test`, `ci`, `perf` | ||
| post_check: | ||
| title: Branch naming convention | ||
| summary: | | ||
| Branch `{{head}}` does not match the required pattern: `<type>/<description>` or `<username>/<description>`. | ||
| close: | ||
| message: | | ||
| Closing this PR because the branch name does not follow the naming convention. Please rename your branch and reopen. | ||
|
|
||
| - name: Comment on DCO check failure | ||
| description: Post fix instructions when DCO sign-off is missing | ||
| conditions: | ||
| - check-failure = dco-check | ||
| - -closed | ||
| - -draft | ||
| actions: | ||
| comment: | ||
| message: | | ||
| Hi @{{author}}, the DCO sign-off check has failed. All commits must include a `Signed-off-by` line. | ||
|
|
||
| **To fix existing commits:** | ||
| ```bash | ||
| # Sign off the last N commits (replace N with the number of unsigned commits) | ||
| git rebase HEAD~N --signoff | ||
| git push --force-with-lease | ||
| ``` | ||
|
|
||
| **To sign off future commits automatically:** | ||
| - Use `git commit -s` every time, or | ||
| - **VSCode**: enable `Git: Always Sign Off` in Settings | ||
| - **PyCharm**: enable `Sign-off commit` in the Commit tool window | ||
|
|
||
| - name: Notify on merge conflicts | ||
| description: Comment when a PR has merge conflicts | ||
| conditions: | ||
| - conflict | ||
| - -closed | ||
| - -draft | ||
| actions: | ||
| comment: | ||
| message: | | ||
| Hi @{{author}}, this PR has merge conflicts that must be resolved before it can be merged. Please rebase your branch: | ||
| ```bash | ||
| git fetch origin main | ||
| git rebase origin/main | ||
| # resolve any conflicts, then: | ||
| git push --force-with-lease | ||
| ``` | ||
|
|
||
| - name: Remind on stale PRs | ||
| description: Comment and label PRs inactive for 14 days | ||
| conditions: | ||
| - updated-at < 14 days ago | ||
| - -merged | ||
| - -closed | ||
| - -draft | ||
| actions: | ||
| comment: | ||
| message: | | ||
| Hi @{{author}}, this PR has been inactive for 14 days. Please update it or close it if it's no longer needed. | ||
| label: | ||
| add: | ||
| - stale | ||
This file contains hidden or 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,28 @@ | ||
| name: DCO Check | ||
|
|
||
| on: | ||
| pull_request: | ||
| branches: [main] | ||
| types: [opened, synchronize, reopened] | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| dco-check: | ||
| runs-on: k8s-runner-cpu | ||
| permissions: | ||
| contents: read | ||
| steps: | ||
| - uses: actions/checkout@v6 | ||
| with: | ||
| fetch-depth: 0 | ||
| - name: Get PR commits | ||
| id: get-commits | ||
| uses: tim-actions/get-pr-commits@v1.3.1 | ||
| with: | ||
| token: ${{ secrets.GITHUB_TOKEN }} | ||
| - name: Check DCO sign-off | ||
| uses: tim-actions/dco@v1.1.0 | ||
| with: | ||
| commits: ${{ steps.get-commits.outputs.commits }} |
This file contains hidden or 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 hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.