commons

package
v0.0.0-...-31701ed Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 26, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package commons contains common tasks that most go projects need as part of their development/deployment processes.

Index

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.

https://commitsar.aevea.ee https://conventionalcommits.org

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 GoFmt

func GoFmt() harness.Task

GoFmt runs gofmt and formats code in place.

func GoGenerate

func GoGenerate() harness.Task

GoGenerate runs go generate recursively.

func GoImports

func GoImports(localpkg string) harness.Task

GoImports formats code sorting imports taking in account the local package supplied as argument.

func GoIntegrationTest

func GoIntegrationTest(opts ...TestOpt) harness.Task

GoIntegrationTest runs only integration tests. It's a shortcut for GoTest(WithIntegrationTest()).

func GoModTidy

func GoModTidy() harness.Task

GoModTidy runs go mod tidy and errors if the go.mod or go.sum files have changed.

func GoTest

func GoTest(opts ...TestOpt) harness.Task

GoTest runs go test recursively.

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

func OnlyLocally(task harness.Task) harness.Task

OnlyLocally returns the task specified as argument only in the case the current environment is a dev machine. Otherwise it returns a noop task.

func OnlyOnCI

func OnlyOnCI(task harness.Task) harness.Task

OnlyOnCI returns the task specified as argument only in the case the current environment is a known ci system. 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

func WithTarget(target *string) TestOpt

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

func WithTestCIFriendlyOutput(enabled bool) TestOpt

WithTestCIFriendlyOutput formats the test output using gotestfmt, which has special handling of ci environments, grouping the output using the native uis available.

https://github.com/GoTestTools/gotestfmt

func WithTestCobertura

func WithTestCobertura(enabled bool) TestOpt

WithTestCobertura controls if the test task should generate a cobertura coverage file or not.

func WithTestCoberturaOutput

func WithTestCoberturaOutput(filename string) TestOpt

WithTestCoberturaOutput specifies the filename for the cobertura output.

func WithTestCoverageExclusions

func WithTestCoverageExclusions() TestOpt

func WithTestFileDump

func WithTestFileDump(enabled bool) TestOpt

WithTestFileDump controls if the test task should dump its output to a file.

func WithTestFileDumpOutput

func WithTestFileDumpOutput(filename string) TestOpt

WithTestFileDumpOutput specifies the filename for test output dump.

func WithTestJunit

func WithTestJunit(enabled bool) TestOpt

WithTestJunit controls if the test task should generate a junit report file or not.

func WithTestJunitOutput

func WithTestJunitOutput(filename string) TestOpt

WithTestJunitOutput specifies the filename for the junit output.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL