Repository navigation
ci: use nix for lint, e2e, quickstart - #3209
Conversation
|
Caution Review failedThe pull request is closed. 📝 WalkthroughWalkthroughRemoves Dagger-based dev/lint/build/test code and replaces CI/test orchestration with Makefiles, Nix, and Docker Compose. Adds base Compose stack and e2e/quickstart Compose setups, revises workflows, updates ports, adjusts E2E tests with slow gating, and modifies Dockerfile binaries. Introduces Corepack/Spectral in flake.nix. Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (32)
✨ Finishing Touches
🧪 Generate unit tests
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
8d1cd4d to
22e521b
Compare
86ca710 to
a5bbc36
Compare
a5bbc36 to
5e9ba8b
Compare
fdf9307 to
66bcea4
Compare
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
Actionable comments posted: 5
🔭 Outside diff range comments (2)
Makefile (2)
42-44: Fix or remove the incomplete migrate-check target.The migrate-check target contains a dagger call that contradicts the PR's objective of removing Dagger-based tooling. This should either be updated to use a Nix-based approach or removed if no longer needed.
.PHONY: migrate-check -migrate-check: ## Validate migrations - $(call print-target) - dagger call migrate check +migrate-check: ## Validate migrations + $(call print-target) + # TODO: Implement migrate check using Nix-based tooling + @echo "migrate-check not yet implemented with Nix tooling" + @false
47-50: Consider migrating generate-sqlc-testdata to Nix tooling.This target still uses Dagger, which is inconsistent with the PR's goal of moving away from Dagger-based tooling.
Since this appears to be development tooling for generating test data, consider implementing this using Nix-based tooling or documenting it as a known exception if Dagger usage is intentional here.
🧹 Nitpick comments (9)
api/client/javascript/src/client/schemas.ts (1)
2780-2784: ConfirmBillingParty.keywrite semantics; considerreadonlyfor consistency.
BillingPartyhasreadonly id?: string. If this type is primarily used as a response model,keyshould bereadonlyto match. If it is used as an input model as well, ensure the spec distinguishes read/write models so the generator can setreadOnlyaccurately.Suggested local change if this is response-only:
- key?: string + readonly key?: stringapi/client/javascript/src/zod/index.ts (3)
5517-5522: Trim supplier.key to prevent whitespace-only inputs.Same rationale as for customer.key; trimming avoids accidental " " values.
Apply this diff:
- key: zod.coerce - .string() + key: zod.coerce + .string() + .trim() .min(1) .max(updateInvoiceBodySupplierKeyMax) .optional() .describe('An optional unique key of the party (if available)'),
6050-6054: Trim supplier.key (createBillingProfileBody). Also clarify precedence vs supplier.id.
- Add .trim() to avoid whitespace-only keys.
- Consider documenting precedence (or adding a refinement) when both supplier.id and supplier.key are provided to avoid ambiguity at ingestion.
Apply this diff for trimming:
- key: zod.coerce - .string() + key: zod.coerce + .string() + .trim() .min(1) .max(createBillingProfileBodySupplierKeyMax) .optional() .describe('An optional unique key of the party (if available)'),Optional follow-up (outside this hunk): add a refinement on the parent
supplierobject to either document or enforce precedence when bothidandkeyare present.
6408-6412: Trim supplier.key (updateBillingProfileBody).Keeps behavior consistent with other key fields and avoids whitespace-only entries.
Apply this diff:
- key: zod.coerce - .string() + key: zod.coerce + .string() + .trim() .min(1) .max(updateBillingProfileBodySupplierKeyMax) .optional() .describe('An optional unique key of the party (if available)'),e2e/e2e_test.go (1)
1042-1046: Consider reducing or eliminating the hardcoded sleep durations.The test includes multiple hardcoded sleep statements (
time.Sleep(time.Minute)andtime.Sleep(time.Second * 10)) which can make tests brittle and slow. Consider using polling mechanisms or event-driven approaches where possible.Apply this approach to reduce hardcoded sleeps:
- // we have to wait after the reset - time.Sleep(time.Minute) - time.Sleep(time.Second * 10) + // Poll for reset completion instead of fixed sleep + assert.EventuallyWithT(t, func(t *assert.CollectT) { + // Check for reset completion by verifying entitlement state + // Implementation depends on available reset status APIs + }, 2*time.Minute, 5*time.Second)e2e/Makefile (2)
9-13: Consider adding a timeout to the curl health check.The health check loop could potentially run indefinitely if the service fails to start properly. While
--retry-max-time 120provides some protection, consider adding an explicit timeout using--max-timefor individual requests.- curl --retry 10 --retry-max-time 120 --retry-all-errors http://localhost:30000/healthz + curl --retry 10 --retry-max-time 120 --max-time 10 --retry-all-errors http://localhost:30000/healthz
34-37: Address static analysis warnings about missing standard phony targets.The static analysis tool flagged missing standard Makefile targets. While not critical for this specialized e2e Makefile, consider adding empty implementations to satisfy tooling expectations.
+.PHONY: all clean test +all: ## Default target (no-op for e2e) + @echo "No default target for e2e Makefile. Use 'make help' to see available targets." + +clean: ## Clean up local environment + $(call print-target) + $(MAKE) env-local-down + +test: test-local ## Alias for test-local + .PHONY: helpMakefile (1)
175-179: Performance consideration for the ci target.Running
make -j 10 lint test etoein parallel might overwhelm system resources, especially since e2e tests typically require exclusive access to ports and services. Consider if this level of parallelism is appropriate.- $(MAKE) -j 10 lint test etoe + $(MAKE) lint + $(MAKE) -j 2 test etoeThis would run linting first (which is fast), then run tests and e2e in parallel with reduced concurrency to avoid resource conflicts.
.github/workflows/ci.yaml (1)
91-91: Potential redundancy in go module cache restore keys.The go module cache restore keys include the same key twice in the restore-keys list. This is harmless but redundant.
restore-keys: | - ${{ runner.os }}-openmeter-go-modules-${{ github.ref_name }}-${{ hashFiles('flake.*', 'go.*', '.github/workflows/*.yaml') }} ${{ runner.os }}-openmeter-go-modules-${{ github.ref_name }}- ${{ runner.os }}-openmeter-go-modules-main-${{ hashFiles('flake.*', 'go.*', '.github/workflows/*.yaml') }} ${{ runner.os }}-openmeter-go-modules-mainAlso applies to: 141-141, 209-209, 305-305
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (34)
.dagger/build.go(0 hunks).dagger/dev.go(0 hunks).dagger/generate.go(0 hunks).dagger/lint.go(0 hunks).dagger/test.go(0 hunks).dagger/test_e2e.go(0 hunks).dagger/utils.go(1 hunks).github/workflows/artifacts.yaml(3 hunks).github/workflows/ci.yaml(5 hunks).github/workflows/sdk-javascript-release.yaml(1 hunks).vscode/settings.json(1 hunks)Dockerfile(2 hunks)Makefile(3 hunks)api/client/javascript/Makefile(1 hunks)api/client/javascript/src/client/schemas.ts(3 hunks)api/client/javascript/src/zod/index.ts(8 hunks)api/spec/Makefile(1 hunks)docker-compose.base.yaml(1 hunks)docker-compose.yaml(1 hunks)e2e/.gitignore(1 hunks)e2e/Makefile(1 hunks)e2e/docker-compose.infra.yaml(1 hunks)e2e/docker-compose.openmeter-latest.yaml(1 hunks)e2e/docker-compose.openmeter-local.yaml(1 hunks)e2e/docker-compose.openmeter.yaml(1 hunks)e2e/e2e_test.go(1 hunks)e2e/entitlement_test.go(2 hunks)e2e/productcatalog_test.go(3 hunks)e2e/setup_test.go(1 hunks)flake.nix(1 hunks)quickstart/.gitignore(1 hunks)quickstart/README.md(5 hunks)quickstart/docker-compose.ci.yaml(0 hunks)quickstart/docker-compose.yaml(3 hunks)
💤 Files with no reviewable changes (7)
- .dagger/test.go
- .dagger/dev.go
- quickstart/docker-compose.ci.yaml
- .dagger/generate.go
- .dagger/test_e2e.go
- .dagger/lint.go
- .dagger/build.go
✅ Files skipped from review due to trivial changes (3)
- e2e/.gitignore
- quickstart/.gitignore
- .vscode/settings.json
🚧 Files skipped from review as they are similar to previous changes (12)
- e2e/docker-compose.openmeter-latest.yaml
- .dagger/utils.go
- .github/workflows/sdk-javascript-release.yaml
- e2e/docker-compose.openmeter.yaml
- quickstart/README.md
- e2e/entitlement_test.go
- e2e/productcatalog_test.go
- quickstart/docker-compose.yaml
- .github/workflows/artifacts.yaml
- docker-compose.yaml
- flake.nix
- Dockerfile
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-03-07T12:17:43.129Z
Learnt from: GAlexIHU
PR: openmeterio/openmeter#2383
File: openmeter/entitlement/metered/lateevents_test.go:37-45
Timestamp: 2025-03-07T12:17:43.129Z
Learning: In the OpenMeter codebase, test files like `openmeter/entitlement/metered/lateevents_test.go` may use variables like `meterSlug` and `namespace` without explicit declarations visible in the same file. This appears to be an accepted pattern in their test structure.
Applied to files:
e2e/e2e_test.go
🧬 Code Graph Analysis (1)
e2e/e2e_test.go (5)
api/api.gen.go (4)
ResetEntitlementUsageJSONRequestBody(8508-8508)EntitlementMeteredCreateInputs(2823-2860)RecurringPeriodCreateInput(5900-5906)CreateEntitlementJSONRequestBody(8499-8499)openmeter/ent/db/grant/where.go (1)
EffectiveAt(105-107)openmeter/ent/db/usagereset/where.go (1)
Anchor(100-102)pkg/convert/ptr.go (1)
ToPointer(10-12)openmeter/ent/db/entitlement/where.go (1)
IssueAfterReset(120-122)
🪛 checkmake (0.2.2)
api/client/javascript/Makefile
[warning] 11-11: Missing required phony target "all"
(minphony)
[warning] 11-11: Missing required phony target "clean"
(minphony)
[warning] 11-11: Missing required phony target "test"
(minphony)
api/spec/Makefile
[warning] 17-17: Missing required phony target "all"
(minphony)
[warning] 17-17: Missing required phony target "clean"
(minphony)
[warning] 17-17: Missing required phony target "test"
(minphony)
e2e/Makefile
[warning] 34-34: Missing required phony target "all"
(minphony)
[warning] 34-34: Missing required phony target "clean"
(minphony)
[warning] 34-34: Missing required phony target "test"
(minphony)
🪛 Gitleaks (8.27.2)
docker-compose.base.yaml
123-123: Uncovered a JSON Web Token, which may lead to unauthorized access to web applications and sensitive user data.
(jwt)
🪛 Checkov (3.2.334)
docker-compose.base.yaml
[MEDIUM] 121-122: Basic Auth Credentials
(CKV_SECRET_4)
🔇 Additional comments (30)
api/client/javascript/src/zod/index.ts (3)
4522-4522: Constants for party key max length look good and consistent (256).Using explicit per-context constants mirrors the existing style in this file and keeps future changes localized.
Also applies to: 4531-4531
5916-5916: Supplier key max length (createBillingProfile) set to 256 — consistent with other key fields.No issues spotted.
6302-6302: Supplier key max length (updateBillingProfile) set to 256 — consistent and fine.Matches creation model and invoice model.
e2e/setup_test.go (1)
26-30: LGTM!The
shouldRunSlowTestshelper is well-implemented with proper test helper marking and provides a clean way to gate slow tests based on environment configuration.e2e/e2e_test.go (3)
1005-1010: LGTM! Well-structured slow test gating.The slow test wrapper appropriately uses the
shouldRunSlowTestshelper to conditionally skip time-consuming tests. The skip message clearly explains the reasoning and provides guidance for when to re-enable these tests.
1012-1040: LGTM! Proper reset test implementation.The reset test correctly waits for time to advance before performing the reset operation and validates the grants before proceeding. The implementation properly handles the timing constraints mentioned in the comments.
1047-1076: LGTM! Comprehensive entitlement creation test.The test properly validates the creation of an entitlement with automatic grant issuing, verifies the correct subject assignment, and confirms that grants are created as expected. The test structure is clear and follows good testing practices.
api/client/javascript/Makefile (4)
1-1: LGTM! Good documentation reference.The reference to the self-documenting Makefile pattern provides helpful context for maintainers and follows the same approach used across other Makefiles in the repository.
4-9: LGTM! Well-structured JavaScript SDK generation pipeline.The generate target follows a logical sequence: install dependencies with frozen lockfile, generate code, build, and test. The use of
--frozen-lockfileensures reproducible builds, and the inclusion of testing validates the generated output.
13-14: LGTM! Standard help target implementation.The help target correctly implements the self-documenting Makefile pattern with proper formatting and color output for improved usability.
20-22: LGTM! Consistent print-target macro.The
print-targetmacro provides consistent visual feedback across all Makefiles in the repository and improves the developer experience by clearly indicating which target is executing.api/spec/Makefile (5)
1-1: LGTM! Consistent documentation approach.The reference to the self-documenting Makefile pattern maintains consistency with other Makefiles in the repository.
4-9: LGTM! Proper OpenAPI spec generation workflow.The generate target correctly installs dependencies, compiles the specs, and copies the output files to their expected locations in the repository root. The use of
--frozen-lockfileensures reproducible builds.
12-15: LGTM! Clean linting target.The lint target follows the same pattern as generate with dependency installation and proper linting execution.
19-20: LGTM! Standard help implementation.The help target maintains consistency with the self-documenting pattern used across the repository.
26-28: LGTM! Consistent macro implementation.The
print-targetmacro matches the implementation used in other Makefiles, maintaining consistency across the repository.docker-compose.base.yaml (5)
4-25: LGTM! Comprehensive Kafka configuration.The Kafka service is properly configured for development use with appropriate environment variables, JMX monitoring, and a robust healthcheck. The configuration supports both internal and external connectivity patterns.
27-42: LGTM! Well-configured ClickHouse service.The ClickHouse configuration includes proper authentication, database setup, and ulimits for file descriptors. The healthcheck uses a reliable HTTP ping endpoint.
59-66: LGTM! Appropriate Redis configuration for development.The Redis service is configured with sensible memory limits and eviction policies for development use. The healthcheck properly validates Redis availability.
98-114: LGTM! Proper PostgreSQL setup with initialization.The PostgreSQL service includes proper authentication configuration, logical replication support, and initialization script mounting. The healthcheck validates database readiness.
131-136: LGTM! Proper database initialization script.The svix SQL configuration properly creates the user, database, and grants appropriate privileges. This is a clean approach for development environment setup.
e2e/docker-compose.openmeter-local.yaml (1)
1-11: LGTM! Well-documented docker-compose configuration.The file provides clear documentation about proper usage and intentional design decisions. The configuration correctly defines the required services for local e2e testing.
e2e/docker-compose.infra.yaml (1)
1-41: LGTM! Excellent port management for environment separation.The configuration correctly uses the 30000+ port range to avoid conflicts with the main dev environment. The service extensions are properly configured, and the inline SQL configuration for Svix is appropriate for testing scenarios.
Makefile (3)
26-30: Makefile generate target verified in api/client/javascript
Theapi/client/javascript/Makefileexists and defines thegenerate:target as expected:generate: ## Generate JavaScript SDK $(call print-target) pnpm --frozen-lockfile install pnpm run generate pnpm build pnpm testNo changes required.
23-24: Confirmed:generatetarget exists inapi/spec/MakefileRan a quick check and found this definition in api/spec/Makefile:
generate: ## Generate OpenAPI spec $(call print-target) pnpm --frozen-lockfile install pnpm compile cp output/openapi.OpenMeter.yaml ../openapi.yaml cp output/openapi.OpenMeterCloud.yaml ../openapi.cloud.yamlThe
generatetarget is present and correctly set up. No further action needed.
162-162: .spectral.yaml and OpenAPI spec validated
- ✓
.spectral.yamlexists and extends[spectral:oas, recommended]with the expected rule overrides- ✓
api/openapi.yamlis presentPlease ensure that the
spectralCLI is provided in your Nix environment (e.g. viashell.nixordefault.nix) so that thelint-openapitarget can invokespectral lintsuccessfully..github/workflows/ci.yaml (4)
107-165: LGTM! Excellent addition of code generation validation.The generators job properly ensures that all code generation is up-to-date by running
make generate-alland checking for uncommitted changes. The logic correctly handles both modified files (git diff) and new untracked files (git status --porcelain).
267-352: Excellent migration from Dagger to Nix-based linting.The lint job has been successfully migrated to use Nix tooling with several improvements:
- Smart caching: Base-commit aware lint caching will significantly improve performance
- Modular approach: Separate steps for different linters improve debuggability
- Proper environment: GOLANGCI_LINT_CACHE environment variable ensures consistent cache usage
391-470: Well-implemented artifact-driven quickstart testing.The quickstart job correctly:
- Depends on artifacts for container images
- Creates dynamic override files to use the built images
- Uses proper health checks and timeouts
- Runs tests with the correct environment variables
471-562: Robust e2e testing implementation.The e2e job follows the same excellent pattern as quickstart:
- Artifact-driven container images
- Proper service orchestration
- Health checks and readiness validation
- Log collection for debugging
The timeout of 3 minutes for e2e tests is appropriate given that long-sleep test cases are being skipped as mentioned in the PR objectives.
32b19e8 to
f963b2d
Compare
Linters
make lint: runs all linters (go, api spec, openapi.yaml, helm)make lint-api-spec: runs typespec lintersmake lint-openapi: runs openapi.yaml validators (spectral)make lint-helm: runs helm lintersGeneration
make gen-apigenerates the API + javascript clientmake update-openapigenerates the API, but now javascript client generation happensmake generate-allgenerates all artifactsCI validates that generators are ran on the PR
E2E + QuickStart
Both docker-compose setups rely on the base docker compose file.
The base docker-compose file now reusable.
There's no port conflict between dev, quickstart and e2e docker compose environments.
CI relies on the artifacts to be published by the CI to execute e2e and quickstart tests.
make etoeis the equivalent ofdagger call etoee2e: skip testcases that are sleeping for minutes. Those should be implemented as unit tests and rely on time-travel. (discussed with @GAlexIHU )
NIX
Add spectral, corepack as dependencies.
Other fixes
Remove dagger code that was replaced by nix based equivaltents.
Add missing binaries to dockerfile
TODO: helm charts should be also updated
make ciexecutes generators and all the tests/e2e/linters etc. (it's pretty slow, but if you want to make sure you can use this target)Regenerate JS library as we seem to have forgotten to regenerate that.
Summary by CodeRabbit
New Features
Tests
Documentation
Chores