Skip to content

Commit

Permalink
Merge pull request #199 from mnecas/update_makefile
Browse files Browse the repository at this point in the history
Update makefile: Add ginkgo-install and add binary gen for necessary targets
  • Loading branch information
mnecas authored Apr 8, 2024
2 parents 093350d + a43b04c commit 9a8e01b
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 13 deletions.
6 changes: 0 additions & 6 deletions .github/workflows/check-pull-request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,5 @@ jobs:
with:
go-version: 1.17

- name: Setup Ginkgo
run: go install github.com/onsi/ginkgo/v2/[email protected]

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

- name: Run the tests
run: make tests
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@
/model/
/openapi_generator
/tests/*/generated/

# Local bin directory
bin
30 changes: 23 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@
# Disable CGO so that we always generate static binaries:
export CGO_ENABLED=0

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

# Details of the version of 'antlr' to use:
antlr_version:=4.9.3
antlr_url:=https://www.antlr.org/download/antlr-$(antlr_version)-complete.jar
Expand All @@ -43,6 +51,14 @@ antlr:
wget --progress=dot:giga --output-document="$@" "$(antlr_url)"
echo "$(antlr_sum) $@" | sha256sum --check

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

.PHONY: goimports_install
goimports_install:
@GOBIN=$(LOCAL_BIN_PATH) go install golang.org/x/tools/cmd/[email protected]

.PHONY: fmt
fmt:
gofmt -s -l -w \
Expand All @@ -59,20 +75,20 @@ test tests:
$(MAKE) docs_tests

.PHONY: unit_tests
unit_tests:
ginkgo -r pkg
unit_tests: ginkgo_install
$(GINKGO) -r pkg

.PHONY: golang_tests
go_tests: binary
go_tests: binary ginkgo_install goimports_install
rm -rf tests/go/generated
./metamodel generate go \
--model=tests/model \
--base=github.com/openshift-online/ocm-api-metamodel/tests/go/generated \
--output=tests/go/generated
cd tests/go && ginkgo -r
cd tests/go && $(GINKGO) -r

.PHONY: openapi_tests
openapi_tests: openapi_generator
openapi_tests: openapi_generator binary
rm -rf tests/openapi/generated
./metamodel generate openapi --model=tests/model --output=tests/openapi/generated
for spec in $$(find tests/openapi -name '*.json'); do \
Expand All @@ -84,7 +100,7 @@ openapi_generator:
echo "$(openapi_generator_sum) $@" | sha256sum --check

.PHONY: docs_tests
docs_tests:
docs_tests: binary
rm -rf tests/docs/generated
./metamodel generate docs --model=tests/model --output=tests/docs/generated

Expand All @@ -93,8 +109,8 @@ clean:
rm -rf \
.gobin \
antlr \
metamodel \
model \
bin \
openapi_generator \
tests/*/generated \
$(NULL)

0 comments on commit 9a8e01b

Please sign in to comment.