Skip to content

Commit

Permalink
feat(forge/cli): adds ci flag
Browse files Browse the repository at this point in the history
  • Loading branch information
jmgilman committed Sep 6, 2024
1 parent 5129684 commit 89cb853
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 1 deletion.
1 change: 1 addition & 0 deletions forge/cli/cmd/cmds/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (

type RunCmd struct {
Artifact string `short:"a" help:"Dump all produced artifacts to the given path."`
CI bool `help:"Run the target in CI mode."`
Local bool `short:"l" help:"Forces the target to run locally (ignores satellite)."`
Path string `arg:"" help:"The path to the target to execute (i.e., ./dir1+test)."`
Platform string `short:"p" help:"Run the target with the given platform."`
Expand Down
5 changes: 5 additions & 0 deletions forge/cli/cmd/cmds/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ func generateOpts(target string, flags *RunCmd, config *schema.Blueprint) []eart
if flags.Artifact != "" {
opts = append(opts, earthly.WithArtifact(flags.Artifact))
}

if flags.CI {
opts = append(opts, earthly.WithCI())
}

if flags.Platform != "" {
opts = append(opts, earthly.WithPlatform(flags.Platform))
}
Expand Down
3 changes: 2 additions & 1 deletion forge/cli/cmd/testdata/run/3.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
exec forge run --platform test ./dir1+test
exec forge run --ci --platform test ./dir1+test
cmp stdout golden.txt

-- golden.txt --
earthly
--ci
--platform
test
./dir1+test
Expand Down
1 change: 1 addition & 0 deletions forge/cli/pkg/earthly/earthly.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ type EarthlySecret struct {
// EarthlyExecutor.
type earthlyExecutorOptions struct {
artifact string
ci bool
retries int
}

Expand Down
8 changes: 8 additions & 0 deletions forge/cli/pkg/earthly/earthly_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,14 @@ func TestEarthlyExecutor_buildArguments(t *testing.T) {
),
expect: []string{"--artifact", "/test/dir+foo/*", "test/"},
},
{
name: "with ci",
e: NewEarthlyExecutor("/test/dir", "foo", nil, secrets.SecretStore{},
testutils.NewNoopLogger(),
WithCI(),
),
expect: []string{"--ci", "/test/dir+foo"},
},
{
name: "with platform",
e: NewEarthlyExecutor("/test/dir", "foo", nil, secrets.SecretStore{},
Expand Down
7 changes: 7 additions & 0 deletions forge/cli/pkg/earthly/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@ func WithArtifact(path string) EarthlyExecutorOption {
}
}

func WithCI() EarthlyExecutorOption {
return func(e *EarthlyExecutor) {
e.opts.ci = true
e.earthlyArgs = append(e.earthlyArgs, "--ci")
}
}

// WithPlatform is an option for configuring an EarthlyExecutor to run the
// Earthly target with the given platform.
func WithPlatform(platform string) EarthlyExecutorOption {
Expand Down

0 comments on commit 89cb853

Please sign in to comment.