This tool has two functions:
affected
finds the affected packages given a list of diffs.setup-files
loads and validates the setup files settings for each package.
The tooling is language agnostic, so anything that is language-specific is configured in a config file.
The config file can be a .json
file, or a .jsonc
(JSON with comments) file.
For .jsonc
files, it supports both // single line comments
and /* multi-line comments */
.
For example, a config file for Node.js might look like this:
For more information, see
pkg/config/config.go
.
To the tools tests, we must change to the directory where the tools package is defined. We can run it in a subshell using parentheses to keep our working directory from changing.
(cd custard && go test -v ./...)
To build the tools, we must change to the directory where the tools package is defined. We can run it in a subshell using parentheses to keep our working directory from changing.
(cd custard && go build -o /tmp/custard ./cmd/...)
This must run at the repository root directory.
First, generate a file with all the diffs. This file should be one file per line.
You can use git diff
to test on files that have changed in your branch.
You can also create the file manually if you want to test something without commiting changes to your branch.
git --no-pager diff --name-only HEAD origin/main | tee /tmp/diffs.txt
Then run the affected
command, with the following positional arguments:
- The
config.jsonc
file path. - The
diffs.txt
file path. - The
paths.txt
file path to write the affected packages to.
/tmp/custard affected \
path/to/config.jsonc \
/tmp/diffs.txt \
/tmp/paths.txt
The output paths file contains one path per line.
This must run at the repository root directory.
Then run the setup-files
command, with the following positional arguments:
- The
config.jsonc
file path. - The
paths.txt
file with the packages of interest.
/tmp/custard setup-files \
path/to/config.jsonc \
/tmp/paths.txt