fix: make startup tests and database cleanup conditional - #496
Conversation
📝 WalkthroughWalkthroughThe test workflows now set ChangesCORE test execution
Estimated code review effort: 2 (Simple) | ~10 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Pull request overview
Makes the Core API container startup behavior safer for local development by avoiding unconditional database cleanup and Go test execution on every container start, while attempting to preserve CI behavior by enabling those steps only when explicitly requested.
Changes:
- Gate database cleanup +
go test ./...incore_startup.shbehindRUN_TESTS=true. - Update CI workflows to prefix
docker compose upcommands withRUN_TESTS=trueto trigger the gated behavior.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| opengin/core-api/docker/core_startup.sh | Wraps DB cleanup and Go tests in a RUN_TESTS=true conditional during container startup. |
| .github/workflows/docker-compose-test.yml | Attempts to enable the gated startup tests/cleanup during the full compose CI run by setting RUN_TESTS=true. |
| .github/workflows/core-api-test.yml | Attempts to enable the gated startup tests/cleanup for the Core-only CI workflow by setting RUN_TESTS=true. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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/core-api-test.yml:
- Line 46: Update the core service environment in docker-compose.yml to declare
RUN_TESTS=${RUN_TESTS:-false}, ensuring workflow-provided RUN_TESTS reaches
core_startup.sh. Apply this for the workflow invocations at
.github/workflows/core-api-test.yml:46 and
.github/workflows/docker-compose-test.yml:26; no direct changes are needed in
either workflow file.
🪄 Autofix
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: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 1ceb000e-2750-4aab-9f70-e339f3d1c929
📒 Files selected for processing (3)
.github/workflows/core-api-test.yml.github/workflows/docker-compose-test.ymlopengin/core-api/docker/core_startup.sh
…TESTS Signed-off-by: Kavindu Sachinthe <kavix@yahoo.com>
257a6c7 to
cbbdda9
Compare
Description
This Pull Request resolves issue #465 where the
core_startup.shscript unconditionally ran database cleanups and Go tests every time the container started.The Problem
During local development, developers frequently need to restore/seed postgres and mongo databases with specific test data (e.g., using
./init.sh restore_from_github). Becausecore_startup.shran unconditionally on startup, any database restarts or rebuilds instantly wiped the databases, leading to500 Internal Server Errorsand null-pointer exceptions in the frontend UI.The Solution
RUN_TESTSenvironment variable:RUN_TESTSenvironment variable indocker-compose.yml(defaulting tofalse) so it can be passed from the host shell into the core container. No direct changes are needed in the workflow files as the runner environment'sRUN_TESTS=truewill automatically propagate through Compose.Changes
opengin/core-api/docker/core_startup.sh:[ "$RUN_TESTS" = "true" ].docker-compose.yml:RUN_TESTS=${RUN_TESTS:-false}to thecoreservice environment configuration to allow variable forwarding from host to container.Testing & Verification
coreservice:RUN_TESTSset: Verified database tables are not dropped and the container starts up immediately.RUN_TESTS=true: Verified the tests and databases cleanups run normally.DCO Sign-off
Signed-off-by: Kavindu Sachinthe kavix@yahoo.com