Documentation ¶
Overview ¶
Package commons contains common tasks that most go projects need as part of their development/deployment processes.
Index ¶
- func Commitsar(opts ...CommitsarOpt) harness.Task
- func GoBuild(pkg, out string, opts ...GoBuildOpt) harness.Task
- func GoFmt() harness.Task
- func GoGenerate() harness.Task
- func GoImports(localpkg string) harness.Task
- func GoIntegrationTest(opts ...TestOpt) harness.Task
- func GoModTidy() harness.Task
- func GoTest(opts ...TestOpt) harness.Task
- func GolangCILint(opts ...GolangCILintOpt) harness.Task
- func IsCIEnv() bool
- func OnlyLocally(task harness.Task) harness.Task
- func OnlyOnCI(task harness.Task) harness.Task
- type CommitsarOpt
- type GoBuildOpt
- type GolangCILintOpt
- type TestOpt
- func WithIntegrationTest() TestOpt
- func WithTarget(target *string) TestOpt
- func WithTestCIFriendlyOutput(enabled bool) TestOpt
- func WithTestCobertura(enabled bool) TestOpt
- func WithTestCoberturaOutput(filename string) TestOpt
- func WithTestCoverageExclusions() TestOpt
- func WithTestFileDump(enabled bool) TestOpt
- func WithTestFileDumpOutput(filename string) TestOpt
- func WithTestJunit(enabled bool) TestOpt
- func WithTestJunitOutput(filename string) TestOpt
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Commitsar ¶
func Commitsar(opts ...CommitsarOpt) harness.Task
Commitsar lints commit messages and verifies conventional commits compliance.
func GoBuild ¶
func GoBuild(pkg, out string, opts ...GoBuildOpt) harness.Task
GoBuild builds a go binary, from the package specified as argument, outputting it on the relative path supplied as argument. The go build command can be customized with build tags and ldflags via GoBuildOpt arguments.
func GoImports ¶
GoImports formats code sorting imports taking in account the local package supplied as argument.
func GoIntegrationTest ¶
GoIntegrationTest runs only integration tests. It's a shortcut for GoTest(WithIntegrationTest()).
func GolangCILint ¶
func GolangCILint(opts ...GolangCILintOpt) harness.Task
GolangCILint aggregates multiple linters that analyze go code. https://golangci-lint.run
func IsCIEnv ¶
func IsCIEnv() bool
IsCIEnv returns true if the current environment is a known ci system.
func OnlyLocally ¶
OnlyLocally returns the task specified as argument only in the case the current environment is a dev machine. Otherwise it returns a noop task.
Types ¶
type CommitsarOpt ¶
type CommitsarOpt func(c *commitsarconf)
func WithCommitsarVersion ¶
func WithCommitsarVersion(version string) CommitsarOpt
WithCommitsarVersion allows specifying the commitsar version that should be used when running this task.
type GoBuildOpt ¶
type GoBuildOpt func(c *buildconf)
func WithGoBuildLDFlags ¶
func WithGoBuildLDFlags(flags ...string) GoBuildOpt
WithGoBuildLDFlags allows specifying ldflags for the go build command.
func WithGoBuildTags ¶
func WithGoBuildTags(tags ...string) GoBuildOpt
WithGoBuildTags allows specifying build tags for the go build command.
type GolangCILintOpt ¶
type GolangCILintOpt func(c *golangcilintconf)
func WithGolangCICodeClimate ¶
func WithGolangCICodeClimate(enabled bool) GolangCILintOpt
WithGolangCICodeClimate controls if golangci-lint should generate a codeclimate report file instead of outputting everything to stdout or not. https://codeclimate.com
func WithGolangCICodeClimateOutput ¶
func WithGolangCICodeClimateOutput(filename string) GolangCILintOpt
WithGolangCICodeClimateOutput specifies the filename for the codeclimate output.
func WithGolangCIVersion ¶
func WithGolangCIVersion(version string) GolangCILintOpt
WithGolangCIVersion allows specifying the golangci-lint version that should be used when running this task.
type TestOpt ¶
type TestOpt func(c *testconf)
func WithIntegrationTest ¶
func WithIntegrationTest() TestOpt
func WithTarget ¶
WithTarget limits the tests to only a folder relative to the root path. Passing nil as target means running all tests, equivalent to ./...
func WithTestCIFriendlyOutput ¶
WithTestCIFriendlyOutput formats the test output using gotestfmt, which has special handling of ci environments, grouping the output using the native uis available.
func WithTestCobertura ¶
WithTestCobertura controls if the test task should generate a cobertura coverage file or not.
func WithTestCoberturaOutput ¶
WithTestCoberturaOutput specifies the filename for the cobertura output.
func WithTestCoverageExclusions ¶
func WithTestCoverageExclusions() TestOpt
func WithTestFileDump ¶
WithTestFileDump controls if the test task should dump its output to a file.
func WithTestFileDumpOutput ¶
WithTestFileDumpOutput specifies the filename for test output dump.
func WithTestJunit ¶
WithTestJunit controls if the test task should generate a junit report file or not.
func WithTestJunitOutput ¶
WithTestJunitOutput specifies the filename for the junit output.