Skip to content

Conversation

@yamcodes
Copy link
Contributor

@yamcodes yamcodes commented Jul 4, 2025

  • Introduced a separate test environment configuration in src/core/test-env.ts to isolate test-specific variables from production settings.
  • Updated test scripts to utilize the new test environment variables, enhancing clarity and maintainability.
  • Added documentation in README.md to outline the new environment configuration structure.

Summary by CodeRabbit

  • Documentation

    • Added a new "Environment Configuration" section to the README, clarifying the separation between production and test environment variables.
  • Chores

    • Isolated test-specific environment variables into a dedicated configuration, ensuring they are used exclusively by test scripts and runners.
    • Updated test scripts to reference the new test environment configuration.

- Introduced a separate test environment configuration in `src/core/test-env.ts` to isolate test-specific variables from production settings.
- Updated test scripts to utilize the new test environment variables, enhancing clarity and maintainability.
- Added documentation in `README.md` to outline the new environment configuration structure.
@yamcodes yamcodes linked an issue Jul 4, 2025 that may be closed by this pull request
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jul 4, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

A new test-specific environment configuration module was introduced, isolating variables used exclusively for testing. The main environment configuration was updated to remove these test-related variables. Documentation was added to clarify this separation, and test scripts were updated to use the new test environment module.

Changes

File(s) Change Summary
README.md Added documentation about separating production and test environment variables.
scripts/test/api.ts Updated imports and usage to source test-specific environment variables from the new test environment module.
src/core/env.ts Removed test-related environment variable declarations from the production environment configuration.
src/core/test-env.ts Added new module defining and exporting test-specific environment variables with type validation and defaults.

Sequence Diagram(s)

sequenceDiagram
    participant TestRunner as Test Script
    participant testEnv as test-env.ts
    participant env as env.ts

    TestRunner->>testEnv: Import test-specific variables (APIURL, USERNAME, etc.)
    TestRunner->>env: Import production variables (if needed)
    Note over TestRunner: Test scripts use only testEnv for test variables
    Note over env: Production code uses env (without test variables)
Loading

Possibly related issues

Poem

In the warren of code, a new path appears,
Test secrets now hidden, away from our peers.
Production stays clean, while tests have their den,
Variables sorted—no mix-up again!
🐇✨
Hop, skip, and jump—let’s test with delight,
Our configs are tidy, all set for the night!


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b05e84e and 2b9599d.

📒 Files selected for processing (1)
  • scripts/test/api.ts (2 hunks)
✨ Finishing Touches
  • 📝 Generate Docstrings

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.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (3)
scripts/test/api.ts (1)

8-14: Destructure testEnv instead of repeating assignments

Seven back-to-back lines perform one-to-one re-assignments that can be removed entirely by destructuring once. This trims noise and avoids a drift between the constant names and the source keys.

-import { testEnv } from "@/core/test-env";
-
-const APIURL = testEnv.APIURL;
-const USERNAME = testEnv.USERNAME;
-const EMAIL = testEnv.EMAIL;
-const PASSWORD = testEnv.PASSWORD;
-const POSTMAN_COLLECTION = testEnv.POSTMAN_COLLECTION;
+import { testEnv } from "@/core/test-env";
+const {
+  APIURL,
+  USERNAME,
+  EMAIL,
+  PASSWORD,
+  POSTMAN_COLLECTION,
+} = testEnv;
src/core/test-env.ts (1)

5-15: Add stronger validation for URL & e-mail fields

APIURL and EMAIL are currently typed as plain strings. elysia-env supports .url() / .email() helpers (or .regex() fallback) giving early feedback when a test runner mis-configures these values.

-  APIURL: t.String({ default: "http://localhost:3000/api" }),
-  EMAIL: t.String({ default: "jake@jake.jake" }),
+  APIURL: t.URL({ default: "http://localhost:3000/api" }),
+  EMAIL: t.String().email({ default: "jake@jake.jake" }),
README.md (1)

24-29: Reference .env.test earlier to avoid reader confusion

Nice addition! A quick pointer to the .env.test workflow right here would save new contributors a scroll-hunt and make the section self-contained.

