Dagger
Search

coverage

Package go code coverage module

Installation

dagger install github.com/act3-ai/dagger/gocoverage@v0.1.3

Entrypoint

Return Type
Coverage !
Arguments
NameTypeDefault ValueDescription
baseContainer !-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:TAG
func (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-tests
func (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
NameTypeDefault ValueDescription
pkgString !-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 string2
func (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
NameTypeDefault ValueDescription
otherResults !-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-format
func (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 \
 svg
func (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 \
 html
func (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 \
 summary
func (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 \
 percent
func (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
NameTypeDefault ValueDescription
thresholdFloat !-minimum percentage to accept
Example
dagger -m github.com/act3-ai/dagger/gocoverage@c653f2a7229c06acda4d01427f879e123357cdbb call \
 exec --pkg string --args string1 --args string2 \
 check
func (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 \
 directory
func (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()
}