From c140e40d222bdfe8e7322c4af64eeb5b3e356d4c Mon Sep 17 00:00:00 2001 From: Yusuke Kato Date: Thu, 16 Mar 2023 13:41:18 +0900 Subject: [PATCH] enable gorules (#1980) Signed-off-by: kpango --- .github/workflows/test-hack.yml | 17 +++++++++++++---- Makefile.d/test.mk | 12 +++++++++--- apis/grpc/v1/payload/interface.go | 10 +++++----- hack/gorules/rules_test.go | 2 -- hack/gorules/testdata/tests.go | 2 +- 5 files changed, 28 insertions(+), 15 deletions(-) diff --git a/.github/workflows/test-hack.yml b/.github/workflows/test-hack.yml index fc7222deec..54c4c929b3 100644 --- a/.github/workflows/test-hack.yml +++ b/.github/workflows/test-hack.yml @@ -70,18 +70,27 @@ jobs: runs-on: ubuntu-latest container: image: ghcr.io/vdaas/vald/vald-ci-container:nightly + defaults: + run: + working-directory: src/github.com/vdaas/vald steps: - name: Check out code. uses: actions/checkout@v3 + with: + fetch-depth: 1 + path: src/github.com/vdaas/vald - name: set git config run: | - git config --global --add safe.directory ${GITHUB_WORKSPACE} + git config --global --add safe.directory ${GITHUB_WORKSPACE}/src/github.com/vdaas/vald + working-directory: src/github.com/vdaas/vald - name: dependencies run: | - make proto/deps + GOPATH=${GITHUB_WORKSPACE} make proto/deps + working-directory: src/github.com/vdaas/vald - name: Run tests for hack packages / gotestfmt run: | - TEST_RESULT_DIR=${GITHUB_WORKSPACE} make test/hack/gotestfmt + GOPATH=${GITHUB_WORKSPACE} TEST_RESULT_DIR=${GITHUB_WORKSPACE}/src/github.com/vdaas/vald make test/hack/gotestfmt + working-directory: src/github.com/vdaas/vald - name: print tparse result run: | - tparse -notests -smallscreen -sort cover -format markdown -file ${GITHUB_WORKSPACE}/test-hack-gotestfmt-result.json + tparse -notests -smallscreen -sort cover -format markdown -file ${GITHUB_WORKSPACE}/src/github.com/vdaas/vald/test-hack-gotestfmt-result.json diff --git a/Makefile.d/test.mk b/Makefile.d/test.mk index a859dea189..f7f996b896 100644 --- a/Makefile.d/test.mk +++ b/Makefile.d/test.mk @@ -90,13 +90,15 @@ test/hack/tparse: \ tparse/install set -euo pipefail rm -rf "$(TEST_RESULT_DIR)/`echo $@ | sed -e 's%/%-%g'`-result.json" - go test -short -shuffle=on -race -mod=readonly -json -cover \ + go mod vendor -o $(ROOTDIR)/vendor + go test -short -shuffle=on -race -mod=vendor -json -cover \ $(ROOTDIR)/hack/gorules/... \ $(ROOTDIR)/hack/helm/... \ $(ROOTDIR)/hack/license/... \ $(ROOTDIR)/hack/tools/... \ | tee "$(TEST_RESULT_DIR)/`echo $@ | sed -e 's%/%-%g'`-result.json" \ | tparse -pass -notests + rm -rf $(ROOTDIR)/vendor .PHONY: test/all/tparse ## run tests for all Go codes and show table @@ -154,13 +156,15 @@ test/hack/gotestfmt: \ gotestfmt/install set -euo pipefail rm -rf "$(TEST_RESULT_DIR)/`echo $@ | sed -e 's%/%-%g'`-result.json" - go test -short -shuffle=on -race -mod=readonly -json -cover \ + go mod vendor -o $(ROOTDIR)/vendor + go test -short -shuffle=on -race -mod=vendor -json -cover \ $(ROOTDIR)/hack/gorules/... \ $(ROOTDIR)/hack/helm/... \ $(ROOTDIR)/hack/license/... \ $(ROOTDIR)/hack/tools/... \ | tee "$(TEST_RESULT_DIR)/`echo $@ | sed -e 's%/%-%g'`-result.json" \ | gotestfmt -showteststatus + rm -rf $(ROOTDIR)/vendor .PHONY: test/all/gotestfmt ## run tests for all Go codes and show table @@ -190,11 +194,13 @@ test/cmd: .PHONY: test/hack ## run tests for hack test/hack: - go test -short -shuffle=on -race -mod=readonly -cover \ + go mod vendor -o $(ROOTDIR)/vendor + go test -short -shuffle=on -race -mod=vendor -cover \ $(ROOTDIR)/hack/gorules... \ $(ROOTDIR)/hack/helm/... \ $(ROOTDIR)/hack/license/...\ $(ROOTDIR)/hack/tools/... + rm -rf $(ROOTDIR)/vendor .PHONY: test/all ## run tests for all Go codes diff --git a/apis/grpc/v1/payload/interface.go b/apis/grpc/v1/payload/interface.go index 245051eb74..a63d41e0bb 100644 --- a/apis/grpc/v1/payload/interface.go +++ b/apis/grpc/v1/payload/interface.go @@ -21,9 +21,9 @@ type Payload interface { ProtoMessage() ProtoReflect() protoreflect.Message Descriptor() ([]byte, []int) - // MarshalToSizedBufferVT(dAtA []byte) (int, error) - // MarshalToVT(dAtA []byte) (int, error) - // MarshalVT() (dAtA []byte, err error) - // SizeVT() (n int) - // UnmarshalVT(dAtA []byte) error + MarshalToSizedBufferVT(dAtA []byte) (int, error) + MarshalToVT(dAtA []byte) (int, error) + MarshalVT() (dAtA []byte, err error) + SizeVT() (n int) + UnmarshalVT(dAtA []byte) error } diff --git a/hack/gorules/rules_test.go b/hack/gorules/rules_test.go index 9548753bc5..713f5db1cb 100644 --- a/hack/gorules/rules_test.go +++ b/hack/gorules/rules_test.go @@ -1,5 +1,3 @@ -//go:build exclude - // Copyright (C) 2019-2023 vdaas.org vald team // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/hack/gorules/testdata/tests.go b/hack/gorules/testdata/tests.go index 6040734d05..d6040dc062 100644 --- a/hack/gorules/testdata/tests.go +++ b/hack/gorules/testdata/tests.go @@ -11,7 +11,7 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. -package target +package testdata import ( "fmt"