Document ActCommand mutation contract and add integration coverage (#70)#74
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
✅ Files skipped from review due to trivial changes (1)
📝 WalkthroughWalkthrough
ChangesActCommand mutation contract
Estimated code review effort: 2 (Simple) | ~10 minutes Sequence Diagram(s)sequenceDiagram
participant Test as test_act_command_mutation
participant ActCommandBuilder
participant JobExecutor
participant ActCommand
Test->>ActCommandBuilder: build ActCommand from workflow job
ActCommandBuilder-->>Test: ActCommand with env and secrets
Test->>JobExecutor: run(ActCommand, on_output callback)
JobExecutor->>ActCommand: set env_file, secret_file, ownership flags
JobExecutor->>Test: invoke on_output after temp files exist
JobExecutor->>JobExecutor: finally _cleanup_temp_files
JobExecutor-->>Test: job status PASSED
Test->>ActCommand: assert executor-owned temp files are removed
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
cli/localci/core/executor.py (1)
149-171: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winDocstring accurately reflects the mutation contract, but omits the env-file merge behavior.
The contract description is accurate for the "create fresh temp file" path (lines 611-658 below), but it doesn't mention that when a caller-supplied, unowned
env_filealready exists,_execute_processreads and merges its content into the new temp file (lines 618-626). Since this PR's stated goal is to fully document the mutation contract, worth calling out this merge step so callers relying on a pre-populatedenv_fileunderstand their data isn't simply discarded.📝 Suggested docstring addition
* :attr:`env_file` and :attr:`_executor_owned_env_file` are set when :attr:`env` is non-empty (a ``0600`` temp file is created). + If a caller-supplied, unowned ``env_file`` already exists, its contents + are merged into the new temp file before :attr:`env` entries are appended. * :attr:`secret_file` and :attr:`_executor_owned_secret_file` are set when :attr:`secrets` is non-empty (a ``0600`` temp file is created).🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@cli/localci/core/executor.py` around lines 149 - 171, The docstring for ActCommand’s mutation contract is missing the env_file merge behavior in JobExecutor._execute_process. Update the “Executor mutation contract” section to mention that when a caller-supplied, unowned env_file is already present, JobExecutor._execute_process reads and merges its contents into the new temp env file rather than discarding it. Keep the note aligned with the existing env_file/secret_file ownership language so callers understand how env state is preserved across ActCommand and JobExecutor.run.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@cli/localci/core/executor.py`:
- Around line 149-171: The docstring for ActCommand’s mutation contract is
missing the env_file merge behavior in JobExecutor._execute_process. Update the
“Executor mutation contract” section to mention that when a caller-supplied,
unowned env_file is already present, JobExecutor._execute_process reads and
merges its contents into the new temp env file rather than discarding it. Keep
the note aligned with the existing env_file/secret_file ownership language so
callers understand how env state is preserved across ActCommand and
JobExecutor.run.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: aa8a7757-2d8c-41d0-a895-19e4fdc1723d
📒 Files selected for processing (2)
cli/localci/core/executor.pycli/tests/integration/test_act_command_mutation.py
Summary
ActCommand/JobExecutormutation contract:build()stays pure;_execute_process()mutates the caller's instance (env_file,secret_file,_executor_owned_*) andrun()cleans up executor-owned temp files infinally.ActCommandinstances are single-use per execution; reuse and concurrent sharing are unsupported.test_act_command_mutation_and_cleanup) that exercises the realactsubprocess path and asserts mutation during the run plus cleanup afterward.Closes #70.
Test plan
pre-commit run -a(ruff, ruff-format, mypy)cd cli && pytest tests/— 595 unit tests passcd cli && pytest tests/integration/test_act_command_mutation.py— passes whenact+ Docker are available; skips otherwise (excluded from default CI vianorecursedirs)Summary by CodeRabbit
env_file/secret_fileare created during execution, mutation occurs only after expected output, the job completes successfully, and the executor temp files are removed afterward.