HYPERFLEET-1024 - feat: CI for schema checks, version bump, externalize as Go module#42
Conversation
|
Important Review skippedAuto reviews are limited based on label configuration. 🚫 Review skipped — only excluded labels are configured. (1)
Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Central YAML (base), Organization UI (inherited) Review profile: ASSERTIVE Plan: Enterprise Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
📝 WalkthroughWalkthroughReleases v1.0.11 and adds CI and release automation. New CI workflow (PRs + pushes to main) builds core/gcp OpenAPI+Swagger schemas, enforces generated-schema consistency, runs Spectral lint, and checks that main.tsp’s version is bumped. Release workflow (push to main) extracts version from main.tsp, skips if tag exists, builds four schema artifacts, creates/pushes an annotated tag, and publishes a GitHub Release with all artifacts. build-schema.sh now uses the local TypeSpec binary from node_modules/.bin. Schemas’ Error.instance format changed from Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. 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: 5
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In @.github/workflows/ci.yml:
- Around line 53-63: The version check currently does only string equality on
CURRENT and LATEST and doesn't guard empty values; update the CI step to first
fail if either CURRENT (from main.tsp) or LATEST is empty, then perform a
semver-aware comparison (e.g. using sort -V) to ensure CURRENT is strictly
greater than LATEST — reference the CURRENT and LATEST variables and replace the
equality check block with: 1) empty-value guard for CURRENT and LATEST, 2)
semver comparison that fails if the sorted highest version is not CURRENT, and
3) keep the existing messages but return non-zero on equal or downgraded
versions.
In @.github/workflows/release.yml:
- Around line 28-33: The "Extract version" step sets VERSION from main.tsp but
doesn't guard against an empty result, which yields a malformed tag "v"; update
the step to validate VERSION after extraction (the shell variable VERSION used
in the step) and if it's empty, print a clear error to stderr and exit with
non-zero status so the workflow fails instead of creating a "v" tag, or
alternatively conditionally set the "tag" output only when VERSION is non-empty;
ensure the outputs "version" and "tag" are only written to GITHUB_OUTPUT when
VERSION contains a value and include context (e.g., reference to main.tsp) in
the error message.
In `@CHANGELOG.md`:
- Line 21: The changelog entry incorrectly states "Node.js 24 runtime" while the
workflows still set node-version: '20'; update the CHANGELOG line that currently
reads "Bumped `actions/checkout` and `actions/setup-node` to v6 (Node.js 24
runtime)" to accurately reflect the runtime (e.g., remove the "(Node.js 24
runtime)" parenthetical or change it to "(Node.js 20 runtime)"), so the text
matches the actual `node-version: '20'` used in the workflows.
In `@go.mod`:
- Line 3: Update the Go version directive in go.mod from "go 1.25.0" to a lower,
compatible version such as "go 1.16" or "go 1.17" to broaden downstream
compatibility; open go.mod, locate the line containing the literal token "go
1.25.0" and replace it with "go 1.16" (or "go 1.17") since only //go:embed
(introduced in 1.16) is required by the module.
In `@README.md`:
- Around line 365-367: The fenced code block containing the Go module replace
directive (the line starting with "replace
github.com/openshift-hyperfleet/hyperfleet-api-spec =>
/path/to/local/hyperfleet-api-spec") should include a language specifier to
enable syntax highlighting and silence MD040; change the opening backticks from
"```" to "```go" so the block reads "```go" followed by the replace directive
and then the closing "```".
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Enterprise
Run ID: d5cdb396-db24-4ad4-9c30-d1c9df7625b3
⛔ Files ignored due to path filters (1)
package-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (17)
.github/workflows/ci.yml.github/workflows/release.yml.spectral.yamlCHANGELOG.mdCLAUDE.mdCONTRIBUTING.mdREADME.mdRELEASING.mdbuild-schema.shgo.modmain.tspmodels/common/model.tspschemas/core/openapi.yamlschemas/core/swagger.yamlschemas/gcp/openapi.yamlschemas/gcp/swagger.yamlschemas/schemas.go
| run: npm ci | ||
|
|
||
| - name: Install Spectral CLI | ||
| run: npm install -g @stoplight/spectral-cli@6.15.1 |
There was a problem hiding this comment.
ci.yml:28 — global Spectral install contradicts tsp-to-local migration
This PR removes the global tsp install in favor of node_modules/.bin/tsp to eliminate version mismatches, but installs Spectral globally (npm install -g @stoplight/spectral-cli@6.15.1). Consider adding @stoplight/spectral-cli as a pinned devDependency and invoking via npx spectral or node_modules/.bin/spectral for consistency.
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In @.github/workflows/ci.yml:
- Around line 55-58: The current command collapses real gh failures into an
empty LATEST and silently skips version checks; change the logic around the gh
release list call so you capture its output and exit status separately: run gh
release list --limit 1 --json tagName --jq '.[0].tagName' and store its stdout
into a temp var, check the command's exit code and if non-zero fail the CI with
a clear error (do not fall back to empty), only treat an empty stdout as "no
previous releases" (then echo "No previous releases found — version check
skipped" and exit 0), and when stdout is non-empty set LATEST by stripping a
leading v (current LATEST variable) before doing the version comparison.
In `@CONTRIBUTING.md`:
- Around line 84-94: Update the CONTRIBUTING.md local linting instructions to
use the repository's pinned Spectral instead of a global install: replace the
global install command "npm install -g `@stoplight/spectral-cli`" with "npm ci"
(or a command that installs pinned devDependencies) and replace the invocation
"spectral lint schemas/core/openapi.yaml schemas/gcp/openapi.yaml" with the
local binary path "node_modules/.bin/spectral lint schemas/core/openapi.yaml
schemas/gcp/openapi.yaml" so contributors run the exact Spectral version used by
CI.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Central YAML (base), Organization UI (inherited)
Review profile: ASSERTIVE
Plan: Enterprise
Run ID: 86a02636-8f45-444b-bebc-66ae758f1bf2
⛔ Files ignored due to path filters (1)
package-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (18)
.github/workflows/ci.yml.github/workflows/release.yml.spectral.yamlCHANGELOG.mdCLAUDE.mdCONTRIBUTING.mdREADME.mdRELEASING.mdbuild-schema.shgo.modmain.tspmodels/common/model.tsppackage.jsonschemas/core/openapi.yamlschemas/core/swagger.yamlschemas/gcp/openapi.yamlschemas/gcp/swagger.yamlschemas/schemas.go
| LATEST=$(gh release list --limit 1 --json tagName --jq '.[0].tagName' 2>/dev/null | sed 's/^v//' || echo "") | ||
| if [ -z "$LATEST" ]; then | ||
| echo "No previous releases found — version check skipped" | ||
| exit 0 |
There was a problem hiding this comment.
Don’t treat GitHub API failures as “no previous releases.”
LATEST=$(... || echo "") collapses real gh failures into an empty value, and Line 56-58 then skips version enforcement. That can let non-bumped versions merge when the API call fails transiently.
Suggested fix
- LATEST=$(gh release list --limit 1 --json tagName --jq '.[0].tagName' 2>/dev/null | sed 's/^v//' || echo "")
- if [ -z "$LATEST" ]; then
+ if ! RAW_LATEST=$(gh release list --limit 1 --json tagName --jq '.[0].tagName' 2>/dev/null); then
+ echo "::error::Failed to query latest GitHub release tag via gh."
+ exit 1
+ fi
+ LATEST=$(printf '%s' "$RAW_LATEST" | sed 's/^v//')
+ if [ -z "$RAW_LATEST" ]; then
echo "No previous releases found — version check skipped"
exit 0
fiAs per coding guidelines, "CI requirements for PRs: Enforce a strict version bump ... and fail unless main.tsp’s version is strictly greater than the latest release (or skip if no prior releases)."
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| LATEST=$(gh release list --limit 1 --json tagName --jq '.[0].tagName' 2>/dev/null | sed 's/^v//' || echo "") | |
| if [ -z "$LATEST" ]; then | |
| echo "No previous releases found — version check skipped" | |
| exit 0 | |
| CURRENT=$(grep -oP '(?<=version: ")[^"]+' main.tsp) | |
| if [ -z "$CURRENT" ]; then | |
| echo "Could not extract version from main.tsp — check the \`@info\` decorator format." | |
| exit 1 | |
| fi | |
| if ! RAW_LATEST=$(gh release list --limit 1 --json tagName --jq '.[0].tagName' 2>/dev/null); then | |
| echo "::error::Failed to query latest GitHub release tag via gh." | |
| exit 1 | |
| fi | |
| LATEST=$(printf '%s' "$RAW_LATEST" | sed 's/^v//') | |
| if [ -z "$RAW_LATEST" ]; then | |
| echo "No previous releases found — version check skipped" | |
| exit 0 | |
| fi |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In @.github/workflows/ci.yml around lines 55 - 58, The current command collapses
real gh failures into an empty LATEST and silently skips version checks; change
the logic around the gh release list call so you capture its output and exit
status separately: run gh release list --limit 1 --json tagName --jq
'.[0].tagName' and store its stdout into a temp var, check the command's exit
code and if non-zero fail the CI with a clear error (do not fall back to empty),
only treat an empty stdout as "no previous releases" (then echo "No previous
releases found — version check skipped" and exit 0), and when stdout is
non-empty set LATEST by stripping a leading v (current LATEST variable) before
doing the version comparison.
| CI automatically lints OpenAPI schemas using a pinned version of [Spectral](https://github.com/stoplightio/spectral) installed locally in the workflow. For local linting during development, install Spectral globally: | ||
|
|
||
| ```bash | ||
| npm install -g @stoplight/spectral-cli | ||
| ``` | ||
|
|
||
| Then lint the generated schemas: | ||
|
|
||
| ```bash | ||
| spectral lint schemas/core/openapi.yaml schemas/gcp/openapi.yaml | ||
| ``` |
There was a problem hiding this comment.
Use local/pinned Spectral in contributor instructions, not a global install
Line 84 correctly calls out pinned CI behavior, but Lines 85-94 switch to a global install and unpinned binary invocation. That can produce lint results different from CI and hurts reproducibility for contributors.
Suggested doc fix
-CI automatically lints OpenAPI schemas using a pinned version of [Spectral](https://github.com/stoplightio/spectral) installed locally in the workflow. For local linting during development, install Spectral globally:
+CI automatically lints OpenAPI schemas using a pinned version of [Spectral](https://github.com/stoplightio/spectral) installed locally in the workflow. For local linting during development, use the project-local dependency:
```bash
-npm install -g `@stoplight/spectral-cli`
+npm ciThen lint the generated schemas:
-spectral lint schemas/core/openapi.yaml schemas/gcp/openapi.yaml
+node_modules/.bin/spectral lint schemas/core/openapi.yaml schemas/gcp/openapi.yaml</details>
As per coding guidelines, “Focus on major issues impacting performance, readability, maintainability and security. Avoid nitpicks and avoid verbosity. Validate changes against HyperFleet architecture standards from the linked architecture repository.”
<details>
<summary>🤖 Prompt for AI Agents</summary>
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In @CONTRIBUTING.md around lines 84 - 94, Update the CONTRIBUTING.md local
linting instructions to use the repository's pinned Spectral instead of a global
install: replace the global install command "npm install -g
@stoplight/spectral-cli" with "npm ci" (or a command that installs pinned
devDependencies) and replace the invocation "spectral lint
schemas/core/openapi.yaml schemas/gcp/openapi.yaml" with the local binary path
"node_modules/.bin/spectral lint schemas/core/openapi.yaml
schemas/gcp/openapi.yaml" so contributors run the exact Spectral version used by
CI.
</details>
<!-- fingerprinting:phantom:triton:hawk -->
<!-- d98c2f50 -->
<!-- This is an auto-generated comment by CodeRabbit -->
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
/lgtm |
|
/lgtm |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: rh-amarin The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
d8a0f05
into
openshift-hyperfleet:main
Summary
Added CI workflow (ci.yml) that runs on every PR and push to main: rebuilds all four schemas from TypeSpec, checks consistency against committed files, lints both openapi.yaml files with spectral:oas, and enforces a version bump against the latest release tag.
Replaced manual release process with automated release.yml that triggers on push to main, extracts version from main.tsp, auto-creates an annotated tag, and publishes a GitHub Release with all four artifacts attached (core-openapi.yaml, core-swagger.yaml, gcp-openapi.yaml, gcp-swagger.yaml).
Added go.mod and schemas/schemas.go exposing all generated schemas via //go:embed as embed.FS, enabling downstream Go consumers to import versioned schemas as a module dependency without vendoring local copies.
Added .spectral.yaml with spectral:oas ruleset. Fix Error.instance field format from uri to uri-reference per RFC 7807. Bump actions/checkout and actions/setup-node to v6.
Update CHANGELOG.md
Test Plan
make test-allpassesmake lintpassesmake test-helm(if applicable)