Skip to content

Commit

Permalink
feat: improve init (#119)
Browse files Browse the repository at this point in the history
Signed-off-by: Tronje Krop <[email protected]>
  • Loading branch information
tkrop committed Jan 15, 2025
1 parent 0bad606 commit 79c36d5
Show file tree
Hide file tree
Showing 14 changed files with 155 additions and 105 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: 1.23.3
go-version: 1.23.4
cache: false

- name: Checkout code
Expand All @@ -32,7 +32,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: 1.23.3
go-version: 1.23.4

- name: Setup Npm
uses: pnpm/action-setup@v4
Expand All @@ -57,7 +57,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: 1.23.3
go-version: 1.23.4

- name: Setup Npm
uses: pnpm/action-setup@v4
Expand All @@ -79,7 +79,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: 1.23.3
go-version: 1.23.4

- name: Checkout code
uses: actions/checkout@v4
Expand All @@ -101,7 +101,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: 1.23.3
go-version: 1.23.4

- name: Checkout code
uses: actions/checkout@v4
Expand All @@ -124,7 +124,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: 1.23.3
go-version: 1.23.4

- name: Checkout code
uses: actions/checkout@v4
Expand Down
8 changes: 5 additions & 3 deletions MANUAL.md
Original file line number Diff line number Diff line change
Expand Up @@ -561,12 +561,14 @@ need to call them manually.


```bash
make init # short cut for 'init-tools init-hooks init-codacy'
make init-hooks # initializes github hooks for pre-commit, etc
make init # short cut for 'init-git init-hooks init-go init-make'
make init-go # initializes go project files
make init-git # initializes git resource revision control
make init-hooks # initializes git hooks for pre-commit, etc
make init-codacy # initializes tools for running the codacy targets
make init-code # initializes code by generating mocks and kube-apis
make init-make # initializes project by copying template files
make init-make! # copies Makefile.base from the template
make init-make! # initializes Makefile to contain a copy of Makefile.base
```

The `init-make` targets support a `<version>` argument to install the config
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 GOPATH ?= $(shell $(GO) env GOPATH)
export GOBIN ?= $(GOPATH)/bin

# Setup go-make version to use desired build and config scripts.
GOMAKE_DEP ?= github.com/tkrop/[email protected].115
GOMAKE_DEP ?= github.com/tkrop/[email protected].116
INSTALL_FLAGS ?= -mod=readonly -buildvcs=auto
# Request targets from go-make targets target.
TARGETS := $(shell command -v $(GOBIN)/go-make >/dev/null || \
Expand Down
4 changes: 2 additions & 2 deletions Makefile.vars
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Setup default test timeout (default: 10s).
TEST_TIMEOUT := 25s
TEST_TIMEOUT := 30s
# 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]).
Expand Down Expand Up @@ -27,4 +27,4 @@ LINTERS_CUSTOM := nonamedreturns tagliatelle
LINTERS_DISABLED :=

# Customize the build pipeline (default: init test lint build image).
TARGETS_ALL := git-verify init test lint build image
TARGETS_ALL := git-verify init-hooks test lint build image
17 changes: 14 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ satisfied by the runtime environment, e.g. using [`ubuntu-20.04`][ubuntu-20.04],
* [`curl`][curl] (^7)

**Note:** Since [`MacOSX`][mac-osx] comes with heavily outdated GNU tools,
[`go-make`][go-make] is ensures that these are available in recent verions
[`go-make`][go-make] is ensures that these are available in recent versions
using the [`brew`][brew] package manager. As a consequence it only requires
[`go`][go] and [GNU `make`] in a decent version that is usually satisfied by
the standard MacOS installation.
Expand All @@ -139,6 +139,7 @@ config script:
go-make all # execute a whole build pipeline depending on the project.
go-make test lint # execute only test 'test' and 'lint' steps of a pipeline.
go-make image # execute minimal steps to create all container images.
go-make init # initialize a new go-make project from scratch.
```

For further examples see [`go-make` manual](MANUAL.md).
Expand Down Expand Up @@ -210,6 +211,11 @@ is following the [conventional commit][convent-commit] best practice.

## Shell integration

For being able to efficiently work with `go-make` a proper shell integration is
important. Most linux systems come with a good sell integration that supports
auto-completion for `make` showing the targets provided via the wrapper
`Makefile`. However, the vanilla MacOS has its limits.

To set up command completion for [`go-make`][go-make], add the following
snippet to your [`.bashrc`][bashrc].

Expand Down Expand Up @@ -251,8 +257,9 @@ following conventions:
are used by [`go-make`][go-make] as temporary folders to build commands and
run commands and are cleaned up regularly.

4. The build target provides build context values to set up global variables in
`main` and `config` packages.
4. The `build` target creates an extended build context that is provisioned via
the ldflag `-X` and can be accessed providing the following variables in
the `main` package:

* `Path` - the formal package path of the command build.
* `Version` - the version as provided by the `VERSION`-file in project root
Expand Down Expand Up @@ -292,6 +299,10 @@ go install github.com/tkrop/go-make@latest; go-make update;
If the latest version is not fixed yet, you can also try to move backward
finding the last working [tagged version](../../tags).

**Note:** After updating a project to the latest version you may need to
cleanup the installed tools using `make clean-all` before the new tool
version are automatically supported correctly.


## Building

Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.0.115
0.0.116
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 GOPATH ?= $(shell $(GO) env GOPATH)
export GOBIN ?= $(GOPATH)/bin

# Setup go-make version to use desired build and config scripts.
GOMAKE_DEP ?= github.com/tkrop/[email protected].115
GOMAKE_DEP ?= github.com/tkrop/[email protected].116
INSTALL_FLAGS ?= -mod=readonly -buildvcs=auto
# Request targets from go-make targets target.
TARGETS := $(shell command -v $(GOBIN)/go-make >/dev/null || \
Expand Down
Loading

0 comments on commit 79c36d5

Please sign in to comment.