From 15d2a5a2edebc20a41e82e5f9af7f8e91ef92938 Mon Sep 17 00:00:00 2001 From: Austin Vazquez Date: Thu, 16 Mar 2023 16:06:00 +0000 Subject: [PATCH] Switch Go linting to use golangci-lint Signed-off-by: Austin Vazquez --- .github/workflows/build-pr.yml | 20 +++++++++++++++----- .github/workflows/build.yml | 20 +++++++++++++++----- .tool/version-doc.go | 1 + Makefile | 16 +--------------- 4 files changed, 32 insertions(+), 25 deletions(-) diff --git a/.github/workflows/build-pr.yml b/.github/workflows/build-pr.yml index 73666d5..e27ed59 100644 --- a/.github/workflows/build-pr.yml +++ b/.github/workflows/build-pr.yml @@ -11,22 +11,32 @@ jobs: steps: - name: checkout source code uses: actions/checkout@master + - name: setup go environment uses: actions/setup-go@v1 with: go-version: '1.17.2' + + - name: create go.mod + run: | + # Fix for "cannot find main module" issue + go mod init github.com/opencontainers/runtime-spec + + go get -d ./schema/... + + - name: run golangci-lint + uses: golangci/golangci-lint-action@v3 + with: + version: v1.51.2 + args: --verbose + - name: run tests run: | export PATH="$(go env GOPATH)/bin:${PATH}" set -x make install.tools - # Fix for "cannot find main module" issue - go mod init github.com/opencontainers/runtime-spec - - go get -d ./schema/... make .govet - make .golint make .gitvalidation make docs diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9045dd4..eb29bd8 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -11,22 +11,32 @@ jobs: steps: - name: checkout source code uses: actions/checkout@master + - name: setup go environment uses: actions/setup-go@v1 with: go-version: '1.17.2' + + - name: create go.mod + run: | + # Fix for "cannot find main module" issue + go mod init github.com/opencontainers/runtime-spec + + go get -d ./schema/... + + - name: run golangci-lint + uses: golangci/golangci-lint-action@v3 + with: + version: v1.51.2 + args: --verbose + - name: run tests run: | export PATH="$(go env GOPATH)/bin:${PATH}" set -x make install.tools - # Fix for "cannot find main module" issue - go mod init github.com/opencontainers/runtime-spec - - go get -d ./schema/... make .govet - make .golint make .gitvalidation make docs diff --git a/.tool/version-doc.go b/.tool/version-doc.go index f36bfe4..fdc6e28 100644 --- a/.tool/version-doc.go +++ b/.tool/version-doc.go @@ -1,3 +1,4 @@ +//go:build ignore // +build ignore package main diff --git a/Makefile b/Makefile index 7a61610..9fb877d 100644 --- a/Makefile +++ b/Makefile @@ -61,14 +61,6 @@ test: .govet .golint .gitvalidation .govet: go vet -x ./... -# `go get github.com/golang/lint/golint` -.golint: -ifeq ($(call ALLOWED_GO_VERSION,1.7,$(HOST_GOLANG_VERSION)),true) - @which golint > /dev/null 2>/dev/null || (echo "ERROR: golint not found. Consider 'make install.tools' target" && false) - golint ./... -endif - - # When this is running in GitHub, it will only check the GitHub commit range .gitvalidation: @which git-validation > /dev/null 2>/dev/null || (echo "ERROR: git-validation not found. Consider 'make install.tools' target" && false) @@ -78,13 +70,7 @@ else git-validation -v -run DCO,short-subject,dangling-whitespace -range $(EPOCH_TEST_COMMIT)..HEAD endif -install.tools: .install.golint .install.gitvalidation - -# golint does not even build for