-
Notifications
You must be signed in to change notification settings - Fork 66
FXC-3354-Lint-commit-messages #2862
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
Conversation
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.
Additional Comments (1)
-
.github/workflows/tidy3d-python-client-tests.yml, line 524 (link)logic: Missing 'lint-commit-messages' dependency in pr-requirements-pass job needs array
3 files reviewed, 4 comments
1b135b2 to
b817290
Compare
|
I like this! 👍 However, if we always to squash and merge and are using the merge queue, couldn't we enforce the commit message linting only for the commit that lands in main (develop)? |
Great point. This should probably only be enforced once we queue for merge? And then for all commits (in case there is more than one, which does happen from time to time). Nice side-effect is that this would probably also catch cases where we forget to squash. |
|
What exactly do you mean that I should change then? Is there an option to run the commitlint-Pipeline only if the PR is merged? I feel like it would be better to immediately have the feedback as soon as the PR is opened rather than on merge. |
|
Currently, the github pipeline is not working at all, I will see how to fix this |
Diff CoverageDiff: origin/develop...HEAD, staged and unstaged changesNo lines with coverage information in this diff. |
75d3f0a to
e2c5451
Compare
|
I added a check, which fails the PR if there is more than a single commit present. Is there any case where we might want to have more than a single commit in the PR? If this check is too strict, we can also remove it again. @yaugenst-flex could you give feedback here? |
So I think we should allow for more than one commit per PR, because sometimes it does make sense to split up to changes within one PR into two logical commits. That should not be the norm, but it does happen. Sometimes however we just forget to squash, and in those cases typically the individual commits will also not follow commitlint rules (might be commits added after review comments for example). And if we enforce commitlint on all commits, then we would catch these cases automatically. I also think we might not want to enforce commitlint rules on PR open but instead only when queuing up for merge? Since that‘s really the only place where it matters. |
|
So yes, by default the merge queue will rebase the PR commits, and I guess we want to check every commit in the rebase, that said it can be quite annoying to have this check other than in the |
e2c5451 to
0c9acd8
Compare
I changed the github pipeline to only run on merge-group events |
|
Does it make sense to change the local pre-commit config now as well? I am not sure how this should be configured now |
|
Looks broadly good! Not sure if any further comments before moving forward? |
https://pre-commit.com/#top_level-default_install_hook_types Maybe means |
Good suggestions, this works locally for me |
0c9acd8 to
6a47a17
Compare
|
I have changed the pre-commit pipeline, such that the user will get a warning if the commit message is bad, but the pre-commit pipeline does not fail. With this, we can make bad commit messages (temporarily) and squash them together later with a good commit message. |
6a47a17 to
ded7534
Compare
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.
So if I read this correctly, then pr-requirements-pass now depends on lint-commit-messages, but that depends on if: github_event_name == 'merge_group'. This will be skipped on every PR event, which means pr-requirements-pass will never run (correct my understanding if wrong, not a github actions expert...). I think the fix would be to drop the job-level if so that the required dependency is always satisfied and then make the actual commitlint work conditional inside the job (if: github.event_name == 'merge_group').
ded7534 to
ea80d7c
Compare
|
@yaugenst-flex isn't it because of tidy3d/.github/workflows/tidy3d-python-client-tests.yml Lines 513 to 517 in ea80d7c
this overrides the I've used it in some other actions and works well, and should cover this situation I think |
I'm not sure, but we can try it. My understanding is that |
|
Ah but I guess we could of course let the commitlint run and fail, in which case your guard would catch it. Seems a bit wasteful though... |
|
So if we add the tidy3d/.github/workflows/tidy3d-python-client-tests.yml Lines 163 to 166 in ea80d7c
then it would just skip that job, and and also then be skipped by a similar if statement in the Ideally though some flag like |
|
No in what i’m proposing, the job would pass (by skipping its steps), and only truly run when going in merge queue. |
|
So I think both approaches get ultimately the same PR-facing behaviour - happy to try them out! My personal preference is skipping it at the job level like we do other jobs, and simply skipping the check in a merge_group. Ultimately though, I think we're both intending to skip it until the check is meant to run from what I understand you're proposing, it's just where we skip |
|
Yes let’s just try. What’s the worst that could happen 😄 |
|
@yaugenst-flex @frederikschubertflex Do you want to see any other changes or this it PR ready to merge? If so please let me know. |
ea80d7c to
3108ae0
Compare
So this is what I mean #2854 |
Added commitlint to pre-commit pipeline and github wokflow
Greptile Overview
Updated On: 2025-10-02 06:59:20 UTC
Summary
This PR implements commit message linting across the Tidy3D project by adding commitlint configuration and integrating it into both the pre-commit pipeline and GitHub Actions workflow. The changes introduce standardized commit message formatting based on conventional commit standards.The implementation adds three key components:
.commitlint.yml) that defines strict rules for commit messages including mandatory commit types (feat, fix, docs, style, refactor, perf, test, build, ci, chore, revert), length constraints (12-72 characters for headers), and lowercase scoping requirementsThe enforcement follows a gradual rollout strategy - currently configured in informational mode to show warnings but not block merges, with plans to make it mandatory in the future. This approach allows developers to adapt to the new requirements without disrupting existing workflows. The GitHub Actions implementation intelligently handles different event types, checking all commits in a PR range versus just the head commit for pushes.
This change fits into the broader Tidy3D codebase quality infrastructure, complementing existing pre-commit hooks and automated testing pipelines. It establishes a foundation for improved commit history readability, automated changelog generation, and better project maintainability.
PR Description Notes:
Important Files Changed
Changed Files
.commitlint.yml.pre-commit-config.yaml.github/workflows/tidy3d-python-client-tests.ymlConfidence score: 4/5
Sequence Diagram
sequenceDiagram participant Developer participant Git participant PreCommit as "Pre-commit Hooks" participant CommitLint as "CommitLint" participant GitHub as "GitHub Actions" participant RuffLinter as "Ruff Linter" participant TestRunner as "Test Runner" Developer->>Git: "git commit -m 'feat: add new feature'" Git->>PreCommit: "Trigger pre-commit hooks" PreCommit->>RuffLinter: "Run ruff-check and ruff-format" RuffLinter-->>PreCommit: "Code formatting results" PreCommit->>CommitLint: "Validate commit message format" CommitLint-->>PreCommit: "Commit message validation result" PreCommit-->>Git: "Pre-commit validation complete" Git-->>Developer: "Commit accepted/rejected" Developer->>GitHub: "Push commits to PR branch" GitHub->>GitHub: "Trigger tidy3d-python-client-tests workflow" GitHub->>GitHub: "Determine test scope based on PR status" par Linting Jobs GitHub->>RuffLinter: "Run ruff format --check --diff" RuffLinter-->>GitHub: "Format check results" GitHub->>RuffLinter: "Run ruff check tidy3d" RuffLinter-->>GitHub: "Lint check results" and Commit Message Linting GitHub->>CommitLint: "Check all PR commit messages" CommitLint-->>GitHub: "Commit message validation results" and Schema Verification GitHub->>GitHub: "Verify schema changes" GitHub-->>GitHub: "Schema validation results" end GitHub->>TestRunner: "Run local tests (Python 3.10, 3.13)" TestRunner-->>GitHub: "Local test results" alt PR is approved GitHub->>TestRunner: "Run remote tests (multiple platforms)" TestRunner-->>GitHub: "Remote test results" end GitHub->>GitHub: "Check pr-requirements-pass" GitHub-->>Developer: "PR status update"