On arm64 the x86 version of corrosion was downloaded. This downloads the correct version. Also added comments to HACKING.md on how to clean up a broken cluster as I have done it twice now and forgot how to do it both times. Fixes: #284 ~~~ shell % ./ucind cluster create miektest Cluster "miektest" initialised with machine "machine-1" Waiting for cluster to be ready... done. Cluster 'miektest' added to Uncloud config as the current context. Cluster 'miektest' created. ~~~ `uc machine ls` also works. Signed-off-by: Miek Gieben <miek@miek.nl>
2.9 KiB
Developing Uncloud
A short guide on setting up your local development environment.
Prerequisites
Setup
Uncloud uses mise to install and manage development tools and dependencies. It makes it easy to create reproducible
development environments on developer machines and CI.
Follow the Installing Mise guide to get it set up on your machine.
Mark the project as trusted and install all required tools (Go, protoc, golangci-lint, etc.) by running from the
project root:
mise trust
mise install
This reads mise.toml and installs the exact versions of tools specified there. They will be available in
your PATH when you are in the project directory, so you can run go or golangci-lint directly. The tools won't be
available outside the project, so they don't interfere with system packages.
Building
Build the CLI:
go build -o uc ./cmd/uncloud
Or build and run the CLI with a single command:
go run ./cmd/uncloud --help
The Uncloud daemon (uncloudd) only supports Linux, so you need to cross-compile it if you're developing on macOS or
Windows:
GOOS=linux GOARCH=amd64 go build -o uncloudd ./cmd/uncloudd
Docker in Docker (ucind)
When running ucind and running in trouble, you must manually remove the cluster, by running:
docker stop CONTAINERID
docker rm CONTAINERID
docker network rm CLUSTERNAME
Testing
Run all tests (unit and e2e):
make test
End-to-end tests
E2e tests run inside Docker using the ucind (Uncloud-in-Docker) image. Build it first:
make ucind-image
⚠️ NOTE: You need to rebuild the ucind image every time you make changes to the daemon code if you want to test them
in e2e tests.
Then run the tests:
make test-e2e
If tests leave leftover containers, clean them up with:
make test-clean
Manual testing on dev machines
After making changes to the daemon code, you may want to test them in your dev cluster. Build and install uncloudd on
one or multiple dev machines over SSH with:
mise run dev:install user@host1 user@host2/arm64
It will also restart the uncloud.service daemon on those machines to pick up the new version. The host format is
[user@]host[/arch]. The architecture of a machine defaults to amd64 if not specified.
To stop the daemon and wipe all Uncloud data on the dev machines, run:
mise run dev:reset user@host1 user@host2
Linting and formatting
Lint and format the code:
make lint-and-fix
Code generation
Update the generated Go code for the machine gRPC API after modifying .proto files:
mise run proto
Regenerate mocks:
make mocks