From 349e5d4573b22a6bdb4c0595407a5f07d2558beb Mon Sep 17 00:00:00 2001 From: Agniva De Sarker Date: Thu, 4 May 2023 19:37:30 +0530 Subject: [PATCH] Run golangci in server CI (#23240) * Run golangci in server CI Also reordered the checks in check-style target to run vet check first which has far better error messages in case of unsynced branch failures. ```release-note NONE ``` --- .github/workflows/ci.yml | 20 ++++++++++++++++++++ server/Makefile | 5 ++--- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8197f9a20f..e88cbc0746 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -87,6 +87,26 @@ jobs: run: make plugin-checker - name: Run mattermost-vet run: make vet BUILD_NUMBER='${GITHUB_HEAD_REF}' MM_NO_ENTERPRISE_LINT=true MM_VET_OPENSPEC_PATH='${PWD}/../../mattermost-api-reference/v4/html/static/mattermost-openapi-v4.yaml' + golangci: + name: golangci-lint + runs-on: ubuntu-22.04 + defaults: + run: + working-directory: server + steps: + - name: Checkout mattermost-server + uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 + - name: Setup Go + uses: actions/setup-go@4d34df0c2316fe8122ab82dc22947d607c0c91f9 # v4.0.0 + with: + go-version: ${{ env.go-version }} + cache-dependency-path: server/go.sum + - name: golangci-lint + uses: golangci/golangci-lint-action@v3 + with: + version: v1.52.2 + working-directory: server + args: --new-from-rev=HEAD~ --whole-files # This only checks the latest commit for speed. check-migrations: name: Check migration files runs-on: ubuntu-22.04 diff --git a/server/Makefile b/server/Makefile index 4a893bb70f..b8e80e865a 100644 --- a/server/Makefile +++ b/server/Makefile @@ -291,7 +291,7 @@ else endif golangci-lint: ## Run golangci-lint on codebase - @# Keep the version in sync with the command in .circleci/config.yml + @# Keep the version in sync with the command in .github/workflows/ci.yml#L107 $(GO) install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.52.2 @echo Running golangci-lint @@ -403,8 +403,7 @@ setup-go-work: export BUILD_ENTERPRISE_READY := $(BUILD_ENTERPRISE_READY) setup-go-work: ## Sets up your go.work file ./scripts/setup_go_work.sh $(IGNORE_GO_WORK_IF_EXISTS) -check-style: golangci-lint plugin-checker vet ## Runs style/lint checks - +check-style: plugin-checker vet golangci-lint ## Runs style/lint checks do-cover-file: ## Creates the test coverage report file. @echo "mode: count" > cover.out