Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unify env loading #163

Open
6 tasks
ygrishajev opened this issue Apr 15, 2024 · 1 comment
Open
6 tasks

Unify env loading #163

ygrishajev opened this issue Apr 15, 2024 · 1 comment
Labels
enhancement New feature or request P3 priority 3 feature/ enhancement

Comments

@ygrishajev
Copy link
Collaborator

Problem Statement

Currently, our project's configuration management is fragmented; some settings are loaded from JSON files, others from .env files, and some configurations are hardcoded within the application. This inconsistency can lead to difficulties in maintaining and scaling our environment management effectively.

Objective

To streamline and unify configuration management across the entire project, transitioning all configurations to utilize environment files that are managed through direnv. If direnv proves incompatible or suboptimal, especially in diverse development environments including Windows, we will fall back to using dotenv. This approach aligns with the methods used by our core team and enhances consistency across different development environments.

Task Details

  1. Research and Feasibility Study

    • Task: Investigate the compatibility and implementation strategy of direnv for managing environment variables in a Node.js context and assess its support across different operating systems, including Windows.
    • Acceptance Criteria:
      • Confirm that direnv can be integrated seamlessly with Node.js.
      • Ensure that direnv setup is compatible with Windows or provide alternative setup instructions for Windows users.
  2. Fallback Plan: dotenv Implementation

    • Task: Prepare to implement dotenv if direnv integration fails to meet functional or compatibility criteria.
    • Details: Setup dotenv to manage environment variables, loading them from .env files at application startup.
    • Acceptance Criteria:
      • Ensure smooth integration of dotenv as an alternative to direnv, maintaining the ease of configuration management across environments.
  3. Implementation of Environment Management Solution

    • Task: Implement the chosen environment variable management tool (direnv or dotenv).
    • Details: Configure the tool to load environment variables from .env files across different local development environments automatically.
    • Acceptance Criteria:
      • All existing configurations from JSON files and hardcoded settings are migrated to .env files.
      • The chosen tool is configured to autoload these settings seamlessly when entering the project directory.
  4. Distinct Environment Files for Testing

    • Task: Configure separate environment files for unit and functional tests.
    • Details: Create .env.unit.tests for unit testing with Jest and .env.functional.test for functional testing with either Cypress or Playwright.
    • Acceptance Criteria:
      • Each set of tests (unit and functional) uses its respective environment file, ensuring no cross-contamination of settings.
  5. Update Documentation

    • Task: Document the new environment management approach in the README.
    • Details: Include detailed instructions and examples on setting up and using the chosen environment management tool, emphasizing the specific configurations for development, testing, and production environments.
    • Acceptance Criteria:
      • The README contains clear, comprehensive instructions and examples that enable team members to set up and use the environment management tool independently.
  6. Update CI Configuration

    • Task: Ensure that the CI configurations align with the new environment management tool.
    • Details: Update the CI pipeline scripts to correctly load environment variables from the new .env files during automated test runs and deployments.
    • Acceptance Criteria:
      • CI configurations are successfully updated and verified to function with the new environment setup, ensuring all automated processes are compliant with the updated management strategy.

Task Checklist

  • Investigate direnv compatibility with Node.js and assess cross-platform support.
  • Prepare dotenv as a fallback option if direnv is unsuitable.
  • Implement the chosen environment variable management tool.
  • Set up distinct .env files for unit and functional tests.
  • Document the setup process in the README.
  • Update and verify CI configurations to work with the new environment management tool.

This task is crucial for maintaining a consistent and secure configuration management strategy across our development environments, facilitating easier maintenance and scalability of our application settings.

@ygrishajev
Copy link
Collaborator Author

actually envrc can be used along with dotenv https://github.com/akash-network/akash-api/blob/main/.envrc#L5
so let's do that

@ygrishajev ygrishajev added the enhancement New feature or request label Apr 17, 2024
@baktun14 baktun14 added the P3 priority 3 feature/ enhancement label Apr 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request P3 priority 3 feature/ enhancement
Projects
Status: Backlog (not prioritized)
Development

No branches or pull requests

2 participants