Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update makefile with the local bin installs #826

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)