-Test-specific environment variables are now defined in `src/core/test-env.ts` and are only used by test scripts and test runners. This keeps test configuration isolated from production config.
+Test-specific environment variables are now defined in `src/core/test-env.ts` and are only used by test scripts and test runners. This keeps test configuration isolated from production config.
+
+> **Note:** If you need to override any defaults, copy `.env.test.example` to `.env.test` and adjust as required before running tests.
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5c00d5f and b05e84e.

📒 Files selected for processing (4)
  • README.md (1 hunks)
  • scripts/test/api.ts (2 hunks)
  • src/core/env.ts (0 hunks)
  • src/core/test-env.ts (1 hunks)
💤 Files with no reviewable changes (1)
  • src/core/env.ts
🧰 Additional context used
🧠 Learnings (4)
📓 Common learnings
Learnt from: yamcodes
PR: bedtime-coders/bepstack#9
File: src/core/env.ts:25-28
Timestamp: 2025-07-04T15:36:36.132Z
Learning: In the bepstack project, there's a local copy strategy for the Postman collection where `.env.test.example` contains `POSTMAN_COLLECTION=./tests/Conduit.postman_collection.json` pointing to a local copy, providing a fallback for testing scenarios while the main env.ts uses the remote GitHub URL as default.
Learnt from: yamcodes
PR: bedtime-coders/bepstack#9
File: src/core/env.ts:22-24
Timestamp: 2025-07-04T15:34:10.224Z
Learning: In the bepstack project, hardcoded test credentials in environment configuration files are acceptable and don't need to be flagged as security issues.
Learnt from: yamcodes
PR: bedtime-coders/bepstack#9
File: src/core/env.ts:25-28
Timestamp: 2025-07-04T15:43:01.460Z
Learning: In the bepstack project, the .env.test.example file contains `POSTMAN_COLLECTION=./scripts/test/Conduit.postman_collection.json` pointing to a local copy in the scripts/test directory, not the tests directory as initially assumed.
Learnt from: yamcodes
PR: bedtime-coders/bepstack#9
File: src/core/env.ts:25-28
Timestamp: 2025-07-04T15:36:36.132Z
Learning: In the bepstack project, `.env.test.example` contains `POSTMAN_COLLECTION=./tests/Conduit.postman_collection.json` as a planned local fallback strategy, but the tests directory and local Postman collection file need to be created to complete the implementation.
Learnt from: yamcodes
PR: bedtime-coders/bepstack#9
File: src/core/env.ts:25-28
Timestamp: 2025-07-04T15:43:01.460Z
Learning: In the bepstack project, the local fallback strategy for POSTMAN_COLLECTION is now fully implemented with the file existing at scripts/test/Conduit.postman_collection.json and .env.test.example correctly configured to use the local path.
README.md (5)
Learnt from: yamcodes
PR: bedtime-coders/bepstack#9
File: src/core/env.ts:25-28
Timestamp: 2025-07-04T15:36:36.132Z
Learning: In the bepstack project, there's a local copy strategy for the Postman collection where `.env.test.example` contains `POSTMAN_COLLECTION=./tests/Conduit.postman_collection.json` pointing to a local copy, providing a fallback for testing scenarios while the main env.ts uses the remote GitHub URL as default.
Learnt from: yamcodes
PR: bedtime-coders/bepstack#9
File: src/core/env.ts:25-28
Timestamp: 2025-07-04T15:36:36.132Z
Learning: In the bepstack project, `.env.test.example` contains `POSTMAN_COLLECTION=./tests/Conduit.postman_collection.json` as a planned local fallback strategy, but the tests directory and local Postman collection file need to be created to complete the implementation.
Learnt from: yamcodes
PR: bedtime-coders/bepstack#9
File: src/core/env.ts:25-28
Timestamp: 2025-07-04T15:43:01.460Z
Learning: In the bepstack project, the .env.test.example file contains `POSTMAN_COLLECTION=./scripts/test/Conduit.postman_collection.json` pointing to a local copy in the scripts/test directory, not the tests directory as initially assumed.
Learnt from: yamcodes
PR: bedtime-coders/bepstack#9
File: src/core/env.ts:22-24
Timestamp: 2025-07-04T15:34:10.224Z
Learning: In the bepstack project, hardcoded test credentials in environment configuration files are acceptable and don't need to be flagged as security issues.
Learnt from: yamcodes
PR: bedtime-coders/bepstack#9
File: src/core/env.ts:25-28
Timestamp: 2025-07-04T15:43:01.460Z
Learning: In the bepstack project, the local fallback strategy for POSTMAN_COLLECTION is now fully implemented with the file existing at scripts/test/Conduit.postman_collection.json and .env.test.example correctly configured to use the local path.
scripts/test/api.ts (5)
Learnt from: yamcodes
PR: bedtime-coders/bepstack#9
File: src/core/env.ts:25-28
Timestamp: 2025-07-04T15:36:36.132Z
Learning: In the bepstack project, there's a local copy strategy for the Postman collection where `.env.test.example` contains `POSTMAN_COLLECTION=./tests/Conduit.postman_collection.json` pointing to a local copy, providing a fallback for testing scenarios while the main env.ts uses the remote GitHub URL as default.
Learnt from: yamcodes
PR: bedtime-coders/bepstack#9
File: src/core/env.ts:25-28
Timestamp: 2025-07-04T15:43:01.460Z
Learning: In the bepstack project, the .env.test.example file contains `POSTMAN_COLLECTION=./scripts/test/Conduit.postman_collection.json` pointing to a local copy in the scripts/test directory, not the tests directory as initially assumed.
Learnt from: yamcodes
PR: bedtime-coders/bepstack#9
File: src/core/env.ts:25-28
Timestamp: 2025-07-04T15:36:36.132Z
Learning: In the bepstack project, `.env.test.example` contains `POSTMAN_COLLECTION=./tests/Conduit.postman_collection.json` as a planned local fallback strategy, but the tests directory and local Postman collection file need to be created to complete the implementation.
Learnt from: yamcodes
PR: bedtime-coders/bepstack#9
File: src/core/env.ts:25-28
Timestamp: 2025-07-04T15:43:01.460Z
Learning: In the bepstack project, the local fallback strategy for POSTMAN_COLLECTION is now fully implemented with the file existing at scripts/test/Conduit.postman_collection.json and .env.test.example correctly configured to use the local path.
Learnt from: yamcodes
PR: bedtime-coders/bepstack#9
File: src/core/env.ts:22-24
Timestamp: 2025-07-04T15:34:10.224Z
Learning: In the bepstack project, hardcoded test credentials in environment configuration files are acceptable and don't need to be flagged as security issues.
src/core/test-env.ts (3)
Learnt from: yamcodes
PR: bedtime-coders/bepstack#9
File: src/core/env.ts:25-28
Timestamp: 2025-07-04T15:36:36.132Z
Learning: In the bepstack project, there's a local copy strategy for the Postman collection where `.env.test.example` contains `POSTMAN_COLLECTION=./tests/Conduit.postman_collection.json` pointing to a local copy, providing a fallback for testing scenarios while the main env.ts uses the remote GitHub URL as default.
Learnt from: yamcodes
PR: bedtime-coders/bepstack#9
File: src/core/env.ts:25-28
Timestamp: 2025-07-04T15:36:36.132Z
Learning: In the bepstack project, `.env.test.example` contains `POSTMAN_COLLECTION=./tests/Conduit.postman_collection.json` as a planned local fallback strategy, but the tests directory and local Postman collection file need to be created to complete the implementation.
Learnt from: yamcodes
PR: bedtime-coders/bepstack#9
File: src/core/env.ts:25-28
Timestamp: 2025-07-04T15:43:01.460Z
Learning: In the bepstack project, the .env.test.example file contains `POSTMAN_COLLECTION=./scripts/test/Conduit.postman_collection.json` pointing to a local copy in the scripts/test directory, not the tests directory as initially assumed.

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@yamcodes yamcodes merged commit aea137c into main Jul 4, 2025
6 of 8 checks passed
@yamcodes yamcodes deleted the 12-separate-test-specific-environment-variables-from-production-config branch July 4, 2025 17:07
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.

Separate test-specific environment variables from production config

2 participants