Skip to content

Commit

Permalink
Update makefile with the local bin installs
Browse files Browse the repository at this point in the history
Signed-off-by: Martin Necas <[email protected]>
  • Loading branch information
mnecas committed Aug 25, 2023
1 parent b97ef18 commit ebb07d6
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 11 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/check-pull-request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,6 @@ jobs:
with:
go-version: '1.20'

- name: Setup Goimports
run: go install golang.org/x/tools/cmd/[email protected]

- name: Generate code
run: make generate

Expand Down
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
/.idea/
/.vscode/
/examples/*
/metamodel
/model/
/vendor/
!/examples/*.go
!/examples/*.yaml
!/examples/go.mod
!/examples/go.sum

# Local bin directory
bin
32 changes: 25 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,15 @@ model_url:=https://github.com/openshift-online/ocm-api-model.git
# Details of the metamodel to use:
metamodel_version:=v0.0.59

MKFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST)))
PROJECT_PATH := $(patsubst %/,%,$(dir $(MKFILE_PATH)))
LOCAL_BIN_PATH := $(PROJECT_PATH)/bin
# Add the project-level bin directory into PATH. Needed in order
# for `go generate` to use project-level bin directory binaries first
export PATH := $(LOCAL_BIN_PATH):$(PATH)
GINKGO := $(LOCAL_BIN_PATH)/ginkgo
METAMODEL := $(LOCAL_BIN_PATH)/metamodel

# Additional flags to pass to the `ginkgo` command. This is used in the GitHub
# actions environment to skip tests that are sensitive to the speed of the
# machine: the leadership flag and retry tests.
Expand All @@ -36,9 +45,18 @@ examples:
go build $${i} || exit 1; \
done

.PHONY: ginkgo-install
ginkgo-install:
@GOBIN=$(LOCAL_BIN_PATH) go install github.com/onsi/ginkgo/v2/[email protected]

# Needed for the golang metamodel generator.
.PHONY: goimports-install
goimports-install:
@GOBIN=$(LOCAL_BIN_PATH) go install golang.org/x/tools/cmd/[email protected]

.PHONY: test tests
test tests:
ginkgo run -r $(ginkgo_flags)
test tests: ginkgo-install
$(GINKGO) run -r $(ginkgo_flags)

.PHONY: fmt
fmt:
Expand All @@ -50,7 +68,7 @@ lint:
golangci-lint run

.PHONY: generate
generate: model metamodel
generate: model metamodel goimports-install
rm -rf \
accountsmgmt \
addonsmgmt \
Expand All @@ -65,11 +83,11 @@ generate: model metamodel
webrca \
osdfleetmgmt \
openapi
metamodel generate go \
$(METAMODEL) generate go \
--model=model/model \
--base=github.com/openshift-online/ocm-sdk-go \
--output=.
metamodel generate openapi \
$(METAMODEL) generate openapi \
--model=model/model \
--output=openapi

Expand All @@ -87,11 +105,11 @@ model:

.PHONY: metamodel
metamodel:
go install github.com/openshift-online/ocm-api-metamodel/cmd/metamodel@$(metamodel_version)
@GOBIN=$(LOCAL_BIN_PATH) go install github.com/openshift-online/ocm-api-metamodel/cmd/metamodel@$(metamodel_version)

.PHONY: clean
clean:
rm -rf \
metamodel \
bin \
model \
$(NULL)

0 comments on commit ebb07d6

Please sign in to comment.