Skip to content

Conversation

@Kyle-Ye
Copy link
Contributor

@Kyle-Ye Kyle-Ye commented Nov 2, 2025

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 Name New Name Notes
OPENATTRIBUTEGRAPH_DEVELOPMENT DEVELOPMENT Searches OPENATTRIBUTEGRAPH_*, OPENSWIFTUI_*
OPENATTRIBUTEGRAPH_WERROR WERROR Domain-based search
OPENATTRIBUTEGRAPH_LIBRARY_EVOLUTION LIBRARY_EVOLUTION Domain-based search
OPENATTRIBUTEGRAPH_COMPATIBILITY_TEST COMPATIBILITY_TEST Domain-based search
OPENATTRIBUTEGRAPH_USE_LOCAL_DEPS USE_LOCAL_DEPS Domain-based search
OPENATTRIBUTEGRAPH_ATTRIBUTEGRAPH ATTRIBUTEGRAPH Domain-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-actions github-actions bot added enhancement New feature or request build issue labels Nov 2, 2025
@codecov
Copy link

codecov bot commented Nov 2, 2025

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 main Nov 2, 2025
5 checks passed
@Kyle-Ye Kyle-Ye changed the title Optimize environment variable management with EnvManager Refactor: Introduce EnvManager for structured environment variable handling Nov 2, 2025
@Kyle-Ye Kyle-Ye deleted the optimize/env_manager branch November 2, 2025 17:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build issue enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants