-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
95 lines (79 loc) · 3.68 KB
/
Makefile
File metadata and controls
95 lines (79 loc) · 3.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
SHELL = bash
# Current git branch
BRANCH := $(shell git rev-parse --abbrev-ref HEAD)
# Current git commit hash
GIT_COMMIT_HASH := $(shell git show --no-patch --no-notes --pretty='%h' HEAD)
# Current git tag
GIT_TAG := $(shell git describe --tags --exact-match 2>/dev/null || echo "")
ifeq ($(GIT_TAG),)
VERSION := $(BRANCH).$(GIT_COMMIT_HASH)
else
VERSION := $(GIT_TAG)
endif
ifeq ($(shell git status --porcelain),)
DIRTY :=
else
VERSION := $(BRANCH).$(GIT_COMMIT_HASH)
DIRTY := "dev"
endif
LDFLAGS=--ldflags "-s -X github.com/SwissDataScienceCenter/renku-dev-utils/pkg/version.Version=$(VERSION) -X github.com/SwissDataScienceCenter/renku-dev-utils/pkg/version.VersionSuffix=$(DIRTY)"
.PHONY: all
all: help
.PHONY: vars
vars: ## Show the Makefile vars
@echo SHELL="'$(SHELL)'"
@echo BRANCH="'$(BRANCH)'"
@echo GIT_COMMIT_HASH="'$(GIT_COMMIT_HASH)'"
@echo GIT_TAG="'$(GIT_TAG)'"
@echo VERSION="'$(VERSION)'"
@echo DIRTY="'$(DIRTY)'"
.PHONY: rdu
rdu: build/renku-dev-utils ## Build and install renku-dev-utils
mkdir -p `go env GOPATH`/bin/
cp -av build/renku-dev-utils`go env GOEXE` `go env GOPATH`/bin/rdu`go env GOEXE`.new
mv -v `go env GOPATH`/bin/rdu`go env GOEXE`.new `go env GOPATH`/bin/rdu`go env GOEXE`
.PHONY: build/renku-dev-utils
build/renku-dev-utils:
go build -v -o build/ $(LDFLAGS)
# From the operator sdk Makefile
# The help target prints out all targets with their descriptions organized
# beneath their categories. The categories are represented by '##@' and the
# target descriptions by '##'. The awk command is responsible for reading the
# entire set of makefiles included in this invocation, looking for lines of the
# file as xyz: ## something, and then pretty-format the target and help. Then,
# if there's a line with ##@ something, that gets pretty-printed as a category.
# More info on the usage of ANSI control characters for terminal formatting:
# https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_parameters
# More info on the awk command:
# http://linuxcommand.org/lc3_adv_awk.php
.PHONY: help
help: ## Display this help.
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-25s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
##@ Development
.PHONY: format
format: ## Format source files
gofmt -l -w .
.PHONY: check-format
check-format: ## Check that sources are correctly formatted
gofmt -d -s . && git diff --exit-code
.PHONY: check-vet
check-vet: ## Check source files with `go vet`
go vet ./...
.PHONY: lint
lint: ## Lint source files with `golangci-lint run`
golangci-lint run
##@ Code generation
.PHONY: renku-users-apispec
renku-users-apispec: ## Download the "users" API spec
curl -L -o pkg/renkuapi/users/api.spec.yaml https://raw.githubusercontent.com/SwissDataScienceCenter/renku-data-services/refs/heads/main/components/renku_data_services/users/api.spec.yaml
sed -e 's/- default: "general"//g' pkg/renkuapi/users/api.spec.yaml > pkg/renkuapi/users/api.spec.new.yaml
mv pkg/renkuapi/users/api.spec.new.yaml pkg/renkuapi/users/api.spec.yaml
.PHONY: renku-session-apispec
renku-session-apispec: ## Download the "session" API spec
curl -L -o pkg/renkuapi/session/api.spec.yaml https://raw.githubusercontent.com/SwissDataScienceCenter/renku-data-services/refs/heads/main/components/renku_data_services/session/api.spec.yaml
.PHONY: generate
generate: pkg/renkuapi/users/users_gen.go pkg/renkuapi/session/session_gen.go ## Run go generate
pkg/renkuapi/users/users_gen.go: pkg/renkuapi/users/api.spec.yaml
go generate pkg/renkuapi/users/users.go
pkg/renkuapi/session/session_gen.go: pkg/renkuapi/session/api.spec.yaml
go generate pkg/renkuapi/session/session.go