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: Add ginkgo-install and add binary gen for necessary targets #199

Merged
merged 1 commit into from
Apr 8, 2024
Merged
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
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/ginkgo@v2.1.3

- name: Setup Goimports
run: go install golang.org/x/tools/cmd/goimports@v0.0.0-20200518194103-259583f2d8a9

- 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/ginkgo@v2.1.3

.PHONY: goimports_install
goimports_install:
@GOBIN=$(LOCAL_BIN_PATH) go install golang.org/x/tools/cmd/goimports@v0.0.0-20200518194103-259583f2d8a9

.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)
Loading