Skip to content

Commit 4ab9551

Browse files
Mikalai Radchukm1kola
authored andcommitted
Adds makefile for common dev tasks
Signed-off-by: Mikalai Radchuk <[email protected]>
1 parent 55aecef commit 4ab9551

File tree

10 files changed

+1166
-14
lines changed

10 files changed

+1166
-14
lines changed

.bingo/.gitignore

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
2+
# Ignore everything
3+
*
4+
5+
# But not these files:
6+
!.gitignore
7+
!*.mod
8+
!*.sum
9+
!README.md
10+
!Variables.mk
11+
!variables.env
12+
13+
*tmp.mod

.bingo/README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Project Development Dependencies.
2+
3+
This is directory which stores Go modules with pinned buildable package that is used within this repository, managed by https://github.com/bwplotka/bingo.
4+
5+
* Run `bingo get` to install all tools having each own module file in this directory.
6+
* Run `bingo get <tool>` to install <tool> that have own module file in this directory.
7+
* For Makefile: Make sure to put `include .bingo/Variables.mk` in your Makefile, then use $(<upper case tool name>) variable where <tool> is the .bingo/<tool>.mod.
8+
* For shell: Run `source .bingo/variables.env` to source all environment variable for each tool.
9+
* For go: Import `.bingo/variables.go` to for variable names.
10+
* See https://github.com/bwplotka/bingo or -h on how to add, remove or change binaries dependencies.
11+
12+
## Requirements
13+
14+
* Go 1.14+

.bingo/Variables.mk

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Auto generated binary variables helper managed by https://github.com/bwplotka/bingo v0.8. DO NOT EDIT.
2+
# All tools are designed to be build inside $GOBIN.
3+
BINGO_DIR := $(dir $(lastword $(MAKEFILE_LIST)))
4+
GOPATH ?= $(shell go env GOPATH)
5+
GOBIN ?= $(firstword $(subst :, ,${GOPATH}))/bin
6+
GO ?= $(shell which go)
7+
8+
# Below generated variables ensure that every time a tool under each variable is invoked, the correct version
9+
# will be used; reinstalling only if needed.
10+
# For example for hugo variable:
11+
#
12+
# In your main Makefile (for non array binaries):
13+
#
14+
#include .bingo/Variables.mk # Assuming -dir was set to .bingo .
15+
#
16+
#command: $(HUGO)
17+
# @echo "Running hugo"
18+
# @$(HUGO) <flags/args..>
19+
#
20+
HUGO := $(GOBIN)/hugo-v0.111.1
21+
$(HUGO): $(BINGO_DIR)/hugo.mod
22+
@# Install binary/ries using Go 1.14+ build command. This is using bwplotka/bingo-controlled, separate go module with pinned dependencies.
23+
@echo "(re)installing $(GOBIN)/hugo-v0.111.1"
24+
@cd $(BINGO_DIR) && GOWORK=off CGO_ENABLED=1 $(GO) build -tags=extended -mod=mod -modfile=hugo.mod -o=$(GOBIN)/hugo-v0.111.1 "github.com/gohugoio/hugo"
25+

.bingo/go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module _ // Fake go.mod auto-created by 'bingo' for go -moddir compatibility with non-Go projects. Commit this file, together with other .mod files.

.bingo/hugo.mod

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module _ // Auto generated by https://github.com/bwplotka/bingo. DO NOT EDIT
2+
3+
go 1.20
4+
5+
require github.com/gohugoio/hugo v0.111.1 // CGO_ENABLED=1 -tags=extended

.bingo/hugo.sum

Lines changed: 1045 additions & 0 deletions
Large diffs are not rendered by default.

.bingo/variables.env

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Auto generated binary variables helper managed by https://github.com/bwplotka/bingo v0.8. DO NOT EDIT.
2+
# All tools are designed to be build inside $GOBIN.
3+
# Those variables will work only until 'bingo get' was invoked, or if tools were installed via Makefile's Variables.mk.
4+
GOBIN=${GOBIN:=$(go env GOBIN)}
5+
6+
if [ -z "$GOBIN" ]; then
7+
GOBIN="$(go env GOPATH)/bin"
8+
fi
9+
10+
11+
HUGO="${GOBIN}/hugo-v0.111.1"
12+

.github/workflows/lint.yaml

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,14 @@ on: pull_request
44
jobs:
55
lint:
66
runs-on: ubuntu-latest
7-
env:
8-
HUGO_VERSION: 0.111.1
9-
HUGO_ENV: production
107
steps:
11-
- name: Install Hugo CLI
12-
run: |
13-
wget -O ${{ runner.temp }}/hugo.deb https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_linux-amd64.deb \
14-
&& sudo dpkg -i ${{ runner.temp }}/hugo.deb
158
- name: Checkout
169
uses: actions/checkout@v3
17-
- name: Install Node.js dependencies
18-
run: npm ci
19-
- name: Build with Hugo
20-
run: hugo
21-
- name: Run linting script
22-
run: ${PWD}/hack/ci/link-check.sh
10+
- uses: actions/setup-go@v4
11+
with:
12+
go-version-file: go.mod
13+
cache-dependency-path: |
14+
go.sum
15+
.bingo/**.sum
16+
- name: Build and lint the site
17+
run: make lint

Makefile

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# bingo manages consistent tooling versions for things like kind, kustomize, etc.
2+
include .bingo/Variables.mk
3+
4+
CONTAINER_ENGINE ?= docker
5+
6+
.DEFAULT_GOAL := build
7+
8+
##@ General
9+
10+
# The help target prints out all targets with their descriptions organized
11+
# beneath their categories. The categories are represented by '##@' and the
12+
# target descriptions by '##'. The awk commands is responsible for reading the
13+
# entire set of makefiles included in this invocation, looking for lines of the
14+
# file as xyz: ## something, and then pretty-format the target and help. Then,
15+
# if there's a line with ##@ something, that gets pretty-printed as a category.
16+
# More info on the usage of ANSI control characters for terminal formatting:
17+
# https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_parameters
18+
# More info on the awk command:
19+
# http://linuxcommand.org/lc3_adv_awk.php
20+
21+
.PHONY: help
22+
help: ## Display this help.
23+
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
24+
25+
##@ Development
26+
27+
node_modules: package.json package-lock.json
28+
npm ci
29+
30+
.PHONY: build
31+
build: $(HUGO) node_modules ## Build the site.
32+
HUGO_ENV=production $(HUGO)
33+
34+
.PHONY: serve
35+
serve: $(HUGO) ## Build and serves the site locally.
36+
$(HUGO) serve
37+
38+
.PHONY: lint
39+
lint: build ## Run docs linting.
40+
CONTAINER_ENGINE="$(CONTAINER_ENGINE)" \
41+
CONTAINER_RUN_EXTRA_OPTIONS="$(CONTAINER_RUN_EXTRA_OPTIONS)" \
42+
./hack/ci/link-check.sh

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module github.com/operator-framework/olm-docs
22

3-
go 1.19
3+
go 1.20
44

55
require github.com/google/docsy v0.6.0 // indirect

0 commit comments

Comments
 (0)