Welcome to ochami — part of the OpenCHAMI community project under the Linux Foundation Projects (LFP), High Performance Software Foundation (HPSF).
For general contribution guidelines, code of conduct, DCO requirements, and community standards, please see:
OpenCHAMI Contributing Guidelines
This document provides ochami-specific guidance for building, testing, and submitting contributions.
- Go (see minimum version in go.mod)
make(for local builds)goreleaser>= 2.12 (for official builds)scdoc(for man page generation)- Container runtime: Docker, Podman, or compatible (optional, for container builds)
The fastest way to build during development:
makeThis uses the Makefile with linker flags to embed build metadata. The binary will be created in the current directory.
Run tests:
make testTests run with Go's data race detector by default. Control test parallelism
with PARALLEL=<n> (omit to use Go's own default), or disable the race
detector for a faster local iteration loop with RACE=0:
make test PARALLEL=4
make test RACE=0Measure coverage across all packages, then list the uncovered blocks grouped by risk and by file to find gaps worth testing:
make coverage
scripts/cov-prioritize.py coverage.out # summary
scripts/cov-prioritize.py coverage.out --inventory gaps.tsv # every blockRun linting:
make lintCheck REUSE compliance:
make reuseWhen modifying renovate.json, run the configuration check before submitting
a PR:
make renovate-checkThis check requires Node.js 24 and npx (included with npm). It downloads and
runs the pinned Renovate validator with the same version and flags as CI.
Also run it when changing the validator recipe in Makefile or the validation
workflow in .github/workflows/renovate.yml.
Renovate updates the Makefile's RENOVATE_VERSION variable and the workflow's
version pin together. The CI check runs on PRs that change renovate.json,
Makefile, or .github/workflows/renovate.yml.
This is the recommended approach for testing container changes before submitting a PR.
Build a local container from source using a multi-stage build:
make containerTo use a different container runtime (e.g. Podman):
make CONTAINER_PROG=$(which podman) containerBuild local containers for all supported architectures using the Makefile
goreleaser-* targets, which require GoReleaser >= 2.12 and Docker Buildx. The
builder must support linux/amd64 and linux/arm64 (use Docker Desktop or
configure QEMU on Linux):
# Build binaries, packages, and local images for both container platforms
make GORELEASER_OPTS='--clean --snapshot' goreleaser-releaseNote
Goreleaser as of writing does not have the capability of building only a
single container for the current architecture. To do this using Goreleaser,
modification of .goreleaser.yaml is necessary (just be sure to revert
changes after).
If this is not desired, use the multi-stage build method above.
GoReleaser uses docker buildx directly; CONTAINER_PROG only applies to
make container. Snapshot releases build and load separate images with
-amd64 and -arm64 tag suffixes. Do not add --skip=publish: with
dockers_v2, that also skips building the containers.
The Makefile supports these environment variables for goreleaser builds:
IS_PR_BUILD- Whether this is a PR build (default:false)GORELEASER_OPTS- Additional flags to pass to goreleaser
A GoReleaser snapshot loads ghcr.io/openchami/ochami:latest-amd64 and
ghcr.io/openchami/ochami:latest-arm64 locally. Use the tag matching your
host architecture. A make container build uses ghcr.io/openchami/ochami:latest
by default. You can test it:
# Using Docker
docker run ghcr.io/openchami/ochami:latest ochami --version
# Using Podman
podman run ghcr.io/openchami/ochami:latest ochami --versionpkg/config- Configuration loading, merging, cluster lookup, and service URI resolution. Use this package for any code that needs to work with ochami configuration. It is state-independent: the loaders (config.Load,config.LoadFile,config.LoadDefaults,config.LoadMerged) return a freshconfig.Configwithout touching package-global state, so it is safe to build multiple independent configurations and easy to use in tests. See the package documentation (go doc github.com/openchami/ochami/pkg/config) and the runnable examples inpkg/config/example_test.gofor usage. On-disk editing of config files used by theochami configcommands is also public API, viaconfig.File(config.OpenFile/config.CreateFile) — an external Go program can use it to add, set, rename, or delete clusters and global keys the same way the CLI does.
To keep the test suite navigable as it grows, follow these conventions when adding or modifying tests.
Use TestSubject_Case: Subject names the function, type, method
(Type_Method), or command under test; Case names the specific scenario or
condition the test checks (e.g. TestExitCode_CodedBeatsSentinel,
TestEnsureCode_NoDoubleWrap). Omit the _Case suffix only when the package
has no other test for that subject (e.g. TestFabricaWrapHTTPError).
Group tests for a subject into files using this suffix taxonomy:
<subject>_test.go— happy-path / correctness tests.<subject>_errors_test.go— error-path / rejection tests (invalid input, HTTP/network failures, malformed responses, etc).<subject>_boundary_test.go— edge-value or platform-boundary tests (empty/nil inputs, OS-specific behavior, filesystem/process boundaries).
Avoid generic, non-descriptive suffixes (_more, _edge, _extra,
_coverage, _regressions, _branches) — pick the bucket above that
matches what the test actually asserts, or extend the subject's plain test
file if it's more happy-path coverage of the same subject.
Keep each subject's tests for a bucket in one file of its package, so the
file name tells a reader where they are. The subject here is the part of the
name before the first underscore (TestFile in TestFile_SetKey); if that
is too broad to group by, name the tests after the specific function or
method (TestFileUpdate_PersistsAllChanges). The exception is a file
restricted to some platforms by a GOOS/GOARCH file name suffix or build
constraint (e.g. pkg/config/sync_windows_test.go), which holds a subject's
tests for those platforms; keep those in one file per set of platforms. Other
build tags don't make an exception.
Name command tests in cmd after the command path they cover, joined with
underscores: smd_group_test.go holds every happy-path test of the smd group subcommands, whatever the verb, and smd_group_errors_test.go their
error paths. Use a deeper path only for a resource with its own subcommand
group (smd_group_member_test.go, bss_boot_params_test.go). The family
file (smd_test.go) holds only the commands directly under the family, such
as smd service status or discover static, and tests that span several of
the family's resources (TestBootAdd_Success,
TestSMDDelete_RejectsEmptyData). The root files (root_test.go) hold tests
of the global flags and of how the root command loads config. Tests of one
behavior across families go in a file named after that behavior
(prompts_test.go, tokenless_test.go, service_status_test.go), and error
tables across families in commands_errors_test.go.
Give a subject's files for each bucket the same stem, so that its error and
boundary tests sit next to its happy-path tests: loader_test.go,
loader_errors_test.go, and loader_boundary_test.go. Files restricted to some
platforms and commands_errors_test.go are the exceptions.
The suffix taxonomy groups separate top-level Test functions, not the
t.Run subtests within one. A single TestSubject that uses subtests to
check several facets of one cohesive contract (e.g. an executor's
ordering, cancellation, and deadline behavior) belongs together in the
subject's plain _test.go file even when individual subtests cover error
conditions (see pkg/client/batch_test.go).
Give every Test function a doc comment that starts with the function's
name and states the behavior it verifies, the same way exported Go
identifiers are documented (e.g. // TestEnsureCode_NoDoubleWrap verifies EnsureCode preserves an already-coded error's original code). For a
table-driven test, summarize what the cases cover rather than describing
each row. Describe behavior, not coverage mechanics: avoid words such as
"arm", "branch", "exercises", and "handles", and don't refer to other tests.
An HTTP method, path, or exit code a doc names is one the test asserts.
Describe an expected exit code in a failure message with cli.CodeName
instead of hard-coding the constant's name, so the message stays accurate if
the constant is renamed:
if got := cli.ExitCode(err); got != cli.CodeNetwork {
t.Errorf("exit code = %d, want %d (%s)", got, cli.CodeNetwork, cli.CodeName(cli.CodeNetwork))
}Commands read and write through the invocation runtime's streams
(rt.Ios.In(), rt.Ios.Out(), cli.WriteOutput), never os.Stdin or
os.Stdout directly. Command tests run a real command tree against an
isolated cli.NewTestRuntime through the helpers in cmd/testhelpers_test.go
(runOchamiWithRuntime and friends), and call t.Parallel() unless they use
t.Setenv, which can't be combined with it.
The tables in commands_errors_test.go guarantee each command's exit code for a
failure, including for commands added later. Keep a per-family error test only
when it covers something its table row doesn't: a different selector, flag, or
stub response, or more than the exit code, such as the request sent, the message,
or the output. Don't add a test that repeats a row.
make test runs the tests in internal/conventions, which parse the
module's sources and fail on:
- test names that don't follow
TestSubject_Case, test files with a generic suffix, a subject's tests for one bucket split across files, and a subject's bucket files with different stems; - test doc comments that don't start with the test's name, use coverage jargon, or refer to other tests;
- test doc comments that say the test issues, sends, or requests an HTTP method or path its body never mentions, or that name exit codes none of which its body mentions;
- tests that can't fail;
- exit code failure messages without
cli.CodeName, and exit codes compared with integer literals; - an EXIT STATUS table in ochami(1) that differs from the exit codes in
internal/cli/errors.go; - exported
pkg/configAPI that exposes koanf; - external actions and reusable workflows under
.githubthat aren't pinned to a full commit SHA with an exact release comment (owner/repo@<sha> # v1.2.3).
Run them alone with go test ./internal/conventions. make lint checks the
rest: commands use the runtime's streams and return errors rather than
exiting, pkg/ doesn't import the command tree or CLI state, command tests
call t.Parallel(), and test helpers call t.Helper().
When you submit a PR from a fork, GitHub Actions will automatically build binaries, packages, and containers. Container images are built but not published for fork PRs due to GitHub security restrictions.
The best workflow is to build and test locally first before submitting a PR:
- Make your changes
- Build locally using the Makefile approach above
- Test the container locally to validate your changes
- Submit your PR - binaries/packages/containers will build automatically (containers are built locally but not published to registries for forks)
This ensures your changes work before CI runs.
Container images are built locally but not published for fork PRs due to GitHub security restrictions.
GitHub Actions workflows from fork PRs can build containers locally within the workflow but cannot push them to any registry. This is a security feature and cannot be bypassed.
Your fork PR will still:
- Build binaries for all platforms
- Build packages (deb, rpm, apk, archlinux)
- Build container images locally (for validation)
- Run all tests and linting
- Be fully reviewable and mergeable
To test containers before submitting, build and test locally using the Makefile.
For reviewers:
Check out the fork branch locally to test containers:
# Fetch PR branch
PR_NUMBER=<pr_number>
git fetch origin "pull/${PR_NUMBER}/head:pr-${PR_NUMBER}"
git checkout "pr-${PR_NUMBER}"
# Build and test
make GORELEASER_OPTS='--clean --snapshot' goreleaser-release
docker run ghcr.io/openchami/ochami:latest ochami --versionNote: PRs from upstream branches (not forks) will build containers normally
at ghcr.io/openchami/ochami:pr-<pr_number>.
Every pull request whose change users or Go API consumers would notice must add
an entry to CHANGELOG.md. Pull requests with no user impact
don't need one, such as those that only change tests, CI, or internal structure,
or that make routine dependency updates. Security-relevant dependency updates
always need an entry. A maintainer adds it when a bot opens the pull request.
Add the entry under ## [Unreleased], in the heading that matches the change.
Create the heading if it doesn't exist yet, keeping them in this order:
- Added for new features.
- Changed for changes to existing behavior.
- Deprecated for features that will be removed.
- Removed for features that have been removed.
- Fixed for bug fixes.
- Security for vulnerability fixes.
Describe the change and its impact on users in one or two sentences, rather than
repeating the commit subject or how the code changed. Start the entry with
**BREAKING:** if users must change something, and say what. For example:
## [Unreleased]
### Changed
- **BREAKING:** `--cacert` and `--insecure` are now mutually exclusive.
Previously, `--cacert` silently turned certificate verification back on.
### Fixed
- `--log-format json` now emits JSON.Maintainers move these entries under a version heading when making a release.
- Fork the repository and create a feature branch
- Build and test locally using
makeormake goreleaser-build - Run all checks before submitting:
When changing Renovate configuration or validation tooling, also run
make test make lint make reusemake renovate-checkas described above. - Update the changelog under
Unreleasedas described in Changelog - Commit with DCO sign-off (see OpenCHAMI Contributing Guidelines)
- Open a Pull Request and ensure it passes CI checks
- Respond to review feedback promptly
- OpenCHAMI Contributing
Guidelines
- Code of conduct, DCO, REUSE compliance, quality standards
- OpenCHAMI Community - Values, principles, charter, governance
- ochami Documentation - Manual pages in scdoc format
- OpenCHAMI Slack - Community chat
- ochami Issues - Bug reports and feature requests
Thank you for contributing to ochami and the OpenCHAMI community!