-
Couldn't load subscription status.
- Fork 18
Add GitHub Actions workflow for Spotless formatting #89
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
Add GitHub Actions workflow for Spotless formatting #89
Conversation
|
🚀 Hi @nihaltp! Thank you for contributing to MyCMD. A maintainer will review your PR shortly. 🎉 |
|
Warning Rate limit exceeded@nihaltp has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 8 minutes and 4 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📒 Files selected for processing (1)
WalkthroughAdds a new GitHub Actions workflow that runs Spotless formatting on pull requests and pushes to the main branch, using JDK 17 and Maven to apply formatting and commit any resulting changes back to the branch. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant Dev as Developer (PR / Push)
participant GH as GitHub Actions
participant Runner as ubuntu-latest
participant Repo as Repository
participant Maven as Maven / Spotless
Dev->>GH: Open PR or push to main
GH->>Runner: Start "Apply Spotless Formatting" job
Runner->>Repo: actions/checkout (full fetch)
Runner->>Runner: setup-java (Temurin 17) + maven cache
Runner->>Maven: mvn spotless:apply
alt formatting changes detected
Maven->>Repo: git commit & push (bot identity)
Repo->>Dev: Updated PR branch with formatting commits
else no changes
Maven->>Runner: output "No changes detected"
end
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
Comment |
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.
Actionable comments posted: 2
🧹 Nitpick comments (1)
.github/workflows/formatter.yml (1)
36-36: Consider restrictinggit addscope to prevent unintended file commits.Using
git add .commits all modified files in the repository. For a formatting-only workflow, consider being more specific (e.g., common source directories likesrc/,pom.xml) to reduce the risk of accidentally committing unrelated changes.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
.github/workflows/formatter.yml(1 hunks)
🧰 Additional context used
🪛 actionlint (1.7.8)
.github/workflows/formatter.yml
33-33: "github.head_ref" is potentially untrusted. avoid using it directly in inline scripts. instead, pass it through an environment variable. see https://docs.github.com/en/actions/reference/security/secure-use#good-practices-for-mitigating-script-injection-attacks for more details
(expression)
1fb4422 to
e0fb155
Compare
|
🚀 Hi @nihaltp! Thank you for contributing to MyCMD. A maintainer will review your PR shortly. 🎉 |
e0fb155 to
95661a7
Compare
|
🚀 Hi @nihaltp! Thank you for contributing to MyCMD. A maintainer will review your PR shortly. 🎉 |
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.
Actionable comments posted: 1
🧹 Nitpick comments (1)
.github/workflows/formatter.yml (1)
11-13: Optional: Consider adding explicit minimal permissions.While not required for functionality, explicitly declaring minimal permissions improves security posture. This workflow only needs to push commits:
jobs: format: runs-on: ubuntu-latest + permissions: + contents: write concurrency:This prevents the workflow from using overly-broad default permissions. However, this is optional.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
.github/workflows/formatter.yml(1 hunks)
🧰 Additional context used
🪛 actionlint (1.7.8)
.github/workflows/formatter.yml
36-36: "github.head_ref" is potentially untrusted. avoid using it directly in inline scripts. instead, pass it through an environment variable. see https://docs.github.com/en/actions/reference/security/secure-use#good-practices-for-mitigating-script-injection-attacks for more details
(expression)
🔇 Additional comments (2)
.github/workflows/formatter.yml (2)
14-16: ✅ Concurrency constraint properly implemented.The concurrency block correctly serializes formatter runs per branch, preventing race conditions during
git pull --rebaseandgit pushoperations. The branch ref fallbackgithub.head_ref || github.ref_namecorrectly handles both pull_request and push contexts.
19-23: ✅ Checkout ref properly handles both contexts.Using
github.head_ref || github.ref_nameensures the step checks out the correct ref for both pull_request events (uses head_ref) and push events (uses ref_name). Full history fetch is appropriate for rebasing.
this will automatically apply formatting using `mvn spotless:apply`
95661a7 to
568cafb
Compare
|
🚀 Hi @nihaltp! Thank you for contributing to MyCMD. A maintainer will review your PR shortly. 🎉 |
Summary by CodeRabbit