Skip to content

Refactor: Introduce EnvManager for structured environment variable handling - #194

Merged
Kyle-Ye merged 5 commits into
mainfrom
optimize/env_manager
Nov 2, 2025
Merged

Refactor: Introduce EnvManager for structured environment variable handling#194
Kyle-Ye merged 5 commits into
mainfrom
optimize/env_manager

Conversation

@Kyle-Ye

@Kyle-YeKyle-Ye commented Nov 2, 2025

Copy link
Copy Markdown
Member

Summary

Introduces a comprehensive EnvManager system to replace the simple envEnable() function with structured, testable, and maintainable environment variable management.

Key Features

1. Domain-based Variable Lookup

  • Automatically searches for domain-prefixed environment variables (e.g., OPENATTRIBUTEGRAPH_*, OPENSWIFTUI_*)
  • Supports fallback to raw key with includeFallbackToRawKey option
  • Cleaner variable names: DEVELOPMENT instead of OPENATTRIBUTEGRAPH_DEVELOPMENT

2. Multiple Value Types

  • envBoolValue() - Boolean environment variables (0/1)
  • envIntValue() - Integer environment variables
  • envStringValue() - String environment variables
  • All return optional types for better error handling

3. Testability & Flexibility

  • Custom environment provider support via EnvironmentProvider protocol
  • reset() method for test cleanup
  • withDomain() for temporary domain contexts
  • Dependency injection ready

4. Enhanced Debugging

  • Automatic logging of environment variable resolution
  • Shows which key was checked and the resolved value
  • Displays when default values are used

Environment Variable Changes

All environment variables now use shorter names with automatic domain prefixing:

Old NameNew NameNotes
OPENATTRIBUTEGRAPH_DEVELOPMENTDEVELOPMENTSearches OPENATTRIBUTEGRAPH_*, OPENSWIFTUI_*
OPENATTRIBUTEGRAPH_WERRORWERRORDomain-based search
OPENATTRIBUTEGRAPH_LIBRARY_EVOLUTIONLIBRARY_EVOLUTIONDomain-based search
OPENATTRIBUTEGRAPH_COMPATIBILITY_TESTCOMPATIBILITY_TESTDomain-based search
OPENATTRIBUTEGRAPH_USE_LOCAL_DEPSUSE_LOCAL_DEPSDomain-based search
OPENATTRIBUTEGRAPH_ATTRIBUTEGRAPHATTRIBUTEGRAPHDomain-based search

Benefits

  • ✅ More maintainable and testable code
  • ✅ Better debugging with automatic logging
  • ✅ Type-safe value parsing with optional types
  • ✅ Flexible domain-based search with fallback options
  • ✅ Supports nested domain contexts with withDomain()
  • ✅ Backward compatible through domain-based search

Testing

  • Package builds successfully with various environment variable configurations
  • Both old (fully-qualified) and new (short) variable names work

@github-actionsgithub-actionsBot added enhancement New feature or request build issue labels Nov 2, 2025
@codecov

codecovBot commented Nov 2, 2025

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 4.87%. Comparing base (21426f2) to head (7a9d9d8).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@ Coverage Diff @@## main #194 +/- ##
=====================================
Coverage 4.87% 4.87% =====================================
Files 28 28 Lines 820 820 =====================================
Hits 40 40 Misses 780 780 

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Kyle-Ye
Kyle-Ye merged commit 701ea17 into mainNov 2, 2025
5 checks passed
@Kyle-YeKyle-Ye changed the title Optimize environment variable management with EnvManagerRefactor: Introduce EnvManager for structured environment variable handlingNov 2, 2025
@Kyle-Ye
Kyle-Ye deleted the optimize/env_manager branch November 2, 2025 17:47
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build issueenhancementNew feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

@Kyle-Ye