Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
"CGO_ENABLED": "0"
},
"args": [
"--env_file=${workspaceFolder}/.env",
"/Users/sebastian/Desktop/test.act",
"--config_file=/Users/sebastian/Desktop/test.actconfig",
"--concurrency=1"
]
},
{
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,17 +62,17 @@ actrun ./my_graph.act --target="production" --verbose
If you need to strictly separate CLI flags from graph arguments, use the `--` separator:

```bash
actrun --env_file=.env -- ./my_graph.act --target="production"
actrun --env-file=.env -- ./my_graph.act --target="production"


```

### 🌍 3. Load Environment Variables

Inject environment variables from a file before execution starts using `--env_file`.
Inject environment variables from a file before execution starts using `--env-file`.

```bash
actrun --env_file=.env.local ./my_graph.act
actrun --env-file=.env.local ./my_graph.act


```
Expand All @@ -91,10 +91,10 @@ actrun validate ./complex_workflow.act

### 🕸️ Debug Sessions

`actrun` can bridge your local terminal to the Actionforge web app for visual debugging. You can either connect to your browser session via a debug session token that your browser provided, or you can let the CLI intiate a debug session by using `--create_debug_session`. The latter will print a link to stdout that you can open in your browser and the debug session will immediately begin.
`actrun` can bridge your local terminal to the Actionforge web app for visual debugging. You can either connect to your browser session via a debug session token that your browser provided, or you can let the CLI intiate a debug session by using `--create-debug-session`. The latter will print a link to stdout that you can open in your browser and the debug session will immediately begin.

```bash
actrun --create_debug_session ./my_graph.act
actrun --create-debug-session ./my_graph.act


```
Expand Down
23 changes: 17 additions & 6 deletions cmd/cmd_root.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"flag"
"fmt"
"os"
"strings"

"github.com/actionforge/actrun-cli/build"
"github.com/actionforge/actrun-cli/core"
Expand All @@ -17,6 +18,7 @@ import (
"github.com/fatih/color"
"github.com/inconshreveable/mousetrap"
"github.com/spf13/cobra"
"github.com/spf13/pflag"

// initialize all nodes
_ "github.com/actionforge/actrun-cli/nodes"
Expand Down Expand Up @@ -140,9 +142,9 @@ var cmdRoot = &cobra.Command{
}

if finalCreateDebugSession && finalSessionToken != "" {
return errors.New("both --session_token and --create_debug_session cannot be used together")
return errors.New("both --session-token and --create-debug-session cannot be used together")
} else if finalCreateDebugSession && finalGraphFile == "" {
return errors.New("when using --create_debug_session, a graph file must be specified")
return errors.New("when using --create-debug-session, a graph file must be specified")
}

return nil
Expand Down Expand Up @@ -200,6 +202,11 @@ func Execute() {
}
}

// Allow both variations, both --env-file and --env_file will work
func normalizeFlag(f *pflag.FlagSet, name string) pflag.NormalizedName {
return pflag.NormalizedName(strings.ReplaceAll(name, "_", "-"))
}

func init() {
flag.Usage = func() {
fmt.Print("\n")
Expand All @@ -214,12 +221,16 @@ func init() {
fmt.Print("\n\n")
}

cmdRoot.PersistentFlags().StringVar(&flagEnvFile, "env_file", "", "Absolute path to an env file (.env) to load before execution")
// Enable backwards compatibility: allow both --env-file and --env_file
cmdRoot.PersistentFlags().SetNormalizeFunc(normalizeFlag)
cmdRoot.Flags().SetNormalizeFunc(normalizeFlag)

cmdRoot.PersistentFlags().StringVar(&flagEnvFile, "env-file", "", "Absolute path to an env file (.env) to load before execution")

cmdRoot.Flags().StringVar(&flagConfigFile, "config_file", "", "The config file to use")
cmdRoot.Flags().StringVar(&flagConfigFile, "config-file", "", "The config file to use")
cmdRoot.Flags().StringVar(&flagConcurrency, "concurrency", "", "Enable or disable concurrency")
cmdRoot.Flags().StringVar(&flagSessionToken, "session_token", "", "The session token from your browser")
cmdRoot.Flags().BoolVar(&flagCreateDebugSession, "create_debug_session", false, "Create a debug session by connecting to the web app")
cmdRoot.Flags().StringVar(&flagSessionToken, "session-token", "", "The session token from your browser")
cmdRoot.Flags().BoolVar(&flagCreateDebugSession, "create-debug-session", false, "Create a debug session by connecting to the web app")

// disable interspersed flag parsing to allow passing arbitrary flags to graphs.
// it stops cobra from parsing flags once it hits positional argument
Expand Down
4 changes: 2 additions & 2 deletions sessions/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ func RunSessionMode(configFile string, graphFileForDebugSession string, sessionT
done := make(chan os.Signal, 1)
signal.Notify(done, syscall.SIGINT, syscall.SIGTERM)

// if browser disconnects during a --create_debug_session run, we switch to detached mode
// if browser disconnects during a --create-debug-session run, we switch to detached mode
// to ensure the graph finishes execution instead of hanging on a breakpoint.
var detachMu sync.Mutex
var detachedMode bool
Expand Down Expand Up @@ -503,7 +503,7 @@ func RunSessionMode(configFile string, graphFileForDebugSession string, sessionT
currentDebugOps.cachedState = nil
currentDebugOps.Unlock()

// if this was a one-off debug session (initiated by --create_debug_session), exit the process when graph completes
// if this was a one-off debug session (initiated by --create-debug-session), exit the process when graph completes
if graphFileForDebugSession != "" {
done <- syscall.SIGTERM
}
Expand Down
8 changes: 4 additions & 4 deletions tests_e2e/references/reference_app.sh_l10
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ Available Commands:

Flags:
--concurrency string Enable or disable concurrency
--config_file string The config file to use
--create_debug_session Create a debug session by connecting to the web app
--env_file string Absolute path to an env file (.env) to load before execution
--config-file string The config file to use
--create-debug-session Create a debug session by connecting to the web app
--env-file string Absolute path to an env file (.env) to load before execution
-h, --help help for actrun
--session_token string The session token from your browser
--session-token string The session token from your browser
-v, --version version for actrun

Use "actrun [command] --help" for more information about a command.
Expand Down
4 changes: 2 additions & 2 deletions tests_e2e/references/reference_app.sh_l12
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ stack trace:
github.com/actionforge/actrun-cli/core.RunGraphFromFile
graph.go:1123
github.com/actionforge/actrun-cli/cmd.cmdRootRun
cmd_root.go:186
cmd_root.go:188
github.com/spf13/cobra.(*Command).execute
command.go:-1
github.com/spf13/cobra.(*Command).ExecuteC
command.go:-1
github.com/spf13/cobra.(*Command).Execute
command.go:-1
github.com/actionforge/actrun-cli/cmd.Execute
cmd_root.go:198
cmd_root.go:200
main.main
main.go:26
runtime.main
Expand Down
8 changes: 4 additions & 4 deletions tests_e2e/references/reference_contexts_env.sh_l26
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ Available Commands:

Flags:
--concurrency string Enable or disable concurrency
--config_file string The config file to use
--create_debug_session Create a debug session by connecting to the web app
--env_file string Absolute path to an env file (.env) to load before execution
--config-file string The config file to use
--create-debug-session Create a debug session by connecting to the web app
--env-file string Absolute path to an env file (.env) to load before execution
-h, --help help for actrun
--session_token string The session token from your browser
--session-token string The session token from your browser
-v, --version version for actrun

Use "actrun [command] --help" for more information about a command.
Expand Down
4 changes: 2 additions & 2 deletions tests_e2e/references/reference_dir-walk.sh_l56
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,15 @@ github.com/actionforge/actrun-cli/core.RunGraphFromString
github.com/actionforge/actrun-cli/core.RunGraphFromFile
graph.go:1126
github.com/actionforge/actrun-cli/cmd.cmdRootRun
cmd_root.go:186
cmd_root.go:188
github.com/spf13/cobra.(*Command).execute
command.go:-1
github.com/spf13/cobra.(*Command).ExecuteC
command.go:-1
github.com/spf13/cobra.(*Command).Execute
command.go:-1
github.com/actionforge/actrun-cli/cmd.Execute
cmd_root.go:198
cmd_root.go:200
main.main
main.go:26
runtime.main
Expand Down
4 changes: 2 additions & 2 deletions tests_e2e/references/reference_error_no_output.sh_l8
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,15 @@ github.com/actionforge/actrun-cli/core.RunGraphFromString
github.com/actionforge/actrun-cli/core.RunGraphFromFile
graph.go:1126
github.com/actionforge/actrun-cli/cmd.cmdRootRun
cmd_root.go:186
cmd_root.go:188
github.com/spf13/cobra.(*Command).execute
command.go:-1
github.com/spf13/cobra.(*Command).ExecuteC
command.go:-1
github.com/spf13/cobra.(*Command).Execute
command.go:-1
github.com/actionforge/actrun-cli/cmd.Execute
cmd_root.go:198
cmd_root.go:200
main.main
main.go:26
runtime.main
Expand Down
4 changes: 2 additions & 2 deletions tests_e2e/references/reference_group-port-collision.sh_l13
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@ github.com/actionforge/actrun-cli/core.RunGraphFromString
github.com/actionforge/actrun-cli/core.RunGraphFromFile
graph.go:1126
github.com/actionforge/actrun-cli/cmd.cmdRootRun
cmd_root.go:186
cmd_root.go:188
github.com/spf13/cobra.(*Command).execute
command.go:-1
github.com/spf13/cobra.(*Command).ExecuteC
command.go:-1
github.com/spf13/cobra.(*Command).Execute
command.go:-1
github.com/actionforge/actrun-cli/cmd.Execute
cmd_root.go:198
cmd_root.go:200
main.main
main.go:26
runtime.main
Expand Down
4 changes: 2 additions & 2 deletions tests_e2e/references/reference_index.sh_l20
Original file line number Diff line number Diff line change
Expand Up @@ -90,15 +90,15 @@ github.com/actionforge/actrun-cli/core.RunGraphFromString
github.com/actionforge/actrun-cli/core.RunGraphFromFile
graph.go:1126
github.com/actionforge/actrun-cli/cmd.cmdRootRun
cmd_root.go:186
cmd_root.go:188
github.com/spf13/cobra.(*Command).execute
command.go:-1
github.com/spf13/cobra.(*Command).ExecuteC
command.go:-1
github.com/spf13/cobra.(*Command).Execute
command.go:-1
github.com/actionforge/actrun-cli/cmd.Execute
cmd_root.go:198
cmd_root.go:200
main.main
main.go:26
runtime.main
Expand Down
4 changes: 2 additions & 2 deletions tests_e2e/references/reference_run-python-embedded.sh_l13
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,15 @@ github.com/actionforge/actrun-cli/core.RunGraphFromString
github.com/actionforge/actrun-cli/core.RunGraphFromFile
graph.go:1126
github.com/actionforge/actrun-cli/cmd.cmdRootRun
cmd_root.go:186
cmd_root.go:188
github.com/spf13/cobra.(*Command).execute
command.go:-1
github.com/spf13/cobra.(*Command).ExecuteC
command.go:-1
github.com/spf13/cobra.(*Command).Execute
command.go:-1
github.com/actionforge/actrun-cli/cmd.Execute
cmd_root.go:198
cmd_root.go:200
main.main
main.go:26
runtime.main
Expand Down
4 changes: 2 additions & 2 deletions tests_e2e/references/reference_s3_aws_walk.sh_l22
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,15 @@ github.com/actionforge/actrun-cli/core.RunGraphFromString
github.com/actionforge/actrun-cli/core.RunGraphFromFile
graph.go:1126
github.com/actionforge/actrun-cli/cmd.cmdRootRun
cmd_root.go:186
cmd_root.go:188
github.com/spf13/cobra.(*Command).execute
command.go:-1
github.com/spf13/cobra.(*Command).ExecuteC
command.go:-1
github.com/spf13/cobra.(*Command).Execute
command.go:-1
github.com/actionforge/actrun-cli/cmd.Execute
cmd_root.go:198
cmd_root.go:200
main.main
main.go:26
runtime.main
Expand Down
4 changes: 2 additions & 2 deletions tests_e2e/references/reference_s3_aws_walk.sh_l44
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,15 @@ github.com/actionforge/actrun-cli/core.RunGraphFromString
github.com/actionforge/actrun-cli/core.RunGraphFromFile
graph.go:1126
github.com/actionforge/actrun-cli/cmd.cmdRootRun
cmd_root.go:186
cmd_root.go:188
github.com/spf13/cobra.(*Command).execute
command.go:-1
github.com/spf13/cobra.(*Command).ExecuteC
command.go:-1
github.com/spf13/cobra.(*Command).Execute
command.go:-1
github.com/actionforge/actrun-cli/cmd.Execute
cmd_root.go:198
cmd_root.go:200
main.main
main.go:26
runtime.main
Expand Down
4 changes: 2 additions & 2 deletions tests_e2e/references/reference_select-data.sh_l9
Original file line number Diff line number Diff line change
Expand Up @@ -97,15 +97,15 @@ github.com/actionforge/actrun-cli/core.RunGraphFromString
github.com/actionforge/actrun-cli/core.RunGraphFromFile
graph.go:1126
github.com/actionforge/actrun-cli/cmd.cmdRootRun
cmd_root.go:186
cmd_root.go:188
github.com/spf13/cobra.(*Command).execute
command.go:-1
github.com/spf13/cobra.(*Command).ExecuteC
command.go:-1
github.com/spf13/cobra.(*Command).Execute
command.go:-1
github.com/actionforge/actrun-cli/cmd.Execute
cmd_root.go:198
cmd_root.go:200
main.main
main.go:26
runtime.main
Expand Down
4 changes: 2 additions & 2 deletions tests_e2e/references/reference_string-transform.sh_l61
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,15 @@ github.com/actionforge/actrun-cli/core.RunGraphFromString
github.com/actionforge/actrun-cli/core.RunGraphFromFile
graph.go:1126
github.com/actionforge/actrun-cli/cmd.cmdRootRun
cmd_root.go:186
cmd_root.go:188
github.com/spf13/cobra.(*Command).execute
command.go:-1
github.com/spf13/cobra.(*Command).ExecuteC
command.go:-1
github.com/spf13/cobra.(*Command).Execute
command.go:-1
github.com/actionforge/actrun-cli/cmd.Execute
cmd_root.go:198
cmd_root.go:200
main.main
main.go:26
runtime.main
Expand Down
Loading