Skip to content

Commit

Permalink
Merge pull request #850 from miguelsorianod/tools-projectlevel-install
Browse files Browse the repository at this point in the history
feat: install and use tools at project scope level
  • Loading branch information
tzvatot authored Oct 16, 2023
2 parents e4fd724 + 932b44c commit 8e0a745
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 8 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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@
!/examples/*.yaml
!/examples/go.mod
!/examples/go.sum

# local bin directory
/bin
26 changes: 21 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
Expand All @@ -50,7 +61,7 @@ lint:
golangci-lint run

.PHONY: generate
generate: model metamodel
generate: model metamodel-install goimports-install
rm -rf \
accountsmgmt \
addonsmgmt \
Expand All @@ -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

Expand All @@ -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:
Expand Down

0 comments on commit 8e0a745

Please sign in to comment.