feat(cli): add --env-file flag to luca run#88
Merged
Conversation
Introduces EnvFileLoader with EnvFileLoading protocol for loading flat YAML env-var files into [String: String] dictionaries, with typed errors for missing files and non-flat/non-string YAML content. Includes mock and full Swift Testing test suite (7 tests).
Introduces EnvFileLoaderFileManaging protocol and injects it into EnvFileLoader, replacing direct Data(contentsOf:) usage. Extends FileManager to conform to the protocol. Also adds @testable import LucaFoundation to the test file and makes EnvFileLoaderMock final.
Adds envFileEnvironment parameter to PipelineRunning protocol required method and PipelineRunner.run(), with merge order: process env ← env-file env ← pipeline-level env ← task-level env. Convenience overloads forward with envFileEnvironment: [:] for backward compatibility.
Wires up EnvFileLoader into RunCommand: resolves the env file path (defaulting to luca-env-vars.yml), passes envFileEnvironment to PipelineRunner, and surfaces it in dry-run output with sorted keys and as the base context layer for when-condition evaluation.
…nv-file loading - Inject fileManager into EnvFileLoader for consistency with other components - Remove redundant fileExists pre-check that had TOCTOU race condition - Catch fileNotFound from load() directly instead of checking file existence first
- Add string-only constraint to --env-file help text noting that unquoted numbers and booleans are not accepted - Remove orphaned EnvFileLoaderMock that was never used by tests - Add test_load_booleanValue_throwsInvalidFormat to cover YAML boolean literals like 'true'/'false' - Simplify fileNotFound error handling in RunCommand.run() using binding pattern with where guard
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
--env-file <path>option to theruncommand, defaulting to.envin the current directory when present.env:blocks in the YAML: process env → env file → pipeline env → task env.when:condition evaluation and shown in--dry-runoutput.Type of Change
How Has This Been Tested?
New tests added:
EnvFileLoaderTests(9 tests): valid KEY=VALUE pairs, quoted values, comment lines, empty lines, value with=in it (URL), missing file, line without=, error descriptions.PipelineRunnerTests(6 new tests): env file vars passed to subprocess, pipeline env overrides env file, task env overrides env file, empty env file is a no-op, env file vars visible towhen:condition evaluation.swift test— 504 tests passing.Checklist
Breaking Changes?
Additional Notes
File format — standard dotenv: one
KEY=VALUEpair per line,#comments, blank lines ignored, surrounding single/double quotes on values are stripped.Priority order (lowest → highest): inherited process env →
.envfile → pipeline YAMLenv:block → task YAMLenv:block.