coverage
Package go code coverage module
Installation
dagger install github.com/act3-ai/dagger/gocoverage@v0.1.3Entrypoint
Return Type
Coverage !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@c653f2a7229c06acda4d01427f879e123357cdbb call \
--base IMAGE:TAGfunc (m *MyModule) Example(base *dagger.Container) *dagger.Coverage {
return dag.
Coverage(base)
}@function
def example(base: dagger.Container, ) -> dagger.Coverage:
return (
dag.coverage(base)
)@func()
example(base: Container, ): Coverage {
return dag
.coverage(base)
}Types
Coverage 🔗
Code coverage generator
unitTests() 🔗
Code coverage from unit tests
Return Type
Results ! Example
dagger -m github.com/act3-ai/dagger/gocoverage@c653f2a7229c06acda4d01427f879e123357cdbb call \
--base IMAGE:TAG unit-testsfunc (m *MyModule) Example(base *dagger.Container) *dagger.CoverageResults {
return dag.
Coverage(base).
UnitTests()
}@function
def example(base: dagger.Container, ) -> dagger.CoverageResults:
return (
dag.coverage(base)
.unit_tests()
)@func()
example(base: Container, ): CoverageResults {
return dag
.coverage(base)
.unitTests()
}exec() 🔗
Run a go package with coverage
Return Type
Results !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@c653f2a7229c06acda4d01427f879e123357cdbb call \
--base IMAGE:TAG exec --pkg string --args string1 --args string2func (m *MyModule) Example(base *dagger.Container, pkg string, args []string) *dagger.CoverageResults {
return dag.
Coverage(base).
Exec(pkg, args)
}@function
def example(base: dagger.Container, pkg: str, args: List[str]) -> dagger.CoverageResults:
return (
dag.coverage(base)
.exec(pkg, args)
)@func()
example(base: Container, pkg: string, args: string[]): CoverageResults {
return dag
.coverage(base)
.exec(pkg, args)
}Results 🔗
Code coverage results
merge() 🔗
Merge all results
Return Type
Results !Arguments
| Name | Type | Default Value | Description |
|---|---|---|---|
| other | Results ! | - | 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.CoverageResults) *dagger.CoverageResults {
return dag.
Coverage().
Exec(pkg, args).
Merge(other)
}@function
def example(pkg: str, args: List[str], other: dagger.CoverageResults) -> dagger.CoverageResults:
return (
dag.coverage()
.exec(pkg, args)
.merge(other)
)@func()
example(pkg: string, args: string[], other: CoverageResults): CoverageResults {
return dag
.coverage()
.exec(pkg, args)
.merge(other)
}textFormat() 🔗
Text format (older style) coverage format
Return Type
File ! Example
dagger -m github.com/act3-ai/dagger/gocoverage@c653f2a7229c06acda4d01427f879e123357cdbb call \
exec --pkg string --args string1 --args string2 \
text-formatfunc (m *MyModule) Example(pkg string, args []string) *dagger.File {
return dag.
Coverage().
Exec(pkg, args).
TextFormat()
}@function
def example(pkg: str, args: List[str]) -> dagger.File:
return (
dag.coverage()
.exec(pkg, args)
.text_format()
)@func()
example(pkg: string, args: string[]): File {
return dag
.coverage()
.exec(pkg, args)
.textFormat()
}svg() 🔗
SVG heat map of code coverage
Return Type
File ! Example
dagger -m github.com/act3-ai/dagger/gocoverage@c653f2a7229c06acda4d01427f879e123357cdbb call \
exec --pkg string --args string1 --args string2 \
svgfunc (m *MyModule) Example(pkg string, args []string) *dagger.File {
return dag.
Coverage().
Exec(pkg, args).
Svg()
}@function
def example(pkg: str, args: List[str]) -> dagger.File:
return (
dag.coverage()
.exec(pkg, args)
.svg()
)@func()
example(pkg: string, args: string[]): File {
return dag
.coverage()
.exec(pkg, args)
.svg()
}html() 🔗
HTML report
Return Type
File ! Example
dagger -m github.com/act3-ai/dagger/gocoverage@c653f2a7229c06acda4d01427f879e123357cdbb call \
exec --pkg string --args string1 --args string2 \
htmlfunc (m *MyModule) Example(pkg string, args []string) *dagger.File {
return dag.
Coverage().
Exec(pkg, args).
Html()
}@function
def example(pkg: str, args: List[str]) -> dagger.File:
return (
dag.coverage()
.exec(pkg, args)
.html()
)@func()
example(pkg: string, args: string[]): File {
return dag
.coverage()
.exec(pkg, args)
.html()
}summary() 🔗
Summary of coverage by functions
Return Type
File ! Example
dagger -m github.com/act3-ai/dagger/gocoverage@c653f2a7229c06acda4d01427f879e123357cdbb call \
exec --pkg string --args string1 --args string2 \
summaryfunc (m *MyModule) Example(pkg string, args []string) *dagger.File {
return dag.
Coverage().
Exec(pkg, args).
Summary()
}@function
def example(pkg: str, args: List[str]) -> dagger.File:
return (
dag.coverage()
.exec(pkg, args)
.summary()
)@func()
example(pkg: string, args: string[]): File {
return dag
.coverage()
.exec(pkg, args)
.summary()
}percent() 🔗
Percent code coverage (total of all statements)
Return Type
Float ! Example
dagger -m github.com/act3-ai/dagger/gocoverage@c653f2a7229c06acda4d01427f879e123357cdbb call \
exec --pkg string --args string1 --args string2 \
percentfunc (m *MyModule) Example(pkg string, args []string) {
return dag.
Coverage().
Exec(pkg, args).
Percent()
}@function
def example(pkg: str, args: List[str]) -> :
return (
dag.coverage()
.exec(pkg, args)
.percent()
)@func()
example(pkg: string, args: string[]): {
return dag
.coverage()
.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@c653f2a7229c06acda4d01427f879e123357cdbb call \
exec --pkg string --args string1 --args string2 \
checkfunc (m *MyModule) Example(ctx context.Context, pkg string, args []string, threshold ) {
return dag.
Coverage().
Exec(pkg, args).
Check(ctx, threshold)
}@function
async def example(pkg: str, args: List[str], threshold: ) -> None:
return await (
dag.coverage()
.exec(pkg, args)
.check(threshold)
)@func()
async example(pkg: string, args: string[], threshold: ): Promise<void> {
return dag
.coverage()
.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@c653f2a7229c06acda4d01427f879e123357cdbb call \
exec --pkg string --args string1 --args string2 \
directoryfunc (m *MyModule) Example(pkg string, args []string) *dagger.Directory {
return dag.
Coverage().
Exec(pkg, args).
Directory()
}@function
def example(pkg: str, args: List[str]) -> dagger.Directory:
return (
dag.coverage()
.exec(pkg, args)
.directory()
)@func()
example(pkg: string, args: string[]): Directory {
return dag
.coverage()
.exec(pkg, args)
.directory()
}