Skip to content

fix: make startup tests and database cleanup conditional - #496

Open
kavix wants to merge 1 commit into
LDFLK:mainfrom
kavix:fix-core-startup-conditional-tests
Open

fix: make startup tests and database cleanup conditional#496
kavix wants to merge 1 commit into
LDFLK:mainfrom
kavix:fix-core-startup-conditional-tests

Conversation

@kavix

@kavix kavix commented Aug 12, 2026

Copy link
Copy Markdown

Description

This Pull Request resolves issue #465 where the core_startup.sh script 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). Because core_startup.sh ran unconditionally on startup, any database restarts or rebuilds instantly wiped the databases, leading to 500 Internal Server Errors and null-pointer exceptions in the frontend UI.

The Solution

  • Wraps the test suite and database cleanup logic in a conditional block that checks for the RUN_TESTS environment variable:
    if [ "$RUN_TESTS" = "true" ]; then
      ...
    fi
  • Skips tests and database cleanups in local development by default, keeping seeded databases intact.
  • Exposes the RUN_TESTS environment variable in docker-compose.yml (defaulting to false) 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's RUN_TESTS=true will automatically propagate through Compose.

Changes

  • opengin/core-api/docker/core_startup.sh:
    • Enclosed cleanup and testing block in a check for [ "$RUN_TESTS" = "true" ].
  • docker-compose.yml:
    • Added RUN_TESTS=${RUN_TESTS:-false} to the core service environment configuration to allow variable forwarding from host to container.

Testing & Verification

  • Tested locally by rebuilding and restarting the core service:
    • Without RUN_TESTS set: Verified database tables are not dropped and the container starts up immediately.
    • With RUN_TESTS=true: Verified the tests and databases cleanups run normally.
  • Verified that shell script syntax remains valid.

DCO Sign-off

Signed-off-by: Kavindu Sachinthe kavix@yahoo.com

Copilot AI lite review requested due to automatic review settings August 12, 2026 14:40
@coderabbitai

coderabbitai Bot commented Aug 12, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The test workflows now set RUN_TESTS=true. The CORE startup script runs database cleanup and Go tests only when this value is enabled.

Changes

CORE test execution

Layer / File(s) Summary
Workflow wiring and conditional startup tests
.github/workflows/core-api-test.yml, .github/workflows/docker-compose-test.yml, opengin/core-api/docker/core_startup.sh
Both test workflows set RUN_TESTS=true. The startup script conditionally performs database cleanup, Go tests, failure handling, and post-test cleanup.

Estimated code review effort: 2 (Simple) | ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: startup tests and database cleanup now run conditionally.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 ./... in core_startup.sh behind RUN_TESTS=true.
  • Update CI workflows to prefix docker compose up commands with RUN_TESTS=true to 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.

Comment thread .github/workflows/docker-compose-test.yml Outdated
Comment thread .github/workflows/core-api-test.yml Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between b85611f and 7121a16.

📒 Files selected for processing (3)
  • .github/workflows/core-api-test.yml
  • .github/workflows/docker-compose-test.yml
  • opengin/core-api/docker/core_startup.sh

Comment thread .github/workflows/core-api-test.yml Outdated
…TESTS

Signed-off-by: Kavindu Sachinthe <kavix@yahoo.com>
@kavix
kavix force-pushed the fix-core-startup-conditional-tests branch from 257a6c7 to cbbdda9 Compare August 12, 2026 14:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants