Skip to content

Commit 112fea4

Browse files
authored
Merge pull request #7777 from onflow/peter/improve-lint
[CI] Add new make lint targets
2 parents 7158034 + 5c9bf97 commit 112fea4

File tree

4 files changed

+49
-3
lines changed

4 files changed

+49
-3
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,8 @@ jobs:
321321
username: ${{ vars.DOCKERHUB_USERNAME }}
322322
password: ${{ secrets.DOCKERHUB_TOKEN }}
323323
if: ${{ (github.event_name == 'merge_group' || (github.event.pull_request && (github.event.pull_request.author_association == 'MEMBER' || github.event.pull_request.author_association == 'COLLABORATOR'))) }}
324+
# this docker auth is exclusively for higher rate limits. continue unauthenticated if it fails
325+
continue-on-error: true
324326

325327

326328
- name: Docker build

.golangci.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,22 @@ run:
33

44
linters-settings:
55
goimports:
6+
# enforced by linter
67
# put imports beginning with prefix after 3rd-party packages;
78
# it's a comma-separated list of prefixes
89
local-prefixes: github.com/onflow/flow-go/
910

11+
# used to generate canonical import ordering
12+
# not enforced by linter
13+
gci:
14+
sections:
15+
- standard # 1. standard library
16+
- default # 2. external packages
17+
- prefix(github.com/onflow/) # 3. org packages
18+
- prefix(github.com/onflow/flow-go/) # 4. project packages
19+
skip-generated: true
20+
custom-order: true
21+
1022
gosec:
1123
# To select a subset of rules to run.
1224
# Available rules: https://github.com/securego/gosec#available-rules

AGENTS.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,21 @@ This file provides guidance to AI Agents when working with code in this reposito
5151
5252
### Code Quality and Generation
5353
- `make lint` - Run linter (includes tidy and custom checks)
54-
- `make lint -e LINT_PATH=./path/to/lint/...` - Run linter for a specific module
54+
- `make fix-new` - Run linter for files changed since master
5555
- `make fix-lint` - Automatically fix linting issues
56+
- `make fix-lint-new` - Automatically fix linting issues for files changed since master
57+
- `make fix-imports` - Automatically fix imports
58+
- `make fix-imports-new` - Automatically fix imports for files changed since master
59+
- `make vet` - Run go vet
60+
- `make vet-new` - Run go vet for files changed since master
5661
- `make generate` - Run all code generators (proto, mocks, fvm wrappers)
5762
- `make generate-mocks` - Generate mocks for unit tests
5863
- `make generate-proto` - Generate protobuf stubs
5964
- `make tidy` - Run go mod tidy
6065
66+
`lint`, `vet`, `fix-lint`, and `fix-imports` support passing `LINT_PATH`, which sets the path used by golangci-lint
67+
- `make lint -e LINT_PATH=./path/to/lint/...` - Run linter for a specific module
68+
6169
### Dependency Management
6270
- `make install-tools` - Install all required development tools
6371
- `make install-mock-generators` - Install mock generation tools

Makefile

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,15 +170,39 @@ tools/custom-gcl: tools/structwrite .custom-gcl.yml
170170
golangci-lint custom
171171

172172
.PHONY: lint
173-
lint: tidy tools/custom-gcl
173+
lint: tools/custom-gcl
174174
# revive -config revive.toml -exclude storage/ledger/trie ./...
175175
./tools/custom-gcl run -v $(or $(LINT_PATH),./...)
176176

177+
.PHONY: lint-new
178+
lint-new: tools/custom-gcl
179+
./tools/custom-gcl run -v --new-from-rev=master
180+
177181
.PHONY: fix-lint
178-
fix-lint:
182+
fix-lint: tools/custom-gcl
179183
# revive -config revive.toml -exclude storage/ledger/trie ./...
180184
./tools/custom-gcl run -v --fix $(or $(LINT_PATH),./...)
181185

186+
.PHONY: fix-lint-new
187+
fix-lint-new: tools/custom-gcl
188+
./tools/custom-gcl run -v --fix --new-from-rev=master
189+
190+
.PHONY: fix-imports
191+
fix-imports: tools/custom-gcl
192+
./tools/custom-gcl run --enable-only=gci --fix $(or $(LINT_PATH),./...)
193+
194+
.PHONY: fix-imports-new
195+
fix-imports-new: tools/custom-gcl
196+
./tools/custom-gcl run --enable-only=gci --fix --new-from-rev=master
197+
198+
.PHONY: vet
199+
vet: tools/custom-gcl
200+
./tools/custom-gcl run --enable-only=govet $(or $(LINT_PATH),./...)
201+
202+
.PHONY: vet-new
203+
vet-new: tools/custom-gcl
204+
./tools/custom-gcl run --enable-only=govet --new-from-rev=master
205+
182206
# Runs unit tests with different list of packages as passed by CI so they run in parallel
183207
.PHONY: ci
184208
ci: install-tools test

0 commit comments

Comments
 (0)