From cf2d5f46d7645d2b8b8e49bc2489e8d23485a6b6 Mon Sep 17 00:00:00 2001 From: Shashank Ram Date: Tue, 2 Apr 2024 10:09:28 -0700 Subject: [PATCH] fix test action --- .github/workflows/test.yaml | 2 +- Makefile | 30 ++++++++++++++++++++++++++++-- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index dbb1dae..71c5714 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -18,4 +18,4 @@ jobs: go-version: '1.22.x' - name: Run tests - run: make gotest + run: make build-and-test diff --git a/Makefile b/Makefile index 86a154f..312f07c 100644 --- a/Makefile +++ b/Makefile @@ -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 @@ -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