Thanks for your interest in contributing! This document explains how to set up your environment, build the project, and run the tests.
-
Go — version
1.26or later (see.github/workflows/envfor the exact version used by CI). -
make — all common tasks are wired through the
Makefile. -
git — the repository uses a submodule for the documentation theme. Clone with submodules, or initialise them after cloning:
git clone --recurse-submodules https://github.com/creativeprojects/resticprofile.git # or, if already cloned: git submodule update --init --recursive
Optional tooling (downloaded automatically into $GOBIN by the relevant make
targets, so you usually don't install these by hand):
gotestsum— test runner used by thetest*targetsmockery— regenerates mocks before testsgolangci-lint— linter (pinned version, see.github/workflows/env)restic— only needed if you want to run resticprofile against a real repository
Run make help at any time to list all available targets.
Build the binary for your current platform:
make buildThis produces a resticprofile binary in the repository root. The target first
runs prepare_build (verifies your Go installation and downloads module
dependencies), then compiles with version metadata embedded via -ldflags.
Other build targets:
| Target | Description |
|---|---|
make install |
Build and install the binary into $GOBIN |
make build-no-selfupdate |
Build without the self-update feature (no_self_update tag) |
make build-mac |
Cross-compile for macOS (amd64 + arm64) |
make build-linux |
Cross-compile for Linux (amd64 + arm64) |
make build-windows |
Cross-compile for Windows (amd64 + arm64) |
make build-all |
Cross-compile for all of the above |
To remove build artifacts (binaries, coverage files, generated mocks, etc.):
make cleanRun the full unit test suite:
make testThe test target automatically:
- Installs
gotestsum(into$GOBIN) if needed. - Runs
prepare_test, which regenerates mocks withmockery. - Builds the test helper binaries under
testhelpers/(test-args,test-echo,test-crontab,test-shell) and exposes their location via theTEST_HELPERSenvironment variable. - Runs the tests with
gotestsum.
Useful variations:
| Target | Description |
|---|---|
make test-short |
Run tests in short mode (-short) |
make test-race |
Run tests with the race detector (short mode) |
make test-ci |
Run tests as CI does: race detector, -short, fuse build tag, coverage profile and JUnit report |
make coverage |
Generate a coverage profile and open the HTML report |
The test targets honour the TESTS variable (default ./...). For example, to
run the tests of a single package:
make test TESTS=./config/...You can also run the standard Go tooling directly, but remember to point
TEST_HELPERS at the directory containing the helper binaries built by
make test-helpers:
make test-helpers
TEST_HELPERS=$(pwd)/build/ go test ./config/...Some tests are guarded behind the fuse build tag. They require FUSE
support on your machine.
The SSH client integration tests need a containerised SSH server and are run separately:
make start-ssh-server # spins up the SSH server via docker compose
make ssh-test # runs the SSH client tests (ssh build tag)
make stop-ssh-server # tears the server down and cleans upThese require Docker (with docker compose) and ssh-keygen.
CI runs golangci-lint. To run it locally:
make lint # lint for darwin, linux and windows build targets
make fix # run go mod tidy, go fix, and golangci-lint --fixThe linter version is pinned in .github/workflows/env
and the configuration lives in .golangci.yml.
Some files are generated and should be regenerated when you change their sources:
- Mocks are regenerated automatically by
make prepare_test(used by the test targets), based on.mockery.yml. go generateis run as part ofmake test-ci; you can also rungo generate ./...directly.- JSON schema and the configuration reference are generated from the
built binary with
make generate-jsonschemaandmake generate-config-reference. The documentation site is built withmake documentation(requires Hugo and the docs submodule).
Pull requests are validated on Linux, macOS, Windows and several BSDs. The
Linux/macOS/Windows jobs run the shared workflow
.github/workflows/run-tests-os.yml,
which essentially performs:
make build
make test-ciBefore opening a pull request, it's a good idea to run at least:
make build
make lint
make test- Fork the repository and create a topic branch from
master. - Make your changes, keeping the existing code style and adding tests where it makes sense.
- Run
make build,make lintandmake testand make sure they pass. - Open a pull request describing your change.
Thanks for contributing! 🎉