Develop Octopus
Build management of Octopus
Octopus takes inspiration from Maven and provides a set of project build management based on make. Build management process consists of several stages, a stage consists of several actions. For convenience, the name of the action also represents the current stage. The overall flow relationship of action looks as below:
Explanation of each action:
| Action | Usage |
|---|---|
generate, gen, g | Generate deployment manifests and deepcopy/runtime.Object implementations of octopus via controller-gen; Generate proto files of adaptor interfaces via protoc. |
mod, m | Download octopus dependencies. |
lint, l | Verify octopus via golangci-lint, roll back to go fmt and go vet if the installation fails. <br/Use DIRTY_CHECK=true to verify the whole project is in dirty tree or not. |
build, b | Compile octopus according to the type and architecture of the OS, generate the binary into bin directory. Use CROSS=true to compile binaries of the supported platforms(search constant.sh file in this repo). |
test, t | Run unit tests. |
verify, v | Run integration tests with a Kubernetes cluster. Use CLUSTER_TYPE to specify the type for local cluster, default is k3d. Instead of setting up a local cluster, you can also use environment variable USE_EXISTING_CLUSTER=true to point out an existing cluster, and then the integration tests will use the kubeconfig of the current environment to communicate with the existing cluster. |
package, pkg, p | Package Docker image. |
e2e, e | Run E2E tests. |
deploy, dep, d | Push Docker images and create manifest images for the current version. Use WITHOUT_MANIFEST=true to prevent pushing manifest image, or ONLY_MANIFEST=true to push the manifest images only and IGNORE_MISSING=true to warn on missing images defined in platform list if needed. |
Executing a stage can run make octopus <stage name>, for example, when executing the test stage, please run make octopus test. To execute a stage will execute all actions in the previous sequence, if running make octopus test, it actually includes executing generate, mod, lint, build and test actions.
To run an action by adding only command, for example, if only run build action, please use make octopus build only.
To combine multiple actions can use a comma list, for example, if want to run build, package and deploy actions orderly, please use make octopus build,package,deploy.
Integrate with dapper via BY environment variable, for example, if only run build action via dapper, please use BY=dapper make octopus build only.
Usage cases
Suppose to try the following example on Mac:
Run in the localhost, the current environment will install additional dependencies. You will get a corresponding warning if any installation fails.
make octopus build: executebuildstage, then get adarwin/amd64execution binary.make octopus test only: executetestaction ondarwin/amd64platform.REPO=somebody OS=linux ARCH=amd64 make octopus package: executepackagestage, then get alinux/amd64execution binary and an octopuslinux/amd64image ofsomebodyrepo.CLUSTER_TYPE=kind make octopus verify only: executeverifyaction withkindcluster.
Support multi-arch in the localhost.
CROSS=true make octopus build only: executebuildaction, then get all execution binaries of supported platform.CROSS=true make octopus test only: crossed testing isn't supported currently.CROSS=true REPO=somebody make octopus package only: executepackageaction, then get all supported platform images ofsomebodyrepo.make octopus package only: packagingdarwinplatform image isn't supported currently.
CROSS=true REPO=somebody make octopus deploy only: executedeployaction, then push all supported platform images tosomebodyrepo, also create manifest images for the current version.make octopus deploy only: deployingdarwinplatform image isn't supported currently.
In
dappermode, no additional dependencies are required in the current environment, which suitable for constructing CI / CD and good to the portability of the environment.BY=dapper make octopus build: executebuildstage, then get alinux/amd64execution binary.BY=dapper make octopus test: executeteststage onlinux/amd64platform.BY=dapper REPO=somebody make octopus package only: executepackageaction and get an octopuslinux/amd64image ofsombodyrepo.
Notes
In dapper mode:
- Using
USE_EXISTING_CLUSTER=trueis NOT ALLOWED.
Build management of Adaptors
The build management of Adaptors is the similar to Octopus, except that the execution is different. Executing a stage of any adaptor can run make adaptor <adaptor name> <stage name>. Please view Develop Adaptors for more details.
Build management for all components
With the increase of components, the operation of building them one by one becomes more cumbersome. Therefore, by specifying a stage or action, the build management performs the same stage or action for all components. For example, running make all test will execute the test stage of Octopus and all Adaptors. To execute an action just type with an only suffix command.
Contributor workflow
Contributing is welcome, please view CONTRIBUTING for more details.