go-coverage
Package go code coverage module
Installation
dagger install github.com/act3-ai/dagger/gocoverage@v0.2.1Entrypoint
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@2112f0b57142f670a2de7608869d9c5cbede5eae 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
unitTests() 🔗
Code coverage from unit tests
Return Type
GoCoverageCoverageResults ! Example
dagger -m github.com/act3-ai/dagger/gocoverage@2112f0b57142f670a2de7608869d9c5cbede5eae 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()
}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@2112f0b57142f670a2de7608869d9c5cbede5eae 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)
}GoCoverageCoverageResults 🔗
Code coverage results
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(pkg string, args []string, other *dagger.GoCoverageCoverageResults) *dagger.GoCoverageCoverageResults {
return dag.
GoCoverage().
Exec(pkg, args).
Merge(other)
}@function
def example(pkg: str, args: List[str], other: dagger.GoCoverageCoverageResults) -> dagger.GoCoverageCoverageResults:
return (
dag.go_coverage()
.exec(pkg, args)
.merge(other)
)@func()
example(pkg: string, args: string[], other: GoCoverageCoverageResults): GoCoverageCoverageResults {
return dag
.goCoverage()
.exec(pkg, args)
.merge(other)
}textFormat() 🔗
Text format (older style) coverage format
Return Type
File ! Example
dagger -m github.com/act3-ai/dagger/gocoverage@2112f0b57142f670a2de7608869d9c5cbede5eae call \
exec --pkg string --args string1 --args string2 \
text-formatfunc (m *MyModule) Example(pkg string, args []string) *dagger.File {
return dag.
GoCoverage().
Exec(pkg, args).
TextFormat()
}@function
def example(pkg: str, args: List[str]) -> dagger.File:
return (
dag.go_coverage()
.exec(pkg, args)
.text_format()
)@func()
example(pkg: string, args: string[]): File {
return dag
.goCoverage()
.exec(pkg, args)
.textFormat()
}svg() 🔗
SVG heat map of code coverage
Return Type
File ! Example
dagger -m github.com/act3-ai/dagger/gocoverage@2112f0b57142f670a2de7608869d9c5cbede5eae call \
exec --pkg string --args string1 --args string2 \
svgfunc (m *MyModule) Example(pkg string, args []string) *dagger.File {
return dag.
GoCoverage().
Exec(pkg, args).
Svg()
}@function
def example(pkg: str, args: List[str]) -> dagger.File:
return (
dag.go_coverage()
.exec(pkg, args)
.svg()
)@func()
example(pkg: string, args: string[]): File {
return dag
.goCoverage()
.exec(pkg, args)
.svg()
}html() 🔗
HTML report
Return Type
File ! Example
dagger -m github.com/act3-ai/dagger/gocoverage@2112f0b57142f670a2de7608869d9c5cbede5eae call \
exec --pkg string --args string1 --args string2 \
htmlfunc (m *MyModule) Example(pkg string, args []string) *dagger.File {
return dag.
GoCoverage().
Exec(pkg, args).
Html()
}@function
def example(pkg: str, args: List[str]) -> dagger.File:
return (
dag.go_coverage()
.exec(pkg, args)
.html()
)@func()
example(pkg: string, args: string[]): File {
return dag
.goCoverage()
.exec(pkg, args)
.html()
}summary() 🔗
Summary of coverage by functions
Return Type
File ! Example
dagger -m github.com/act3-ai/dagger/gocoverage@2112f0b57142f670a2de7608869d9c5cbede5eae call \
exec --pkg string --args string1 --args string2 \
summaryfunc (m *MyModule) Example(pkg string, args []string) *dagger.File {
return dag.
GoCoverage().
Exec(pkg, args).
Summary()
}@function
def example(pkg: str, args: List[str]) -> dagger.File:
return (
dag.go_coverage()
.exec(pkg, args)
.summary()
)@func()
example(pkg: string, args: string[]): File {
return dag
.goCoverage()
.exec(pkg, args)
.summary()
}percent() 🔗
Percent code coverage (total of all statements)
Return Type
Float ! Example
dagger -m github.com/act3-ai/dagger/gocoverage@2112f0b57142f670a2de7608869d9c5cbede5eae call \
exec --pkg string --args string1 --args string2 \
percentfunc (m *MyModule) Example(pkg string, args []string) {
return dag.
GoCoverage().
Exec(pkg, args).
Percent()
}@function
def example(pkg: str, args: List[str]) -> :
return (
dag.go_coverage()
.exec(pkg, args)
.percent()
)@func()
example(pkg: string, args: string[]): {
return dag
.goCoverage()
.exec(pkg, args)
.percent()
}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@2112f0b57142f670a2de7608869d9c5cbede5eae call \
exec --pkg string --args string1 --args string2 \
checkfunc (m *MyModule) Example(ctx context.Context, pkg string, args []string, threshold ) {
return dag.
GoCoverage().
Exec(pkg, args).
Check(ctx, threshold)
}@function
async def example(pkg: str, args: List[str], threshold: ) -> None:
return await (
dag.go_coverage()
.exec(pkg, args)
.check(threshold)
)@func()
async example(pkg: string, args: string[], threshold: ): Promise<void> {
return dag
.goCoverage()
.exec(pkg, args)
.check(threshold)
}directory() 🔗
Get a directory of all the results
Return Type
Directory ! Example
dagger -m github.com/act3-ai/dagger/gocoverage@2112f0b57142f670a2de7608869d9c5cbede5eae call \
exec --pkg string --args string1 --args string2 \
directoryfunc (m *MyModule) Example(pkg string, args []string) *dagger.Directory {
return dag.
GoCoverage().
Exec(pkg, args).
Directory()
}@function
def example(pkg: str, args: List[str]) -> dagger.Directory:
return (
dag.go_coverage()
.exec(pkg, args)
.directory()
)@func()
example(pkg: string, args: string[]): Directory {
return dag
.goCoverage()
.exec(pkg, args)
.directory()
}