ci: add workflow to validate specs against Swagger Validator#33
ci: add workflow to validate specs against Swagger Validator#33ChiragAgg5k merged 3 commits intomainfrom
Conversation
|
Warning Rate limit exceeded
⌛ 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. WalkthroughA new GitHub Actions workflow (.github/workflows/ci.yml) is added to validate JSON specifications. It triggers on push and pull requests to the main branch, checks out the repository, posts each JSON file in the Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes 🚥 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 |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
.github/workflows/ci.yml (1)
21-21: External service dependency with no retry logicThe entire workflow is gated on
validator.swagger.iobeing reachable. A single transient failure on any spec file fails (or silently passes, before the fix above) the CI run with no recourse.Consider adding
--retry 3 --retry-delay 5 --retry-all-errorsto thecurlinvocation. This handles transient network hiccups without changing the failure semantics:- response=$(curl -s --fail-with-body --max-time 30 -X POST \ + response=$(curl -s --fail-with-body --max-time 30 --retry 3 --retry-delay 5 --retry-all-errors -X POST \🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In @.github/workflows/ci.yml at line 21, The workflow currently depends on VALIDATOR_URL and calls curl against validator.swagger.io with no retry, so transient network failures can break CI; update the curl invocation that uses the VALIDATOR_URL variable to add retry logic (e.g., append the flags --retry 3 --retry-delay 5 --retry-all-errors) so curl will retry transient errors while preserving failure semantics if the service is truly unreachable.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In @.github/workflows/ci.yml:
- Line 41: The workflow currently feeds find results into the while loop (done <
<(find specs -name "*.json" | sort)) and can silently succeed when no spec files
are found; modify the script to capture the find output into a variable or array
first, check if it's empty (e.g., after running find into SPECS or an array),
and if empty emit an error/notice and exit non‑zero (or set FAILED>0) before
entering the while loop so PASSED/FAILED cannot both be zero and produce a
false-positive CI pass; update the code paths that reference PASSED and FAILED
to respect this early exit.
- Around line 26-40: The validation step silently marks specs as PASSED on HTTP
4xx/5xx or network errors; update the curl invocation that sets response to
include the --fail-with-body flag and add an inline per-file failure handler on
the curl command (the || { ...; continue; } pattern) so that when curl exits
non-zero you log the HTTP/network error, increment FAILED, and continue to the
next spec without terminating the whole script under set -e; ensure you
reference the existing variables response, spec_file, VALIDATOR_URL and the
counters PASSED/FAILED and keep the subsequent jq-based error parsing of
schemaValidationMessages unchanged.
---
Nitpick comments:
In @.github/workflows/ci.yml:
- Line 21: The workflow currently depends on VALIDATOR_URL and calls curl
against validator.swagger.io with no retry, so transient network failures can
break CI; update the curl invocation that uses the VALIDATOR_URL variable to add
retry logic (e.g., append the flags --retry 3 --retry-delay 5
--retry-all-errors) so curl will retry transient errors while preserving failure
semantics if the service is truly unreachable.
Summary
.github/workflows/ci.ymlthat runs on push and PR tomainspecs/and POSTs each tohttps://validator.swagger.io/validator/debugschemaValidationMessageswithlevel == "error"and fails the job if any are foundTest plan
Summary by CodeRabbit