forked from TrueCloudLab/frostfs-node
[#162] ci: Add noliteral linter
Signed-off-by: Alexander Chuprov <a.chuprov@yadro.com>
This commit is contained in:
parent
abdb0910cc
commit
a5f51add25
3 changed files with 33 additions and 7 deletions
|
@ -14,10 +14,11 @@ jobs:
|
||||||
go-version: '1.21'
|
go-version: '1.21'
|
||||||
cache: true
|
cache: true
|
||||||
|
|
||||||
- name: golangci-lint
|
- name: Install linters
|
||||||
uses: https://github.com/golangci/golangci-lint-action@v3
|
run: make lint-install
|
||||||
with:
|
|
||||||
version: latest
|
- name: Run linters
|
||||||
|
run: make lint
|
||||||
|
|
||||||
tests:
|
tests:
|
||||||
name: Tests
|
name: Tests
|
||||||
|
|
|
@ -37,6 +37,14 @@ linters-settings:
|
||||||
alias:
|
alias:
|
||||||
pkg: git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object
|
pkg: git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object
|
||||||
alias: objectSDK
|
alias: objectSDK
|
||||||
|
custom:
|
||||||
|
noliteral:
|
||||||
|
path: bin/external_linters.so
|
||||||
|
original-url: git.frostfs.info/TrueCloudLab/linters.git
|
||||||
|
# settings:
|
||||||
|
# target-methods : ["reportFlushError", "reportError"]
|
||||||
|
# disable-packages: ["codes", "err", "res","exec"]
|
||||||
|
# constants-repository: "git.frostfs.info/TrueCloudLab/frostfs-node/internal/logs"
|
||||||
|
|
||||||
linters:
|
linters:
|
||||||
enable:
|
enable:
|
||||||
|
@ -69,5 +77,6 @@ linters:
|
||||||
- gocognit
|
- gocognit
|
||||||
- contextcheck
|
- contextcheck
|
||||||
- importas
|
- importas
|
||||||
|
- noliteral
|
||||||
disable-all: true
|
disable-all: true
|
||||||
fast: false
|
fast: false
|
||||||
|
|
22
Makefile
22
Makefile
|
@ -8,8 +8,7 @@ HUB_IMAGE ?= truecloudlab/frostfs
|
||||||
HUB_TAG ?= "$(shell echo ${VERSION} | sed 's/^v//')"
|
HUB_TAG ?= "$(shell echo ${VERSION} | sed 's/^v//')"
|
||||||
|
|
||||||
GO_VERSION ?= 1.21
|
GO_VERSION ?= 1.21
|
||||||
LINT_VERSION ?= 1.52.2
|
LINT_VERSION ?= 1.53.3
|
||||||
ARCH = amd64
|
|
||||||
|
|
||||||
BIN = bin
|
BIN = bin
|
||||||
RELEASE = release
|
RELEASE = release
|
||||||
|
@ -25,6 +24,9 @@ PKG_VERSION ?= $(shell echo $(VERSION) | sed "s/^v//" | \
|
||||||
sed -E "s/(.*)-(g[a-fA-F0-9]{6,8})(.*)/\1\3~\2/" | \
|
sed -E "s/(.*)-(g[a-fA-F0-9]{6,8})(.*)/\1\3~\2/" | \
|
||||||
sed "s/-/~/")-${OS_RELEASE}
|
sed "s/-/~/")-${OS_RELEASE}
|
||||||
|
|
||||||
|
OUTPUT_LINT_DIR ?= $(shell pwd)/bin
|
||||||
|
TMP_DIR := .cache
|
||||||
|
|
||||||
.PHONY: help all images dep clean fmts fmt imports test lint docker/lint
|
.PHONY: help all images dep clean fmts fmt imports test lint docker/lint
|
||||||
prepare-release debpackage pre-commit unpre-commit
|
prepare-release debpackage pre-commit unpre-commit
|
||||||
|
|
||||||
|
@ -131,9 +133,23 @@ test:
|
||||||
pre-commit-run:
|
pre-commit-run:
|
||||||
@pre-commit run -a --hook-stage manual
|
@pre-commit run -a --hook-stage manual
|
||||||
|
|
||||||
|
# Install linters
|
||||||
|
lint-install:
|
||||||
|
@mkdir -p $(TMP_DIR)
|
||||||
|
@rm -rf $(TMP_DIR)/linters
|
||||||
|
@git clone --depth 1 https://git.frostfs.info/TrueCloudLab/linters.git $(TMP_DIR)/linters
|
||||||
|
@make -C $(TMP_DIR)/linters lib CGO_ENABLED=1 OUT_DIR=$(OUTPUT_LINT_DIR)
|
||||||
|
@rm -rf $(TMP_DIR)/linters
|
||||||
|
@rmdir $(TMP_DIR) 2>/dev/null || true
|
||||||
|
@GOBIN=$(OUTPUT_LINT_DIR) go install github.com/golangci/golangci-lint/cmd/golangci-lint@v$(LINT_VERSION)
|
||||||
|
|
||||||
|
|
||||||
# Run linters
|
# Run linters
|
||||||
lint:
|
lint:
|
||||||
@golangci-lint --timeout=5m run
|
NOLITERAL_TARGET_METHODS="reportFlushError,reportError" \
|
||||||
|
NOLITERAL_DISABLE_PACKAGES="codes,err,res,exec" \
|
||||||
|
NOLITERAL_CONSTANTS_PACKAGE="git.frostfs.info/TrueCloudLab/frostfs-node/internal/logs" \
|
||||||
|
$(OUTPUT_LINT_DIR)/golangci-lint --timeout=10m run
|
||||||
|
|
||||||
# Install staticcheck
|
# Install staticcheck
|
||||||
staticcheck-install:
|
staticcheck-install:
|
||||||
|
|
Loading…
Reference in a new issue