diff --git a/.circleci/config.yml b/.circleci/config.yml index 821125d..9c8220e 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -39,6 +39,7 @@ jobs: - run: name: go_test command: go test -v ./... + - run: make verify-licenses build: executor: linuxgo diff --git a/.go-version b/.go-version index f5b00dc..14bee92 100644 --- a/.go-version +++ b/.go-version @@ -1 +1 @@ -1.20.3 +1.23.2 diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..d4d7e71 --- /dev/null +++ b/Makefile @@ -0,0 +1,56 @@ +MAKEFLAGS += --warn-undefined-variables +MAKEFLAGS += --no-builtin-rules +MAKEFLAGS += --no-builtin-variables + +GOTESTCMD = $(if $(shell command -v gotestsum),gotestsum --junitfile ./test_results/$(1).xml --format testname --,go test) + +.PHONY: test +#: run all tests +test: test_with_race test_all + +.PHONY: test_with_race +#: run only tests tagged with potential race conditions +test_with_race: test_results + @echo + @echo "+++ testing - race conditions?" + @echo + $(call GOTESTCMD,$@) -tags race --race --timeout 60s -v ./... + +.PHONY: test_all +#: run all tests, but with no race condition detection +test_all: test_results + @echo + @echo "+++ testing - all the tests" + @echo + $(call GOTESTCMD,$@) -tags all --timeout 60s -v ./... + +test_results: + @mkdir -p test_results + +.PHONY: install-tools +install-tools: + go install github.com/google/go-licenses/v2@v2.0.0-alpha.1 + +.PHONY: update-licenses +update-licenses: install-tools + rm -rf LICENSES; \ + #: We ignore the standard library (go list std) as a workaround for \ + "https://github.com/google/go-licenses/issues/244." The awk script converts the output \ + of `go list std` (line separated modules) to the input that `--ignore` expects (comma separated modules). + go-licenses save --save_path LICENSES --ignore "github.com/honeycombio/buildevents" \ + --ignore $(shell go list std | awk 'NR > 1 { printf(",") } { printf("%s",$$0) } END { print "" }') ./; + + +.PHONY: verify-licenses +verify-licenses: install-tools + go-licenses save --save_path temp --ignore "github.com/honeycombio/buildevents" \ + --ignore $(shell go list std | awk 'NR > 1 { printf(",") } { printf("%s",$$0) } END { print "" }') ./; \ + chmod +r temp; \ + if diff temp LICENSES; then \ + echo "Passed"; \ + rm -rf temp; \ + else \ + echo "LICENSES directory must be updated. Run make update-licenses"; \ + rm -rf temp; \ + exit 1; \ + fi; \ diff --git a/RELEASING.md b/RELEASING.md index 9bba5ac..3775496 100644 --- a/RELEASING.md +++ b/RELEASING.md @@ -1,13 +1,31 @@ # Releasing -- Use [go-licenses](https://github.com/google/go-licenses) to ensure all project dependency licenses are correctly represented in this repository: - - Install go-licenses (if not already installed) `go install github.com/google/go-licenses@latest` - - Run and save licenses `go-licenses save github.com/honeycombio/buildevents --save_path="./LICENSES"` - - If there are any changes, submit a separate PR to update licenses. +- Check that licenses are current with `make verify-licenses` + - If there are any changes, submit a separate PR to update licenses using `make update-licenses`. - Prep update PR for the [orb](https://github.com/honeycombio/buildevents-orb) with the new version of buildevents. -- Update `CHANGELOG.md` with the changes since the last release. Consider automating with a command such as these two: - - `git log $(git describe --tags --abbrev=0)..HEAD --no-merges --oneline > new-in-this-release.log` - - `git log --pretty='%C(green)%d%Creset- %s | [%an](https://github.com/)'` +- Update `CHANGELOG.md` with the changes since the last release. + - Use below command to get a list of all commits since last release + + ```sh + git log ..HEAD --pretty='%Creset- %s | [%an](https://github.com/%an)' + ``` + + - Copy the output from the command above into the top of [changelog](./CHANGELOG.md) + - fix each `https://github.com/` to point to the correct github username + (the `git log` command can't do this automatically) + - organize each commit based on their prefix into below three categories: + + ```sh + ### Features + - + + ### Fixes + - + + ### Maintenance + - + ``` + - Commit changes, push, and open a release preparation pull request for review. - Once the pull request is merged, fetch the updated `main` branch. - Apply a tag for the new version on the merged commit (e.g. `git tag -a v2.3.1 -m "v2.3.1"`)