diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index ab445e3..f768efc 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -10,7 +10,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v3 with: - go-version: 1.21 + go-version: 1.22.0 - name: Build and tests env: diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index c496ba2..881f313 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -10,16 +10,16 @@ jobs: - name: Set up Go uses: actions/setup-go@v3 with: - go-version: 1.21 + go-version: 1.22.0 - name: Release new version env: GH_TOKEN: ${{ github.token }} if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} - run: make --trace release + run: make --trace version-release - name: Publish new version env: GH_TOKEN: ${{ github.token }} if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} - run: make --trace publish || true + run: make --trace version-publish || true diff --git a/Makefile b/Makefile index 4521d17..e494fff 100644 --- a/Makefile +++ b/Makefile @@ -7,23 +7,16 @@ else $(warning warning: please customize variables in Makefile.vars) endif -# Setup desired go compiler environemt or defaults. +# Setup default go compiler environment. export GO ?= go -ifndef GOSETUP - export GOBIN ?= $(shell $(GO) env GOPATH)/bin -else ifeq ($(GOSETUP),local) - export GOBIN := $(DIR_BUILD)/bin - export PATH := $(GOBIN):$(PATH) -else - $(error error: unsupported go setup ($(GOSETUP))) -endif - +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/go-make@v0.0.43 +GOMAKE_DEP ?= github.com/tkrop/go-make@v0.0.58 # Request targets from go-make targets target. TARGETS := $(shell command -v $(GOBIN)/go-make >/dev/null || \ - go install $(GOMAKE_DEP) >/dev/stderr && \ - $(GOBIN)/go-make targets 2>/dev/null) + $(GO) install $(GOMAKE_DEP) >/dev/stderr && \ + $(GOBIN)/go-make show-targets 2>/dev/null) # Declare all targets phony to make them available for auto-completion. .PHONY:: $(TARGETS) diff --git a/Makefile.vars b/Makefile.vars index d144402..e41cd49 100644 --- a/Makefile.vars +++ b/Makefile.vars @@ -1,3 +1,9 @@ +# Setup default test timeout (default: 10s). +TEST_TIMEOUT := 12s +# 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 @@ -12,17 +18,8 @@ CODACY_API_BASE_URL := https://api.codacy.com #TEST_DEPS := run-db # Setup required targets before running commands (default: ). #RUN_DEPS := run-db -# Setup required aws services for testing (default: ). -#AWS_SERVICES := - -# Setup when to push images (default: pulls [never, pulls, merges]) -IMAGE_PUSH ?= never - -# Setup default test timeout (default: 10s). -TEST_TIMEOUT := 12s - -# Setup custom delivery file (default: delivery.yaml). -FILE_DELIVERY := .github/workflows/go.yaml +# Setup required aws services for testing (comma separated, default: ). +#AWS_SERVICES := sqs,s3 # Custom linters applied to prepare next level (default: ). LINTERS_CUSTOM := nonamedreturns gochecknoinits tagliatelle diff --git a/README.md b/README.md index 861526b..caf1611 100644 --- a/README.md +++ b/README.md @@ -238,12 +238,23 @@ versions for changes. ## Building -This project is using [go-make][go-make] for building, which provides default -implementations for most common tasks. Read the [go-make manual][go-make-man] -for more information about how to build, test, lint, etc. +This project is using [go-make][go-make], which provides default targets for +most common tasks, to initialize, build, test, and run the software of this +project. Read the [go-make manual][go-make-man] for more information about +targets and configuration options. + +**Not:** [go-make][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-`, +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. [go-make]: [go-make-man]: +[git-hooks]: +[convent-commit]: ## Contributing diff --git a/go.mod b/go.mod index 463fcfd..09c79a2 100644 --- a/go.mod +++ b/go.mod @@ -1,15 +1,13 @@ module github.com/tkrop/go-testing -go 1.21 - -toolchain go1.21.6 +go 1.22.0 require ( github.com/golang/mock v1.6.0 github.com/h2non/gock v1.2.0 github.com/huandu/go-clone v1.6.0 github.com/stretchr/testify v1.8.4 - golang.org/x/exp v0.0.0-20240119083558-1b970713d09a + golang.org/x/exp v0.0.0-20240205201215-2c58cdc269a3 golang.org/x/text v0.13.0 golang.org/x/tools v0.17.0 ) @@ -19,7 +17,7 @@ require ( github.com/h2non/parth v0.0.0-20190131123155-b4df798d6542 // indirect github.com/kr/pretty v0.3.1 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - golang.org/x/mod v0.14.0 // indirect + golang.org/x/mod v0.15.0 // indirect gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index 8ef38ef..a2ff363 100644 --- a/go.sum +++ b/go.sum @@ -33,11 +33,11 @@ github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXl github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/exp v0.0.0-20240119083558-1b970713d09a h1:Q8/wZp0KX97QFTc2ywcOE0YRjZPVIx+MXInMzdvQqcA= -golang.org/x/exp v0.0.0-20240119083558-1b970713d09a/go.mod h1:idGWGoKP1toJGkd5/ig9ZLuPcZBC3ewk7SzmH0uou08= +golang.org/x/exp v0.0.0-20240205201215-2c58cdc269a3 h1:/RIbNt/Zr7rVhIkQhooTxCxFcdWLGIKnZA4IXNFSrvo= +golang.org/x/exp v0.0.0-20240205201215-2c58cdc269a3/go.mod h1:idGWGoKP1toJGkd5/ig9ZLuPcZBC3ewk7SzmH0uou08= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.14.0 h1:dGoOF9QVLYng8IHTm7BAyWqCqSheQ5pYWGhzW00YJr0= -golang.org/x/mod v0.14.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= +golang.org/x/mod v0.15.0 h1:SernR4v+D55NyBH2QiEQrlBAnj1ECL6AGrA5+dPaMY8= +golang.org/x/mod v0.15.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=