Skip to content

Commit

Permalink
feat: implement commit-msg hook (#45)
Browse files Browse the repository at this point in the history
Signed-off-by: Tronje Krop <[email protected]>
  • Loading branch information
tkrop authored Jan 31, 2024
1 parent 455ba90 commit 55f4067
Show file tree
Hide file tree
Showing 22 changed files with 347 additions and 181 deletions.
33 changes: 24 additions & 9 deletions MANUAL.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,17 @@ Similar default config files for tools can be installed using `make init/<file>`
to allow customization. All files can be updated by calling `make update-make`
or simpler `make update`.

**Warning:** `go-make` automatically installs `pre-commit` and `commit-msg`
[hooks][git-hooks] overwriting and deleting pre-existing hooks (see also
[Customizing Git - Git Hooks][git-hooks]). The `pre-commit` hook calls
`make commit` as an alias for executing `test-go`, `test-unit`, `lint-<level>`,
and `lint-markdown` to enforce successful testing and linting. The `commit-msg`
hook calls `make git-verify message` for validating whether the commit message
is following the [conventional commit][convent-commit] best practice.

[git-hooks]: <https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks>
[convent-commit]: <https://www.conventionalcommits.org/en/v1.0.0/>

For more information on customization, please see documentation of the different
target groups:

Expand Down Expand Up @@ -92,14 +103,24 @@ them might need to be adjusted. The following list provides an overview of the
most prominent ones

```Makefile
# Setup default test timeout (default: 10s).
TEST_TIMEOUT := 15s
# Setup when to push images (default: pulls [never, pulls, merges])
IMAGE_PUSH ?= never
# Setup specific go-make version.
GOMAKE := github.com/tkrop/go-make@latest
# Setup the activated commit hooks (default: pre-commit commit-msg).
GITHOOKS := pre-commit commit-msg
# Setup code quality level (default: base).
CODE_QUALITY := plus
# Customizing codacy server (default: https://codacy.bus.zalan.do).
CODACY_API_BASE_URL := https://api.codacy.com
CODE_QUALITY := base


# Setup codacy integration (default: enabled [enabled, disabled]).
CODACY := enabled
# Customizing codacy server (default: https://codacy.bus.zalan.do).
CODACY_API_BASE_URL := https://api.codacy.com
# (default: false / true [cdp-pipeline])
#CODACY_CONTINUE := true

# Setup required targets before testing (default: <empty>).
TEST_DEPS := run-db
Expand All @@ -108,12 +129,6 @@ RUN_DEPS := run-db
# Setup required aws services for testing (default: <empty>).
AWS_SERVICES :=

# Setup when to push images (default: pulls [never, pulls, merges])
IMAGE_PUSH ?= never

# Setup default test timeout (default: 10s).
TEST_TIMEOUT := 15s

# Setup custom delivery files scanned for updating go versions
# (default: delivery*.yaml/.github/workflows/*.yaml).
#DELIVERY := delivery.yaml
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export GO ?= go
export GOPATH ?= $(shell $(GO) env GOPATH)
export GOBIN ?= $(GOPATH)/bin
# Setup go-make to utilize desired build and config scripts.
GOMAKE_DEP ?= github.com/tkrop/[email protected].47
GOMAKE_DEP ?= github.com/tkrop/[email protected].48
# Request targets from go-make targets target.
TARGETS := $(shell command -v $(GOBIN)/go-make >/dev/null || \
$(GO) install $(GOMAKE_DEP) >/dev/stderr && \
Expand Down
12 changes: 6 additions & 6 deletions Makefile.vars
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# Setup default test timeout (default: 10s).
TEST_TIMEOUT := 10s
# Setup when to push images (default: pulls [never, pulls, merges])
IMAGE_PUSH := never
# Setup the activated commit hooks (default: pre-commit [pre-commit, commit-msg]).
GITHOOKS := pre-commit commit-msg
# Setup code quality level (default: base).
CODE_QUALITY := plus

Expand All @@ -15,12 +21,6 @@ RUN_DEPS := run-db
# Setup required aws services for testing (default: <empty>).
#AWS_SERVICES := s3 sqs

# Setup when to push images (default: pulls [never, pulls, merges])
IMAGE_PUSH ?= never

# Setup default test timeout (default: 10s).
TEST_TIMEOUT := 10s

# Custom linters applied to prepare next level (default: <empty>).
LINTERS_CUSTOM := nonamedreturns tagliatelle
# Linters swithed off to complete next level (default: <empty>).
Expand Down
7 changes: 0 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,20 +73,13 @@ when needed in the configured (or latest) available version using a default or
custom config file. All config files can be installed and customized (see
[Setup and customization](MANUAL.md#setup-and-customization)).


**Note:** For many tools `go-make` accepts the risk that using the latest
versions of tools, e.g. for linting, may break the build to allow cotinuous
upgrading of dependencies by default. For tools were this is not desireable,
e.g. for `revive` and `golangci-lint` the default import is version. Other
tools can be versioned if needed (see [manual](MANUAL.md) for more
information).

**Warning:** `go-make` automatically installs a `pre-commit` hook overwriting
and deleting any pre-existing hook. The hook calls `go-make commit` to enforce
successful unit testing and linting before allowing to commit, i.e. the goals
`test-go`, `test-unit`, `lint-base` (or what code quality level is defined as
standard), and `lint-markdown`.

[gomock]: <https://github.com/uber/mock>
[golangci]: <https://github.com/golangci/golangci-lint>
[codacy]: <https://www.codacy.com/>
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.0.47
0.0.48
2 changes: 1 addition & 1 deletion config/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export GO ?= go
export GOPATH ?= $(shell $(GO) env GOPATH)
export GOBIN ?= $(GOPATH)/bin
# Setup go-make to utilize desired build and config scripts.
GOMAKE_DEP ?= github.com/tkrop/[email protected].47
GOMAKE_DEP ?= github.com/tkrop/[email protected].48
# Request targets from go-make targets target.
TARGETS := $(shell command -v $(GOBIN)/go-make >/dev/null || \
$(GO) install $(GOMAKE_DEP) >/dev/stderr && \
Expand Down
Loading

0 comments on commit 55f4067

Please sign in to comment.