Switch from shellscripts-based CI to Go-based CI #310
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Recently, it is becoming harder and harder to maintain our shellscript-based CI (stored under
/script
). Let's switch to golang-based tests. This will help us to write test codes in a type-safe & modular manner, leveraging rich language features of Go.The core package that enables this switch is
util/dockershell
. This providesexec.Cmd
-like API + some useful abstraction over docker, docker-compose and kind. This package allows us to handle multiple shell environments (e.g. node + registry) in object-oriented manners, leveraging Go's rich features including standard lib, goroutine, duck-typing, etc.Based on that pkg, this commit has converted shellscript-based CI into the Go-based testing scripts.
/integration
pkg contains all integratoin tests previously resided under/script
./benchmark
pkg contains hello-bench-based benchmark previously resided under/script/benchmark
.Additional value of this is that this allows contributors to easily run our CI on any hosts, even on their laptop as long as docker, docker-compose and kind are installed.
About
util/dockershell
This pkg provides intuitive shellscript-like API with containers, aiming at tests use-case.
The core of this pkg is
util/dockershell/exec
. This enablesexec.New(containerName).Command(args...).Run()
which runs commandargs...
inside a container namedcontainerName
. Here,exec.New(containerName)
gives us an execution environment*exec.Exec
where we can run any commands insidecontainerName
.Based on this pkg, there are the following wrappers/helpers that allows us to control multiple execution environments.
util/dockershell/compose
creates a set of*exec.Exec
s from docker-compose YAML.util/dockershell/kind
creates a set of*exec.Exec
s from Kind config YAML. This also provides a kubectl wrapper. This wrapper enableskind.New(kindYAML).KubeCtl(args ...).Run()
which executes arbitrary kubectl commands against the created cluster.util/dockershell
provides wrapper ofutil/dockershell/exec
. This gives us shellscript-like experience for executing commands in containers. For example,dockershell.New(nil, container).X(a).X(b).X(c)
executes commands a, b and c sequencially in the container.Example:
Currently,
util/dockershell
contains only methods needed for our integration test and benchmark. Some features may be still missing for general use and we still have room for improvement.