Skip to content

Commit ebb07d6

Browse files
committed
Update makefile with the local bin installs
Signed-off-by: Martin Necas <[email protected]>
1 parent b97ef18 commit ebb07d6

File tree

3 files changed

+28
-11
lines changed

3 files changed

+28
-11
lines changed

.github/workflows/check-pull-request.yaml

-3
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,6 @@ jobs:
7878
with:
7979
go-version: '1.20'
8080

81-
- name: Setup Goimports
82-
run: go install golang.org/x/tools/cmd/[email protected]
83-
8481
- name: Generate code
8582
run: make generate
8683

.gitignore

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22
/.idea/
33
/.vscode/
44
/examples/*
5-
/metamodel
65
/model/
76
/vendor/
87
!/examples/*.go
98
!/examples/*.yaml
109
!/examples/go.mod
1110
!/examples/go.sum
11+
12+
# Local bin directory
13+
bin

Makefile

+25-7
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,15 @@ model_url:=https://github.com/openshift-online/ocm-api-model.git
2424
# Details of the metamodel to use:
2525
metamodel_version:=v0.0.59
2626

27+
MKFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST)))
28+
PROJECT_PATH := $(patsubst %/,%,$(dir $(MKFILE_PATH)))
29+
LOCAL_BIN_PATH := $(PROJECT_PATH)/bin
30+
# Add the project-level bin directory into PATH. Needed in order
31+
# for `go generate` to use project-level bin directory binaries first
32+
export PATH := $(LOCAL_BIN_PATH):$(PATH)
33+
GINKGO := $(LOCAL_BIN_PATH)/ginkgo
34+
METAMODEL := $(LOCAL_BIN_PATH)/metamodel
35+
2736
# Additional flags to pass to the `ginkgo` command. This is used in the GitHub
2837
# actions environment to skip tests that are sensitive to the speed of the
2938
# machine: the leadership flag and retry tests.
@@ -36,9 +45,18 @@ examples:
3645
go build $${i} || exit 1; \
3746
done
3847

48+
.PHONY: ginkgo-install
49+
ginkgo-install:
50+
@GOBIN=$(LOCAL_BIN_PATH) go install github.com/onsi/ginkgo/v2/[email protected]
51+
52+
# Needed for the golang metamodel generator.
53+
.PHONY: goimports-install
54+
goimports-install:
55+
@GOBIN=$(LOCAL_BIN_PATH) go install golang.org/x/tools/cmd/[email protected]
56+
3957
.PHONY: test tests
40-
test tests:
41-
ginkgo run -r $(ginkgo_flags)
58+
test tests: ginkgo-install
59+
$(GINKGO) run -r $(ginkgo_flags)
4260

4361
.PHONY: fmt
4462
fmt:
@@ -50,7 +68,7 @@ lint:
5068
golangci-lint run
5169

5270
.PHONY: generate
53-
generate: model metamodel
71+
generate: model metamodel goimports-install
5472
rm -rf \
5573
accountsmgmt \
5674
addonsmgmt \
@@ -65,11 +83,11 @@ generate: model metamodel
6583
webrca \
6684
osdfleetmgmt \
6785
openapi
68-
metamodel generate go \
86+
$(METAMODEL) generate go \
6987
--model=model/model \
7088
--base=github.com/openshift-online/ocm-sdk-go \
7189
--output=.
72-
metamodel generate openapi \
90+
$(METAMODEL) generate openapi \
7391
--model=model/model \
7492
--output=openapi
7593

@@ -87,11 +105,11 @@ model:
87105

88106
.PHONY: metamodel
89107
metamodel:
90-
go install github.com/openshift-online/ocm-api-metamodel/cmd/metamodel@$(metamodel_version)
108+
@GOBIN=$(LOCAL_BIN_PATH) go install github.com/openshift-online/ocm-api-metamodel/cmd/metamodel@$(metamodel_version)
91109

92110
.PHONY: clean
93111
clean:
94112
rm -rf \
95-
metamodel \
113+
bin \
96114
model \
97115
$(NULL)

0 commit comments

Comments
 (0)