-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: build command Signed-off-by: Thulio Ferraz Assis <3149049+f0rmiga@users.noreply.github.com> * fix: docs Signed-off-by: Thulio Ferraz Assis <3149049+f0rmiga@users.noreply.github.com> * fix: missing punctuation Signed-off-by: Thulio Ferraz Assis <3149049+f0rmiga@users.noreply.github.com> * refactor: move mock to its own package This allows `go mod tidy` to run successfully while keeping Gazelle happy. Signed-off-by: Thulio Ferraz Assis <3149049+f0rmiga@users.noreply.github.com> * fix: use proper arguments on tests Signed-off-by: Thulio Ferraz Assis <3149049+f0rmiga@users.noreply.github.com> * feat: propagate bazel exit code to aspect exit Signed-off-by: Thulio Ferraz Assis <3149049+f0rmiga@users.noreply.github.com> * fix: tests with ExitError Signed-off-by: Thulio Ferraz Assis <3149049+f0rmiga@users.noreply.github.com> * fix: command description Signed-off-by: Thulio Ferraz Assis <3149049+f0rmiga@users.noreply.github.com>
- Loading branch information
Showing
21 changed files
with
342 additions
and
18 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
load("@io_bazel_rules_go//go:def.bzl", "go_library") | ||
|
||
go_library( | ||
name = "build", | ||
srcs = ["build.go"], | ||
importpath = "aspect.build/cli/cmd/aspect/build", | ||
visibility = ["//cmd/aspect/root:__pkg__"], | ||
deps = [ | ||
"//pkg/aspect/build", | ||
"//pkg/bazel", | ||
"//pkg/ioutils", | ||
"@com_github_spf13_cobra//:cobra", | ||
], | ||
) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
Copyright © 2021 Aspect Build Systems Inc | ||
Not licensed for re-use. | ||
*/ | ||
|
||
package build | ||
|
||
import ( | ||
"github.com/spf13/cobra" | ||
|
||
"aspect.build/cli/pkg/aspect/build" | ||
"aspect.build/cli/pkg/bazel" | ||
"aspect.build/cli/pkg/ioutils" | ||
) | ||
|
||
// NewDefaultBuildCmd creates a new build cobra command with the default | ||
// dependencies. | ||
func NewDefaultBuildCmd() *cobra.Command { | ||
return NewBuildCmd(ioutils.DefaultStreams, bazel.New()) | ||
} | ||
|
||
// NewBuildCmd creates a new build cobra command. | ||
func NewBuildCmd( | ||
streams ioutils.Streams, | ||
bzl bazel.Spawner, | ||
) *cobra.Command { | ||
b := build.New(streams, bzl) | ||
|
||
cmd := &cobra.Command{ | ||
Use: "build", | ||
Short: "Builds the specified targets, using the options.", | ||
Long: "Invokes bazel build on the specified targets. " + | ||
"See 'bazel help target-syntax' for details and examples on how to specify targets to build.", | ||
RunE: b.Run, | ||
} | ||
|
||
return cmd | ||
} |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
## aspect build | ||
|
||
Builds the specified targets, using the options. | ||
|
||
### Synopsis | ||
|
||
Invokes bazel build on the specified targets. See 'bazel help target-syntax' for details and examples on how to specify targets to build. | ||
|
||
``` | ||
aspect build [flags] | ||
``` | ||
|
||
### Options | ||
|
||
``` | ||
-h, --help help for build | ||
``` | ||
|
||
### Options inherited from parent commands | ||
|
||
``` | ||
--config string config file (default is $HOME/.aspect.yaml) | ||
--interactive Interactive mode (e.g. prompts for user input) | ||
``` | ||
|
||
### SEE ALSO | ||
|
||
* [aspect](aspect.md) - Aspect.build bazel wrapper | ||
|
||
###### Auto generated by spf13/cobra |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") | ||
|
||
go_library( | ||
name = "build", | ||
srcs = ["build.go"], | ||
importpath = "aspect.build/cli/pkg/aspect/build", | ||
visibility = ["//cmd/aspect/build:__pkg__"], | ||
deps = [ | ||
"//pkg/aspecterrors", | ||
"//pkg/bazel", | ||
"//pkg/ioutils", | ||
"@com_github_spf13_cobra//:cobra", | ||
], | ||
) | ||
|
||
go_test( | ||
name = "build_test", | ||
srcs = ["build_test.go"], | ||
deps = [ | ||
":build", | ||
"//pkg/aspecterrors", | ||
"//pkg/bazel/mock", | ||
"//pkg/ioutils", | ||
"@com_github_golang_mock//gomock", | ||
"@com_github_onsi_gomega//:gomega", | ||
], | ||
) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
Copyright © 2021 Aspect Build Systems Inc | ||
Not licensed for re-use. | ||
*/ | ||
|
||
package build | ||
|
||
import ( | ||
"github.com/spf13/cobra" | ||
|
||
"aspect.build/cli/pkg/aspecterrors" | ||
"aspect.build/cli/pkg/bazel" | ||
"aspect.build/cli/pkg/ioutils" | ||
) | ||
|
||
// Build represents the aspect build command. | ||
type Build struct { | ||
ioutils.Streams | ||
bzl bazel.Spawner | ||
} | ||
|
||
// New creates a Build command. | ||
func New( | ||
streams ioutils.Streams, | ||
bzl bazel.Spawner, | ||
) *Build { | ||
return &Build{ | ||
Streams: streams, | ||
bzl: bzl, | ||
} | ||
} | ||
|
||
// Run runs the aspect build command. | ||
func (b *Build) Run(_ *cobra.Command, args []string) error { | ||
cmd := append([]string{"build"}, args...) | ||
if exitCode, err := b.bzl.Spawn(cmd); exitCode != 0 { | ||
err = &aspecterrors.ExitError{ | ||
Err: err, | ||
ExitCode: exitCode, | ||
} | ||
return err | ||
} | ||
|
||
return nil | ||
} |
Oops, something went wrong.