Skip to content

Commit

Permalink
fix test action
Browse files Browse the repository at this point in the history
  • Loading branch information
shashankram committed Apr 2, 2024
1 parent 35f4452 commit cf2d5f4
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ jobs:
go-version: '1.22.x'

- name: Run tests
run: make gotest
run: make build-and-test
30 changes: 28 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@

all: build run

build-and-test: build gotest

ROOTDIR := $(shell pwd)
OUTPUTDIR = $(ROOTDIR)/_output
BINDIR = $(OUTPUTDIR)/.bin

.PHONY: install-deps
install-deps:
install-deps: install-protoc
mkdir -p $(BINDIR)
GOBIN=$(BINDIR) go install github.com/golang/protobuf/protoc-gen-go

Expand All @@ -25,7 +27,31 @@ run:
protoc --plugin=./$(BINDIR)/protoc-gen-openapi --openapi_out=single_file=true,use_ref=true:$(OUTPUTDIR)/. -Itestdata testdata/testpkg/test1.proto testdata/testpkg/test2.proto testdata/testpkg/test6.proto testdata/testpkg2/test3.proto

gotest:
go test -v ./...
PATH=$(BINDIR):$(PATH) go test -v ./...

PROTOC_VERSION:=3.15.8
PROTOC_URL:=https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOC_VERSION}/protoc-${PROTOC_VERSION}
.PHONY: install-protoc
install-protoc:
mkdir -p $(BINDIR)
if [ $(shell ${BINDIR}/protoc --version | grep -c ${PROTOC_VERSION}) -ne 0 ]; then \
echo expected protoc version ${PROTOC_VERSION} already installed ;\
else \
if [ "$(shell uname)" = "Darwin" ]; then \
echo "downloading protoc for osx" ;\
wget $(PROTOC_URL)-osx-x86_64.zip -O $(BINDIR)/protoc-${PROTOC_VERSION}.zip ;\
elif [ "$(shell uname -m)" = "aarch64" ]; then \
echo "downloading protoc for linux aarch64" ;\
wget $(PROTOC_URL)-linux-aarch_64.zip -O $(BINDIR)/protoc-${PROTOC_VERSION}.zip ;\
else \
echo "downloading protoc for linux x86-64" ;\
wget $(PROTOC_URL)-linux-x86_64.zip -O $(BINDIR)/protoc-${PROTOC_VERSION}.zip ;\
fi ;\
unzip $(BINDIR)/protoc-${PROTOC_VERSION}.zip -d $(BINDIR)/protoc-${PROTOC_VERSION} ;\
mv $(BINDIR)/protoc-${PROTOC_VERSION}/bin/protoc $(BINDIR)/protoc ;\
chmod +x $(BINDIR)/protoc ;\
rm -rf $(BINDIR)/protoc-${PROTOC_VERSION} $(BINDIR)/protoc-${PROTOC_VERSION}.zip ;\
fi

clean:
@rm -fr $(OUTPUTDIR) $(BINDIR)/protoc-gen-openapi

0 comments on commit cf2d5f4

Please sign in to comment.