Contributing
LabCluster grows through contributions: new labs, fixes to existing ones, and improvements to the platform. This page covers the development environment, the layout of the code, and how a change goes from idea to production.
Ways to contribute
- Write a lab. The most valuable contribution. See Writing labs.
- Fix a lab. A wrong fact, an unclear hint or a check that rejects a valid fix: open a pull request, or an issue if you are not sure of the fix.
- Improve the platform. Issues labelled good first issue are a good start. For anything larger than a bug fix, open an issue first so the design can be agreed before you write code.
- Report a problem or propose a lab. Use the issue templates on GitHub. Security problems go to the private channel in Security, never to a public issue.
Set up
In the browser (recommended for lab authors)
Open the repository in GitHub Codespaces. The dev container installs Go and downloads the pinned Kubernetes binaries, so make validate and make lab-test work straight away.
On your machine
You need Linux (x86-64 or arm64) or macOS, Go 1.24, make and curl; on macOS also Homebrew, which make bins uses for ttyd and a current bash. For make dev you also need Docker, for Postgres.
git clone https://github.com/<your-fork>/labcluster && cd labcluster
make bins # download the pinned control-plane binaries, kubectl, kwok and ttyd into bin/
make test # vet and unit tests
make validate # every lab against the schema
make lab-test # every lab on a real cluster (about 15 s per lab)
Run the whole platform
make dev # Postgres in Docker, a local host cluster, the website on http://127.0.0.1:8080
Sign in with the development form at the top of the page (any username), open a lab and press Start session. Development mode runs every session’s control plane and terminal as processes on your machine. It is for your own use only: never expose it to other people (see Security).
GitHub sign-in also works locally if you create a GitHub OAuth app with the callback http://127.0.0.1:8080/auth/github/callback and set GITHUB_CLIENT_ID and GITHUB_CLIENT_SECRET.
The codebase
cmd/labcluster/ the single binary: web, controller, session-host, dev, lab validate|test, grade
internal/web/ website and console: handlers, templates, static files, sign-in, terminal proxy
internal/store/ Postgres: users, sessions, quotas, progress, leaderboard
internal/controller/ reconciles LabSession objects: provision, grade, finish, tear down
internal/session/ session clusters (pod and local providers, session host), terminals, guardrails
internal/grader/ runs a lab's checks against a cluster
internal/labspec/ the lab.yaml schema, validation and the catalogue
internal/simruntime/ KWOK stages for node and container behaviour
internal/kube/ small Kubernetes client helpers: apply, list, wait
api/v1alpha1/ the LabSession custom resource
docs/ this documentation, served at /docs
labs/ the labs; labs/_template is the starting point for new ones
deploy/ Kustomize manifests for production
images/terminal/ the learner terminal image
hack/ scripts for binaries, local development and scaffolding
How it works explains how these parts interact.
Code guidelines
- Keep it small and readable. Prefer a plain function to an abstraction, and delete code that is no longer used. A new contributor should be able to follow a request from the handler to the database in a few minutes.
- Standard library first. New dependencies need a good reason in the pull request.
- Comment why, not what. Every package starts with a comment saying what it is for.
- Errors: return them with context (
fmt.Errorf("apply setup: %w", err)); show learners messages they can act on. - Tests: add a unit test with every behaviour change. Database tests run when
TEST_DATABASE_URLis set; integration tests that need the control-plane binaries run whenLABCLUSTER_E2E_BIN_DIRis set. CI sets both. - Formatting:
gofmtandgo vetmust be clean.make lintruns both. - The website: server-rendered templates, one stylesheet, no inline styles or scripts (the Content Security Policy forbids them), and no new JavaScript without a clear need.
Pull requests
- Fork, branch from
main, and keep each pull request to one change. - Run
make test validate(andmake lab-test LAB=<id>for lab changes) before pushing. - Fill in the pull request template. Link the issue it closes.
- CI must be green: unit and database tests, lab validation, lab CI for every lab, and image builds.
- A maintainer reviews. For labs, the review covers technical accuracy against upstream documentation as well as clarity.
- Squash-merge into
main. Every merge tomainis deployed to production automatically.
Commit messages use the imperative mood and say why: “Grade terminating pods as gone so old replicas do not fail checks”, not “fix grader”.
Releases
main is always deployable. Every merge builds the images, tagged with the commit, and the deploy workflow rolls them out. Version tags (v1.2.0) additionally publish images tagged with the version and create a GitHub release with notes generated from merged pull requests.
Code of conduct
Everyone taking part in LabCluster follows the code of conduct in the repository’s CODE_OF_CONDUCT.md. Be kind, assume good intent, and help newcomers.