-
Notifications
You must be signed in to change notification settings - Fork 49
Update the swagger json github workflow #359
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
base: main
Are you sure you want to change the base?
Conversation
|
Note Currently processing new changes in this PR. This may take a few minutes, please wait... ✏️ Tip: You can disable in-progress messages and the fortune message in your review settings. 📝 WalkthroughWalkthroughCI workflow updates for Swagger JSON generation: Maven runs in batch mode, Swagger fetch now validates JSON and ensures non-empty paths, polling increased, shutdown and port-cleanup hardened, checkout fetches full history, PR action/version/branch/commit-title conventions updated, and created PRs are set to delete the branch. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
.github/workflows/swagger-json.yml
Outdated
| run: | | ||
| mkdir -p amrit-docs/docs/swagger | ||
| cp common-api.json amrit-docs/docs/swagger/common-api.json | ||
| cp tm-api.json amrit-docs/docs/swagger/tm-api.json |
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.
@DurgaPrasad-54 why does this say tm api in common?
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
🤖 Fix all issues with AI agents
In @.github/workflows/swagger-json.yml:
- Around line 96-104: The workflow currently generates unique branches per run
via the create-pull-request step (uses: peter-evans/create-pull-request@v8)
using branch: auto/swagger-update-${{ github.run_id }}-${{ github.run_attempt
}}, which causes many stale PRs; change this to a fixed branch name (e.g.,
branch: auto/swagger-update) so the action will update/force-push the same
branch and keep a single PR open, retaining delete-branch: true for cleanup
after merge.
🧹 Nitpick comments (2)
.github/workflows/swagger-json.yml (2)
67-80: Misleading comments and unconditionalsleep 5before the PID check.Two concerns:
Comment–code mismatch: The "Graceful shutdown" comment (Line 70) annotates the bare
sleep 5, while the actual graceful signal (SIGTERM, Line 75) sits under the "Force kill" comment (Line 72). This will confuse future maintainers.Process-group kill may be a no-op:
kill -- -"$PID"treats$PIDas a PGID. The$!captured on Line 36 is the Maven wrapper PID, which is not guaranteed to be a process-group leader in the Actions runner shell. If it isn't, bothkillcalls silently fail and onlyfuseron Line 80 actually cleans up — so the logic is safe, but the intermediate steps would be dead code.Minor: The unconditional
sleep 5(Line 71) runs even whenapi_pid.txtdoesn't exist. Move it inside theifblock.Proposed cleanup
- name: Stop API if: always() run: | - # Graceful shutdown of the process group - sleep 5 - # Force kill the process group if still running if [ -f api_pid.txt ]; then - PID=$(cat api_pid.txt) - kill -TERM -- -"$PID" 2>/dev/null || true - sleep 2 - kill -9 -- -"$PID" 2>/dev/null || true - fi - # Fallback: kill any remaining java process on port 9090 - fuser -k 9090/tcp 2>/dev/null || true + PID=$(cat api_pid.txt) + # Graceful SIGTERM, then wait + kill -TERM "$PID" 2>/dev/null || true + sleep 5 + # Force SIGKILL if still running + kill -9 "$PID" 2>/dev/null || true + sleep 1 + fi + # Fallback: kill anything still on port 9090 + fuser -k 9090/tcp 2>/dev/null || true
30-36: Consider usingsetsidto guarantee a new process group for reliable group-kill in the Stop step.The PID captured by
$!on Line 36 may not be a process-group leader (relevant to thekill -- -"$PID"calls in the Stop step). If you want the process-group kill pattern to work reliably, launch withsetsid:- mvn spring-boot:run \ + setsid mvn spring-boot:run \ -Dspring-boot.run.profiles=swagger \ -Dspring-boot.run.arguments=--server.port=9090 \ > app.log 2>&1 &This ensures the Maven process is a session/group leader, making
kill -- -"$PID"effective and cleaning up all child processes (including the forked Java process).
|



Summary by CodeRabbit
Bug Fixes
Chores
Documentation