go-coverage
Package go code coverage module
Installation
dagger install github.com/act3-ai/dagger/gocoverage@v0.2.2Entrypoint
Return Type
GoCoverage !Arguments
| Name | Type | Default Value | Description |
|---|---|---|---|
| base | Container ! | - | base container for go. Expectations: - working directory is set to the go.mod file - go tool works for go-cover-treemap (optional) |
| excludes | [String ! ] | - | Exclude files from coverage |
Example
dagger -m github.com/act3-ai/dagger/gocoverage@a2ef82ee644a892da3b9bf40137e6003d9dc42a7 call \
--base IMAGE:TAGfunc (m *MyModule) Example(base *dagger.Container) *dagger.GoCoverage {
return dag.
GoCoverage(base)
}@function
def example(base: dagger.Container, ) -> dagger.GoCoverage:
return (
dag.go_coverage(base)
)@func()
example(base: Container, ): GoCoverage {
return dag
.goCoverage(base)
}Types
GoCoverage 🔗
Code coverage generator
exec() 🔗
Run a go package with coverage
Return Type
GoCoverageCoverageResults !Arguments
| Name | Type | Default Value | Description |
|---|---|---|---|
| pkg | String ! | - | No description provided |
| args | [String ! ] ! | - | No description provided |
Example
dagger -m github.com/act3-ai/dagger/gocoverage@a2ef82ee644a892da3b9bf40137e6003d9dc42a7 call \
--base IMAGE:TAG exec --pkg string --args string1 --args string2func (m *MyModule) Example(base *dagger.Container, pkg string, args []string) *dagger.GoCoverageCoverageResults {
return dag.
GoCoverage(base).
Exec(pkg, args)
}@function
def example(base: dagger.Container, pkg: str, args: List[str]) -> dagger.GoCoverageCoverageResults:
return (
dag.go_coverage(base)
.exec(pkg, args)
)@func()
example(base: Container, pkg: string, args: string[]): GoCoverageCoverageResults {
return dag
.goCoverage(base)
.exec(pkg, args)
}unitTests() 🔗
Code coverage from unit tests
Return Type
GoCoverageCoverageResults ! Example
dagger -m github.com/act3-ai/dagger/gocoverage@a2ef82ee644a892da3b9bf40137e6003d9dc42a7 call \
--base IMAGE:TAG unit-testsfunc (m *MyModule) Example(base *dagger.Container) *dagger.GoCoverageCoverageResults {
return dag.
GoCoverage(base).
UnitTests()
}@function
def example(base: dagger.Container, ) -> dagger.GoCoverageCoverageResults:
return (
dag.go_coverage(base)
.unit_tests()
)@func()
example(base: Container, ): GoCoverageCoverageResults {
return dag
.goCoverage(base)
.unitTests()
}GoCoverageCoverageResults 🔗
Code coverage results
check() 🔗
Check that the coverage percentage is above a threshold
Return Type
Void !Arguments
| Name | Type | Default Value | Description |
|---|---|---|---|
| threshold | Float ! | - | minimum percentage to accept |
Example
dagger -m github.com/act3-ai/dagger/gocoverage@a2ef82ee644a892da3b9bf40137e6003d9dc42a7 call \
unit-tests \
checkfunc (m *MyModule) Example(ctx context.Context, threshold ) {
return dag.
GoCoverage().
UnitTests().
Check(ctx, threshold)
}@function
async def example(threshold: ) -> None:
return await (
dag.go_coverage()
.unit_tests()
.check(threshold)
)@func()
async example(threshold: ): Promise<void> {
return dag
.goCoverage()
.unitTests()
.check(threshold)
}directory() 🔗
Get a directory of all the results
Return Type
Directory ! Example
dagger -m github.com/act3-ai/dagger/gocoverage@a2ef82ee644a892da3b9bf40137e6003d9dc42a7 call \
unit-tests \
directoryfunc (m *MyModule) Example() *dagger.Directory {
return dag.
GoCoverage().
UnitTests().
Directory()
}@function
def example() -> dagger.Directory:
return (
dag.go_coverage()
.unit_tests()
.directory()
)@func()
example(): Directory {
return dag
.goCoverage()
.unitTests()
.directory()
}html() 🔗
HTML report
Return Type
File ! Example
dagger -m github.com/act3-ai/dagger/gocoverage@a2ef82ee644a892da3b9bf40137e6003d9dc42a7 call \
unit-tests \
htmlfunc (m *MyModule) Example() *dagger.File {
return dag.
GoCoverage().
UnitTests().
Html()
}@function
def example() -> dagger.File:
return (
dag.go_coverage()
.unit_tests()
.html()
)@func()
example(): File {
return dag
.goCoverage()
.unitTests()
.html()
}merge() 🔗
Merge all results
Return Type
GoCoverageCoverageResults !Arguments
| Name | Type | Default Value | Description |
|---|---|---|---|
| other | GoCoverageCoverageResults ! | - | other coverage results to merge into the returned results |
| pkgs | [String ! ] | - | module paths to include |
Example
echo 'Custom types are not supported in shell examples'func (m *MyModule) Example(other *dagger.GoCoverageCoverageResults) *dagger.GoCoverageCoverageResults {
return dag.
GoCoverage().
UnitTests().
Merge(other)
}@function
def example(other: dagger.GoCoverageCoverageResults) -> dagger.GoCoverageCoverageResults:
return (
dag.go_coverage()
.unit_tests()
.merge(other)
)@func()
example(other: GoCoverageCoverageResults): GoCoverageCoverageResults {
return dag
.goCoverage()
.unitTests()
.merge(other)
}percent() 🔗
Percent code coverage (total of all statements)
Return Type
Float ! Example
dagger -m github.com/act3-ai/dagger/gocoverage@a2ef82ee644a892da3b9bf40137e6003d9dc42a7 call \
unit-tests \
percentfunc (m *MyModule) Example() {
return dag.
GoCoverage().
UnitTests().
Percent()
}@function
def example() -> :
return (
dag.go_coverage()
.unit_tests()
.percent()
)@func()
example(): {
return dag
.goCoverage()
.unitTests()
.percent()
}svg() 🔗
SVG heat map of code coverage
Return Type
File ! Example
dagger -m github.com/act3-ai/dagger/gocoverage@a2ef82ee644a892da3b9bf40137e6003d9dc42a7 call \
unit-tests \
svgfunc (m *MyModule) Example() *dagger.File {
return dag.
GoCoverage().
UnitTests().
Svg()
}@function
def example() -> dagger.File:
return (
dag.go_coverage()
.unit_tests()
.svg()
)@func()
example(): File {
return dag
.goCoverage()
.unitTests()
.svg()
}summary() 🔗
Summary of coverage by functions
Return Type
File ! Example
dagger -m github.com/act3-ai/dagger/gocoverage@a2ef82ee644a892da3b9bf40137e6003d9dc42a7 call \
unit-tests \
summaryfunc (m *MyModule) Example() *dagger.File {
return dag.
GoCoverage().
UnitTests().
Summary()
}@function
def example() -> dagger.File:
return (
dag.go_coverage()
.unit_tests()
.summary()
)@func()
example(): File {
return dag
.goCoverage()
.unitTests()
.summary()
}textFormat() 🔗
Text format (older style) coverage format
Return Type
File ! Example
dagger -m github.com/act3-ai/dagger/gocoverage@a2ef82ee644a892da3b9bf40137e6003d9dc42a7 call \
unit-tests \
text-formatfunc (m *MyModule) Example() *dagger.File {
return dag.
GoCoverage().
UnitTests().
TextFormat()
}@function
def example() -> dagger.File:
return (
dag.go_coverage()
.unit_tests()
.text_format()
)@func()
example(): File {
return dag
.goCoverage()
.unitTests()
.textFormat()
}