From 99a30d2437112125ee897a32ae966e5b3d4198de Mon Sep 17 00:00:00 2001 From: Derek McGowan Date: Thu, 3 Mar 2022 17:15:48 -0800 Subject: [PATCH] Update github actions ci to use Makefile Signed-off-by: Derek McGowan --- .github/workflows/ci.yml | 31 +++++++++++-------------------- Makefile | 25 ++++++++++++++++--------- 2 files changed, 27 insertions(+), 29 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b650f0c..71c925e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -84,12 +84,12 @@ jobs: - name: Test working-directory: src/github.com/containerd/ttrpc run: | - go test -v -race -coverprofile=coverage_txt -covermode=atomic ./... + make coverage TESTFLAGS_RACE=-race - name: Code Coverage uses: codecov/codecov-action@v2 with: - files: coverage_txt + files: coverage.txt if: matrix.os == 'ubuntu-latest' # @@ -119,27 +119,18 @@ jobs: path: src/github.com/containerd/ttrpc fetch-depth: 25 - - name: Install protoc - run: | - curl -LO https://github.com/protocolbuffers/protobuf/releases/download/v3.5.0/protoc-3.5.0-linux-x86_64.zip - sudo unzip -x protoc-3.5.0-linux-x86_64.zip -d /usr/local - sudo chmod -R go+rX /usr/local/include - sudo chmod go+x /usr/local/bin/protoc - - - name: Install protoc-gen-go - run: | - go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.27.1 - - - name: Build protoc-gen-go-ttrpc + - name: Install dependencies working-directory: src/github.com/containerd/ttrpc run: | - go build ./cmd/protoc-gen-go-ttrpc + sudo make install-protobuf + make install-protobuild + + - name: Install protoc-gen-go-ttrpc + working-directory: src/github.com/containerd/ttrpc + run: | + make install - name: Run Protobuild working-directory: src/github.com/containerd/ttrpc run: | - export PATH=$GOPATH/bin:$PWD:$PATH - go install github.com/containerd/protobuild@7e5ee24bc1f70e9e289fef15e2631eb3491320bf - protobuild - (cd example && protobuild) - git diff --exit-code + make check-protos diff --git a/Makefile b/Makefile index 9005621..3a4ec95 100644 --- a/Makefile +++ b/Makefile @@ -33,7 +33,8 @@ GO_BUILDTAGS ?= GO_TAGS=$(if $(GO_BUILDTAGS),-tags "$(strip $(GO_BUILDTAGS))",) # Project packages. -PACKAGES=$(shell $(GO) list ${GO_TAGS} ./... | grep -v /integration | grep -v /example) +PACKAGES=$(shell $(GO) list ${GO_TAGS} ./... | grep -v /example) +TESTPACKAGES=$(shell $(GO) list ${GO_TAGS} ./... | grep -v /cmd | grep -v /integration | grep -v /example) BINPACKAGES=$(addprefix ./cmd/,$(COMMANDS)) #Replaces ":" (*nix), ";" (windows) with newline for easy parsing @@ -56,7 +57,7 @@ TESTFLAGS_PARALLEL ?= 8 # Use this to replace `go test` with, for instance, `gotestsum` GOTEST ?= $(GO) test -.PHONY: clean all AUTHORS build binaries test integration generate protos checkprotos coverage ci check help install vendor install-deps +.PHONY: clean all AUTHORS build binaries test integration generate protos checkprotos coverage ci check help install vendor install-protobuf install-protobuild .DEFAULT: default # Forcibly set the default goal to all, in case an include above brought in a rule definition. @@ -106,11 +107,11 @@ build: ## build the go packages test: ## run tests, except integration tests and tests that require root @echo "$(WHALE) $@" - @$(GOTEST) ${TESTFLAGS} ${PACKAGES} + @$(GOTEST) ${TESTFLAGS} ${TESTPACKAGES} -#integration: ## run integration tests -# @echo "$(WHALE) $@" -# @cd "${ROOTDIR}/integration" && $(GO) mod download && $(GOTEST) -v ${TESTFLAGS} -parallel ${TESTFLAGS_PARALLEL} . +integration: ## run integration tests + @echo "$(WHALE) $@" + @cd "${ROOTDIR}/integration" && $(GOTEST) -v ${TESTFLAGS} -parallel ${TESTFLAGS_PARALLEL} . benchmark: ## run benchmarks tests @echo "$(WHALE) $@" @@ -138,13 +139,19 @@ install: ## install binaries @echo "$(WHALE) $@ $(BINPACKAGES)" @$(GO) install $(BINPACKAGES) -install-deps: - script/install-protobuf +install-protobuf: + @echo "$(WHALE) $@" + @script/install-protobuf + +install-protobuild: + @echo "$(WHALE) $@" + @$(GO) install google.golang.org/protobuf/cmd/protoc-gen-go@v1.27.1 + @$(GO) install github.com/containerd/protobuild@7e5ee24bc1f70e9e289fef15e2631eb3491320bf coverage: ## generate coverprofiles from the unit tests, except tests that require root @echo "$(WHALE) $@" @rm -f coverage.txt - @$(GO) test -i ${TESTFLAGS} ${PACKAGES} 2> /dev/null + @$(GO) test -i ${TESTFLAGS} ${TESTPACKAGES} 2> /dev/null @( for pkg in ${PACKAGES}; do \ $(GO) test ${TESTFLAGS} \ -cover \