-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
150 lines (124 loc) · 4.43 KB
/
Makefile
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
include ./Makefile.Common
GOCMD?= go
GOTEST=$(GOCMD) test
GO_ACC=go-acc
LINT=golangci-lint
IMPI=impi
GOOS := $(shell $(GOCMD) env GOOS)
GOARCH := $(shell $(GOCMD) env GOARCH)
GH := $(shell which gh)
ALL_MODULES := $(shell find . -type f -name "go.mod" -exec dirname {} \; | sort | egrep '^./' )
# All source code and documents. Used in spell check.
ALL_DOC := $(shell find . \( -name "*.md" -o -name "*.yaml" \) \
-type f | sort)
# Define a delegation target for each module
GOMODULES = $(ALL_MODULES)
.PHONY: $(GOMODULES)
$(GOMODULES):
@echo "Running target '$(TARGET)' in module '$@'"
$(MAKE) -C $@ $(TARGET)
# Triggers each module's delegation target
.PHONY: for-all-target
for-all-target: $(GOMODULES)
.PHONY: gotest
gotest:
@$(MAKE) for-all-target TARGET="test"
.PHONY: gomoddownload
gomoddownload:
@$(MAKE) for-all-target TARGET="moddownload"
.PHONY: golint
golint:
@$(MAKE) for-all-target TARGET="lint"
.PHONY: goimpi
goimpi:
@$(MAKE) for-all-target TARGET="impi"
.PHONY: gofmt
gofmt:
@$(MAKE) for-all-target TARGET="fmt"
.PHONY: misspell
misspell: $(MISSPELL)
$(MISSPELL) -error $(ALL_DOC)
.PHONY: misspell-correction
misspell-correction: $(MISSPELL)
$(MISSPELL) -w $(ALL_DOC)
.PHONY: crosslink
crosslink: $(CROSSLINK)
@echo "Executing crosslink"
$(CROSSLINK) --root=$(shell pwd) --prune
DEPENDABOT_PATH=".github/dependabot.yml"
.PHONY: internal-gendependabot
internal-gendependabot:
@echo "Add rule for \"${PACKAGE}\" in \"${DIR}\"";
@echo " - package-ecosystem: \"${PACKAGE}\"" >> ${DEPENDABOT_PATH};
@echo " directory: \"${DIR}\"" >> ${DEPENDABOT_PATH};
@echo " schedule:" >> ${DEPENDABOT_PATH};
@echo " interval: \"weekly\"" >> ${DEPENDABOT_PATH};
# This target should run on /bin/bash since the syntax DIR=$${dir:1} is not supported by /bin/sh.
.PHONY: gendependabot
gendependabot: $(eval SHELL:=/bin/bash)
@echo "Recreating ${DEPENDABOT_PATH} file"
@echo "# File generated by \"make gendependabot\"; DO NOT EDIT." > ${DEPENDABOT_PATH}
@echo "" >> ${DEPENDABOT_PATH}
@echo "version: 2" >> ${DEPENDABOT_PATH}
@echo "updates:" >> ${DEPENDABOT_PATH}
$(MAKE) internal-gendependabot DIR="/" PACKAGE="github-actions"
$(MAKE) internal-gendependabot DIR="/" PACKAGE="gomod"
@set -e; for dir in $(ALL_MODULES); do \
$(MAKE) internal-gendependabot DIR=$${dir:1} PACKAGE="gomod"; \
done
.PHONY: gotest-with-cover
gotest-with-cover: $(GOCOVMERGE)
@$(MAKE) for-all-target TARGET="test-with-cover"
$(GOCOVMERGE) $$(find . -name coverage.out) > coverage.txt
# Build the ocg executable.
.PHONY: ocg
ocg:
# pushd main/ && GO111MODULE=auto $(GOCMD) build -trimpath -o ../../bin/ocg_$(GOOS)_$(GOARCH) . && popd
pushd main && $(GOCMD) build -trimpath -o ../../bin/ocg_$(GOOS)_$(GOARCH) && popd
VERSIONYAML_PATH="./versions.yaml"
.PHONY: internal-genversionyml
internal-genversionyml:
@echo " - github/Chinwendu20/otel_components_generator${DIR}" >> ${VERSIONYAML_PATH};
# This target should run on /bin/bash since the syntax DIR=$${dir:1} is not supported by /bin/sh.
INCLUDE_MODULES := $(filter-out ./internal/tools, $(ALL_MODULES))
VERSION?="dev"
.PHONY: genversionyml
genversionyml: $(eval SHELL:=/bin/bash)
@echo "Recreating ${VERSIONYAML_PATH} file"
@echo "# File generated by \"make genversionyml\"; DO NOT EDIT." > ${VERSIONYAML_PATH}
@echo "" >> ${VERSIONYAML_PATH}
@echo "module-sets:" >> ${VERSIONYAML_PATH}
@echo " stable:" >> ${VERSIONYAML_PATH}
@echo " version:${VERSION}:" >> ${VERSIONYAML_PATH}
@echo " modules:" >> ${VERSIONYAML_PATH}
@set -e; for dir in $(INCLUDE_MODULES); do \
$(MAKE) internal-genversionyml DIR=$${dir:1}; \
done
@echo "">>${VERSIONYAML_PATH}
@echo "excluded-modules:" >>${VERSIONYAML_PATH}
@echo " - github/Chinwendu20/otel_components_generator/internal/tools" >>${VERSIONYAML_PATH};
.PHONY: multimod-verify
multimod-verify: $(MULTIMOD)
@echo "Validating versions.yaml"
$(MULTIMOD) verify
MODSET?=stable
.PHONY: multimod-prerelease
multimod-prerelease: $(MULTIMOD)
$(MULTIMOD) prerelease -s=true -b=false -v ./versions.yaml -m ${MODSET}
$(MAKE) gotidy
FILENAME?=$(shell git branch --show-current).yaml
.PHONY: chlog-new
chlog-new: $(CHLOG)
$(CHLOG) new --filename $(FILENAME)
.PHONY: chlog-validate
chlog-validate: $(CHLOG)
$(CHLOG) validate
.PHONY: chlog-preview
chlog-preview: $(CHLOG)
$(CHLOG) update --dry
.PHONY: chlog-update
chlog-update: $(CHLOG)
$(CHLOG) update --version $(VERSION)
.PHONY: gotidy
gotidy:
@$(MAKE) for-all-target TARGET="tidy"