Add logs-linter #526
No reviewers
Labels
No labels
P0
P1
P2
P3
badger
frostfs-adm
frostfs-cli
frostfs-ir
frostfs-lens
frostfs-node
good first issue
triage
Infrastructure
blocked
bug
config
discussion
documentation
duplicate
enhancement
go
help wanted
internal
invalid
kludge
observability
perfomance
question
refactoring
wontfix
No milestone
No project
No assignees
5 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: TrueCloudLab/frostfs-node#526
Loading…
Add table
Reference in a new issue
No description provided.
Delete branch "achuprov/frostfs-node:logs-linter"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Close #162
Adding logs-linter
Not a elegant solution
Perhaps it should be taken out into a separate action.yml in the linter repository
7b53f8ff3a/.forgejo/workflows/tests.yml (L19-L21)
But this requires additional study, whether it is possible to connect action.yml files not from github. I couldn't achieve this locally using act, however, it's possible that forgejo might allow for it.
[#162] add logs-linterto WIP: [#162] add logs-linter17eb079cdf
tob99a18bcc8
b99a18bcc8
to48c3dcb989
48c3dcb989
to1476590cce
1476590cce
to3885ca0e8e
WIP: [#162] add logs-linterto [#162] add logs-linter@ -40,0 +41,4 @@
noliteral:
path: .bin/external_linters.so
description:
original-url: git.frostfs.info/achuprov/linter
Invalid URL
fixed
@ -133,8 +133,12 @@ pre-commit-run:
# Run linters
lint:
@git clone https://git.frostfs.info/achuprov/linter.git
Invalid URL
fixed
3885ca0e8e
to956821812f
@ -16,1 +16,4 @@
- name: Install linters
run: |
git clone --depth 1 https://git.frostfs.info/TrueCloudLab/linters.git
See
staticcheck
example below, we would not like to duplicate install instructions.Maybe introduce
make extralinters-install
? Or evenmake lint-install
, it depends.done
@ -39,1 +39,4 @@
alias: objectSDK
custom:
noliteral:
path: .bin/external_linters.so
Will my local
make lint
continue to work if I don't have this?Can we restrict it to actions somehow?
I am not sure
.bin
is the right name, how about justbin
(we already storeprotogen
plugin there) or.cache
(it is in the git ignore).@ -133,8 +133,12 @@ pre-commit-run:
# Run linters
lint:
@git clone --depth 1 https://git.frostfs.info/TrueCloudLab/linters.git
We will clone a git repo on each
make lint
.This is not ideal, we should be able to do
make lint
even without the network.make lint
command no longer needs internet connectivity4e33e93e35
to8aed013a84
8aed013a84
to0429b26743
0429b26743
to0a0d722a56
0a0d722a56
toa4c0cc471b
a4c0cc471b
tofb04ab8e76
@ -134,0 +137,4 @@
@git clone --depth 1 https://git.frostfs.info/TrueCloudLab/linters.git
@cd linters && make lib OUT_DIR=../.bin/
@cd ..
@export GOBIN=`pwd`/.bin && go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.53.3
I think it's better to not export, just
GOBIN=/path/bin go install ...
@ -19,2 +17,2 @@
with:
version: latest
- name: Install linters
run: |
Can we use single line syntax for a single command
run: make lint-install
-- like in other places in this file.@ -133,1 +134,4 @@
# Install linters
lint-install:
@git clone --depth 1 https://git.frostfs.info/TrueCloudLab/linters.git
It is a bad idea to clone something in the repo root -- the comman can fail in the middle and we will have garbage. How about
.cache
ortmp
?fb04ab8e76
tofdf36754e6
fdf36754e6
to196e420fa4
[#162] add logs-linterto Add logs-linter@ -25,6 +25,7 @@ PKG_VERSION ?= $(shell echo $(VERSION) | sed "s/^v//" | \
sed -E "s/(.*)-(g[a-fA-F0-9]{6,8})(.*)/\1\3~\2/" | \
sed "s/-/~/")-${OS_RELEASE}
Why we need this new line?
@ -1,52 +0,0 @@
package main
Why we need to remove this file? How this changes relates to your commit message?
That was an unsuccessful Friday commit. Rolled it back
Add logs-linterto WIP: Add logs-linter@ -134,3 +141,2 @@
# Run linters
lint:
@golangci-lint --timeout=5m run
lint-run:
This is a common target across multiple our repos, I would leave it as is.
reverted
196e420fa4
to62e17c8542
62e17c8542
toe47059ea2e
WIP: Add logs-linterto Add logs-linter@ -134,0 +134,4 @@
# Install linters
lint-install:
@mkdir -p tmp && cd tmp && git clone --depth 1 https://git.frostfs.info/TrueCloudLab/linters.git && cd linters && make lib OUT_DIR=../../.bin/
@GOBIN=$(shell pwd)/.bin go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.53.3
Why again
.bin
? You can use $(BIN)e47059ea2e
to1f0bb74f95
1f0bb74f95
tofbf106fb65
Table of const check linter triggers
click
fbf106fb65
toa247b77934
a247b77934
tob2873d488a
b2873d488a
to74c77ea083
74c77ea083
to979bf70580
979bf70580
to9e13fd055a
@ -40,0 +41,4 @@
noliteral:
path: bin/external_linters.so
original-url: git.frostfs.info/TrueCloudLab/linters.git
# settings:
It is better to avoid commented out code in RP, especially without comments.
2 things here:
rmdir
is probably not needed9e13fd055a
toc0640191fb
@fyrchik
c0640191fb/Makefile (L147)
I've added suppression of the output.@ -133,1 +135,4 @@
# Install linters
lint-install:
@mkdir -p tmp && \
Some suggestions for this target:
rm ./tmp/linters
is a sane thing to do at the beginning.git clone
can clone in a specific directory, no need tocd
yes | rm
can be replaced with-f
flag forrm
.rm
can remove arbitrary path, no need tocd
.-C
(it has a nice property of leaving the directory after the make)make
can be replaced with$(MAKE)
, see https://www.gnu.org/software/make/manual/html_node/Recursion.htmlexport CGO_ENABLED=1
is useful for 1 command (it does not affectgo install
-- I still have static binary on my machine. We can set it the same way asOUT_DIR
tmp
as a directory where we store stuff, can we a make variable (and I still believe .cache is better, as nothing is stored there manually, usually)For (6) and why it is good: if I use custom make (not in my PATH), with $(MAKE) the same binary will be used)
https://stackoverflow.com/questions/50510278/makefile-why-always-use-make-instead-of-make
Also, from https://golangci-lint.run/contributing/new-linters/#how-to-add-a-private-linter-to-golangci-lint
@achuprov
That's because I have
CGO_ENABLED=0
explicitly set in my shell config (so I have my own defaults).c0640191fb
toe62e964b4f
Add logs-linterto WIP: Add logs-linter4d7a8f29df
to0eea1901ed
0eea1901ed
to595cd57250
@fyrchik fixed
WIP: Add logs-linterto Add logs-linter595cd57250
toba225e5c74
Still doesn't work for me.
ba225e5c74
to9dce55821e
9dce55821e
toc37eee6b75
@fyrchik I probably fixed the problem. But it might depend on your local environment. If this doesn't solve the issue, describe your environment and show the output of 'go env'."
@ -39,1 +39,4 @@
alias: objectSDK
custom:
noliteral:
path: bin/lint-1.54.0/external_linters.so
Do we need to change it each time we update linter version? Can it be avoided?
@ -134,0 +143,4 @@
@make -C $(TMP_DIR)/linters lib CGO_ENABLED=1 OUT_DIR=$(LINT_DIR)
@rm -rf $(TMP_DIR)/linters
@rmdir $(TMP_DIR) 2>/dev/null || true
@GOBIN=$(LINT_DIR) go install github.com/golangci/golangci-lint/cmd/golangci-lint@v$(LINT_VERSION)
CGO_ENABLED=1
is what we miss here.@ -137,0 +152,4 @@
echo "Run make lint-install"; \
exit 1; \
fi
$(LINT_DIR)/golangci-lint --timeout=10m run
Previously a timeout was different, whats the reason for change?
Anyway, we have it in the
.golangci.yml
, why do we need it here?c37eee6b75
tob5f94ec7d7
@fyrchik fixed
Please, rebase on the master branch.
b5f94ec7d7
toad87493c41
@fyrchik Rebased