Skip to content

Commit 2641081

Browse files
8bitAlexclaude
andauthored
Task runner (#5)
* simple task-runner * additional task configurations * fix shell exec and add shell config * load env vars * cleanup and tests * bug fixes * Simplify readme * add http, wait, and template task types * add condition, group, and git task types * add command based tasks * general cleanup * ignore any ai files * rename * add unit tests * user defined raid subcommands * command tests * set task path * support multi platform * add zsh support and direct script execution tests * fix: ensure file is closed after creation in getOrCreateConfigFile * fix: update getShell tests for Windows compatibility and remove redundant cases * resolve PR review comments: correctness and cross-platform fixes * fix: update codecov workflow to include Go setup and improve test coverage command * fix: add Windows support for getShell function * fix: enhance command handling and error reporting in task execution * fix: improve config file handling and error reporting, enhance YAML to JSON conversion * fix: enhance getShell function to prioritize pwsh over powershell, update tests accordingly * fix: enhance config file handling by expanding paths and improving directory validation * fix: validate JSON arrays element-by-element and apply withDefaultDir to Groups - validateFile now detects top-level JSON arrays and validates each element individually, matching extractProfilesFromJSON which supports both single- object and array-of-objects profile files - ForceLoad now applies withDefaultDir to profile.Groups so Shell tasks inside Group/Parallel/Retry tasks use the home dir as default working directory, consistent with Commands tasks Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * test: use exit 0 instead of test -n in literal shell task test test -n is a POSIX shell built-in unavailable in cmd.exe on Windows, causing the test to fail in the windows-latest CI matrix. exit 0 is universally available in both cmd and POSIX shells. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * fix: error on empty YAML in validateFile An empty YAML file produced zero decode iterations, so validateFile returned nil even when the schema required fields like 'name'. Track the document count and return an error when the stream contains no documents. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * fix: handle -c=path shorthand and -- end-of-flags in applyConfigFlag Previously applyConfigFlag missed the -c=value shorthand form and would continue scanning positional args after a -- end-of-flags marker, risking picking up the wrong config path or treating positional args as flags. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * fix: return error from Write/Set instead of panicking config.Write() panicked on viper.WriteConfig failure, which crashes the process instead of letting callers handle the error. Changed Write() and Set() to return error, and propagated through SetProfile, AddProfile, AddProfiles, RemoveProfile, and SetEnv. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * fix: discard stdout/stderr during condition command evaluation A Condition task's Cmd ran with inherited stdout/stderr, polluting the terminal output with the condition check's output. Condition evaluation is a boolean probe — its output is noise to the user. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * fix: create parent directories before opening command output file os.Create fails when the parent directory does not exist. Added MkdirAll before creating the output file, matching the behaviour of the HTTP download task. Updated the test to use a path whose parent is a regular file so MkdirAll itself fails. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * fix: treat non-2xx responses as not-ready in checkHTTP checkHTTP returned nil for any HTTP response including 4xx/5xx, causing execWait to consider a server that is returning errors as ready and stop waiting prematurely. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * fix: add pwsh and ps to shell enum in both schemas getShell() accepts "pwsh" and "ps" as aliases for PowerShell, but neither schema listed them, causing schema validation to reject otherwise-valid configs. Both the root schema and the embedded runtime copy are updated together. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * fix: validate that Cmd is non-empty in execShell An empty Cmd would silently invoke the shell with no arguments and exit 0, masking misconfigurations. Return a clear error instead, consistent with the required-field checks in HTTP/Wait/Template tasks. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * fix: serialize stdin reads with a mutex in Prompt and Confirm Both tasks read from os.Stdin and can be marked concurrent:true. Without synchronization, concurrent Prompt/Confirm tasks interleave reads, hang, or consume each other's input. A package-level stdinMu mutex ensures stdin is held exclusively for the duration of each prompt, making concurrent execution effectively sequential for user input. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * fix: add stage prefix to Initialize() fatal error messages Without context, a fatal during initialization only shows the raw error string with no indication of which stage failed. Adding "init config:" and "load profile:" prefixes makes CLI failures easier to diagnose. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * fix: warn to stderr when a profile command shadows a built-in Commands whose names match reserved subcommands were silently skipped, giving no indication in help output or logs. Now emits a warning to stderr so users know why their command is missing. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * fix: nil-check context before dereferencing in Install Install() accessed context.Profile unconditionally. If called before Initialize() sets the context, this panics. Added a nil guard consistent with the pattern used in ExecuteEnv and GetCommands. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 5feb4a1 commit 2641081

45 files changed

Lines changed: 6090 additions & 702 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/codecov.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,12 @@ jobs:
1414
runs-on: ubuntu-latest
1515
steps:
1616
- uses: actions/checkout@v4
17+
- name: Set up Go
18+
uses: actions/setup-go@v5
19+
with:
20+
go-version: '1.24.4'
1721
- name: Run Tests
18-
run: go test -coverprofile=coverage.txt
22+
run: go test -coverprofile=coverage.txt -covermode=atomic ./...
1923
- uses: codecov/codecov-action@v5
2024
with:
2125
token: ${{ secrets.CODECOV_TOKEN }}

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,7 @@ go.work.sum
2424

2525
# env file
2626
.env
27+
28+
# AI assistant files
29+
CLAUDE.md
30+
.claude/

0 commit comments

Comments
 (0)