diff --git a/.github/workflows/check-pull-request.yaml b/.github/workflows/check-pull-request.yaml index 87c413612..281d4b9f7 100644 --- a/.github/workflows/check-pull-request.yaml +++ b/.github/workflows/check-pull-request.yaml @@ -78,9 +78,6 @@ jobs: with: go-version: '1.20' - - name: Setup Goimports - run: go install golang.org/x/tools/cmd/goimports@v0.4.0 - - name: Generate code run: make generate diff --git a/.gitignore b/.gitignore index e3e0dc30d..7e15990dd 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,6 @@ !/examples/*.yaml !/examples/go.mod !/examples/go.sum + +# local bin directory +/bin diff --git a/Makefile b/Makefile index 8beafb920..2f5409d05 100644 --- a/Makefile +++ b/Makefile @@ -13,6 +13,15 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# +# +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 the tasks to use project-level bin directory binaries first +export PATH := $(LOCAL_BIN_PATH):$(PATH) # Disable CGO so that we always generate static binaries: export CGO_ENABLED=0 @@ -24,6 +33,8 @@ model_url:=https://github.com/openshift-online/ocm-api-model.git # Details of the metamodel to use: metamodel_version:=v0.0.59 +goimports_version:=v0.4.0 + # 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. @@ -50,7 +61,7 @@ lint: golangci-lint run .PHONY: generate -generate: model metamodel +generate: model metamodel-install goimports-install rm -rf \ accountsmgmt \ addonsmgmt \ @@ -65,11 +76,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 @@ -86,8 +97,13 @@ model: fi .PHONY: metamodel -metamodel: - go install github.com/openshift-online/ocm-api-metamodel/cmd/metamodel@$(metamodel_version) +METAMODEL=$(LOCAL_BIN_PATH)/metamodel +metamodel-install: + GOBIN=$(LOCAL_BIN_PATH) go install github.com/openshift-online/ocm-api-metamodel/cmd/metamodel@$(metamodel_version) + +.PHONY: goimports +goimports-install: + @GOBIN=$(LOCAL_BIN_PATH) go install golang.org/x/tools/cmd/goimports@$(goimports_version) .PHONY: clean clean: