feat: Add temp dir option#2891
Open
kjasn wants to merge 4 commits into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
Adds support for configuring Task’s temporary directory via .taskrc.yml (temp-dir) and the TASK_TEMP_DIR environment variable, wiring the resolved value into executor setup and updating docs/schemas accordingly.
Changes:
- Add
temp-dirto taskrc AST + merge logic, and add unit tests covering parsing/merge precedence. - Introduce
Executor.TempDirPath/WithTempDirPathand use it duringExecutorsetup to buildExecutor.TempDir. - Update website docs and JSON schema for
.taskrc.yml, plus VS Code YAML schema mapping.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| website/src/public/schema-taskrc.json | Adds temp-dir to the taskrc JSON schema. |
| website/src/docs/reference/config.md | Documents the new temp-dir config option and adds it to the example config. |
| taskrc/taskrc_test.go | Adds tests for temp-dir parsing and merge precedence across config locations. |
| taskrc/ast/taskrc.go | Adds TempDir field and merges it during TaskRC merge. |
| setup.go | Adds temp-dir resolution helper and uses it to initialize Executor.TempDir. |
| internal/flags/flags.go | Reads temp-dir from env/taskrc into executor options (no CLI flag). |
| executor.go | Adds TempDirPath + WithTempDirPath option for unresolved temp dir configuration. |
| .vscode/settings-sample.json | Adds YAML schema association for .taskrc.* files. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+131
to
+140
| func (e *Executor) configuredTempDirPath() string { | ||
| // Priority: OS env > taskrc/env > default | ||
| if tempDir := env.GetTaskEnv("TEMP_DIR"); tempDir != "" { | ||
| return tempDir | ||
| } | ||
| if e.TempDirPath != "" { | ||
| return e.TempDirPath | ||
| } | ||
| return ".task" | ||
| } |
Author
There was a problem hiding this comment.
The precedence behavior is same as internal/flags/flags.go:319:
// getConfig extracts a config value with priority: env var > taskrc config > fallback
func getConfig[T any](config *taskrcast.TaskRC, envKey string, fieldFunc func() *T, fallback T) T {
// xxx
};
Comment on lines
+131
to
+135
| func (e *Executor) configuredTempDirPath() string { | ||
| // Priority: OS env > taskrc/env > default | ||
| if tempDir := env.GetTaskEnv("TEMP_DIR"); tempDir != "" { | ||
| return tempDir | ||
| } |
Author
There was a problem hiding this comment.
I think it has some file reading order issue, so it doesn't support this for now.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
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.
Close #998
Support
temp-diroption in.taskrc.ymland env variable. Haven't supported option or configuration in dotenv andTaskfile.ymldue to some file reading order issues.AI helped with generating some unit test in this PR.