GoTest Module for Dagger

A simple Dagger module that wraps Go testing functionality to run Go tests within a containerized environment.
Configuration ๐ ๏ธ
Through the Dagger CLI, or by using it directly within your module, you can configure the following options:
- โ๏ธ
ctr: The container to use as a base container. If not specified, a new container is created.
- โ๏ธ
version: The version of the Go image to use. Defaults to latest.
- โ๏ธ
image: The Go image to use. Defaults to golang:alpine.
- โ๏ธ
envVarsFromHost: Environment variables to pass from the host to the container.
Features ๐จ
| Command or functionality |
Command |
Example |
Status |
| Run Go Tests |
run |
dagger call run-go-test --packages="./..." --enableVerbose=true --race=true --src="my-code/src" |
โ
|
| Run GoTestSum |
gotestsum |
dagger call run-go-test-sum --src="mydir/src" --race=true --testFlags="-json" --goTestSumFlags="--format=short-verbose" --format="short" --enablePretty=true |
โ
|
Using the GoTest Module
This module allows you to integrate Go testing into your Dagger pipelines easily. To use it, simply specify the source directory and the desired command. The module can execute various Go testing functions, including running tests and using gotestsum for advanced test result formatting.
- GoTestSum: GoTestSum is a tool for running and summarizing Go tests. More details can be found in the GoTestSum Documentation.
- Dagger: Dagger is a portable devkit for CI/CD pipelines, allowing you to define your pipeline as code and execute it anywhere. For more on Dagger, visit Dagger.io.
Usage ๐
dagger call run-go-test --src="../../test/testdata/gotest" \
--test-flags="--json" --enable-cache;
dagger call --verbose run-go-test-sum --src="../../test/testdata/gotest" \
--enable-pretty --enable-cache;
Testing ๐งช
This module includes a testing module that aims to test the functionality of the GoTest module. The tests are written in Go and can be run using the following command:
## Run the tests using the just command
just test gotest
NOTE: The just command entails the use of the Justfile for task automation.