Skip to content

Commit 7c0e8d3

Browse files
committed
Adds a simple Makefile with the most commonly used options
This will make it easier for people new to the project to figure out how to contribute or test changes locally. Signed-off-by: John Schnake <[email protected]>
1 parent 24ebb1f commit 7c0e8d3

File tree

4 files changed

+61
-11
lines changed

4 files changed

+61
-11
lines changed

Makefile

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
.PHONY: build test update_golden help
2+
.DEFAULT_GOAL := help
3+
4+
build: ## Builds the Sonobuoy binary for your local OS
5+
# This is for local use; when building for other os/arch, use functions in ./scripts/build_funcs.sh directly.
6+
@echo "Building the sonobuoy binary..."
7+
go build
8+
@echo "Complete. Use sonobuoy in the current working directory (e.g. ./sonobuoy)"
9+
10+
test: ## Runs go tests
11+
@echo "Running unit tests..."
12+
source ./scripts/build_funcs.sh; unit_local
13+
14+
golden: ## Runs go generate to produce version info
15+
source ./scripts/build_funcs.sh; update_local
16+
@echo "Run 'git status' and 'git diff' to see updated golden files."
17+
18+
help:
19+
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'

README.md

+18
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,24 @@ will be. Feel free to make comments on Github or start conversations in Slack.
197197
Thanks for taking the time to join our community and start contributing! We welcome pull requests. Feel free to dig
198198
through the [issues][issue] and jump in.
199199

200+
The most common build/test functions are called via the Makefile:
201+
202+
```
203+
// Build the binary
204+
$ make build
205+
206+
// Run local unit tests
207+
$ make test
208+
```
209+
210+
If you make changes which change output, you may fail tests which utilize the golden file testing pattern (e.g. correct data is stored in external files), update them by running:
211+
```
212+
$ make golden
213+
```
214+
215+
In most cases, running integration tests is more simply done in CI when you open a pull request.
216+
You can dig into scripts/build_funcs.sh and our .github/workflows/ci-test.yaml for exact details of existing test flows.
217+
200218
### Before you start
201219

202220
* Please familiarize yourself with the [Code of Conduct][coc] before contributing.

scripts/build_funcs.sh

+5-3
Original file line numberDiff line numberDiff line change
@@ -364,9 +364,11 @@ load_test_images_into_cluster(){
364364
# tests so this will also build sonobuoy locally. A kind cluster won't be necessary.
365365
update_local() {
366366
set -x
367-
# Download linux kubectl and move into default path for tests
368-
curl --output ./kubectl https://storage.googleapis.com/kubernetes-release/release/v1.23.0/bin/linux/amd64/kubectl
369-
chmod +x ./kubectl
367+
if [ -f "./kubectl" ]; then
368+
# Download linux kubectl and move into default path for tests
369+
curl --output ./kubectl https://storage.googleapis.com/kubernetes-release/release/v1.23.0/bin/linux/amd64/kubectl
370+
chmod +x ./kubectl
371+
fi
370372

371373
# Redirect output so we can avoid clutter where go is telling us where -update
372374
# is not defined. Just printing out the packages at the end.

site/content/docs/main/_index.md

+19-8
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,6 @@ more about the new release cycles in [our blog][decoupling-sonobuoy-k8s].
5252

5353
Move the extracted `sonobuoy` executable to somewhere on your `PATH`.
5454

55-
## CLI Documentation
56-
57-
The full documentation for the CLI can be found [here][clidocs].
58-
5955
## Getting Started
6056

6157
To launch conformance tests (ensuring [CNCF][cncf] conformance) and wait until they are finished run:
@@ -207,6 +203,24 @@ will be. Feel free to make comments on Github or start conversations in Slack.
207203
Thanks for taking the time to join our community and start contributing! We welcome pull requests. Feel free to dig
208204
through the [issues][issue] and jump in.
209205

206+
The most common build/test functions are called via the Makefile:
207+
208+
```
209+
// Build the binary
210+
$ make build
211+
212+
// Run local unit tests
213+
$ make test
214+
```
215+
216+
If you make changes which change output, you may fail tests which utilize the golden file testing pattern (e.g. correct data is stored in external files), update them by running:
217+
```
218+
$ make golden
219+
```
220+
221+
In most cases, running integration tests is more simply done in CI when you open a pull request.
222+
You can dig into scripts/build_funcs.sh and our .github/workflows/ci-test.yaml for exact details of existing test flows.
223+
210224
### Before you start
211225

212226
* Please familiarize yourself with the [Code of Conduct][coc] before contributing.
@@ -269,7 +283,4 @@ See [the list of releases][releases] to find out about feature changes.
269283

270284
[aggregator-permissions]: aggregator-permissions
271285

272-
[clidocs]: cli/sonobuoy
273-
274-
[roadmap]: https://github.com/vmware-tanzu/sonobuoy/wiki/Roadmap
275-
286+
[roadmap]: https://github.com/vmware-tanzu/sonobuoy/wiki/Roadmap

0 commit comments

Comments
 (0)