Skip to content

Commit 27ee4dd

Browse files
committed
Consolidate lint steps in GitHub Actions
Like with running Go tests, the lints for each separate Go module must be running separately. This is currently being accomplished in CI by giving each Go module its own lint job using golangci-lint's GitHub Action. Unfortunately, this is really not working out well. Although the lints themselves are all very fast to run (just a couple seconds), the post run step where it saves it cache is quite slow, about two minutes, and that's happening for each of the lint steps, making the entire lint job take almost _ten minutes_ to run. I think what might've been happening is that each lint job was overwriting the last job's cache, which is why each post run step seemed to be doing so much work. I didn't validate this hypothesis, but it seems like a strong possibility. Here, try to hack around the problem by having the main lint job fetch golangci-lint, but then only run `--help`, and then do the real linting as a separate step (one that doesn't use the GitHub Action) that calls into our `make lint` target to run lints for each Go module. A downside is that it may not annotate lint problems on the GitHub PR, which is something that theoretically happened before, although it never seemed to work for me. This might not be that bad though because it could as a side effect improve the log output, which is terrible for the GitHub Action step because it doesn't include files or line numbers. Also, I notice that the lints/tests in `Makefile` had been commented out for `./cmd/river` for some reason (maybe something I did during the driver refactor and forgot to fix), so I uncommented them. [1] golangci/golangci-lint-action#271
1 parent 8fbad91 commit 27ee4dd

File tree

2 files changed

+12
-32
lines changed

2 files changed

+12
-32
lines changed

.github/workflows/ci.yml

+10-30
Original file line numberDiff line numberDiff line change
@@ -163,38 +163,18 @@ jobs:
163163
- name: Lint
164164
uses: golangci/golangci-lint-action@v4
165165
with:
166+
# golangci-lint needs to be run separately for every Go module, and
167+
# its GitHub Action doesn't provide any way to do that. Have it fetch
168+
# the golangci-lint binary, trick it into not running by sending only
169+
# `--help`, then run the full set of lints below. DO NOT run separate
170+
# modules as separate golangci-lint-action steps. Its post run caching
171+
# can be extremely slow, and that's amplified in a very painful way if
172+
# it needs to be run multiple times.
173+
args: --help
166174
version: ${{ env.GOLANGCI_LINT_VERSION }}
167-
working-directory: .
168175

169-
- name: Lint cmd/river
170-
uses: golangci/golangci-lint-action@v4
171-
with:
172-
version: ${{ env.GOLANGCI_LINT_VERSION }}
173-
working-directory: ./cmd/river
174-
175-
- name: Lint riverdriver
176-
uses: golangci/golangci-lint-action@v4
177-
with:
178-
version: ${{ env.GOLANGCI_LINT_VERSION }}
179-
working-directory: ./riverdriver
180-
181-
- name: Lint riverdriver/riverdatabasesql
182-
uses: golangci/golangci-lint-action@v4
183-
with:
184-
version: ${{ env.GOLANGCI_LINT_VERSION }}
185-
working-directory: ./riverdriver/riverdatabasesql
186-
187-
- name: Lint riverdriver/riverpgxv5
188-
uses: golangci/golangci-lint-action@v4
189-
with:
190-
version: ${{ env.GOLANGCI_LINT_VERSION }}
191-
working-directory: ./riverdriver/riverpgxv5
192-
193-
- name: Lint rivertype
194-
uses: golangci/golangci-lint-action@v3
195-
with:
196-
version: ${{ env.GOLANGCI_LINT_VERSION }}
197-
working-directory: ./rivertype
176+
- name: Run lint
177+
run: make lint
198178

199179
producer_sample:
200180
runs-on: ubuntu-latest

Makefile

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ generate/sqlc:
1010
.PHONY: lint
1111
lint:
1212
cd . && golangci-lint run --fix
13-
# cd cmd/river && golangci-lint run --fix
13+
cd cmd/river && golangci-lint run --fix
1414
cd riverdriver && golangci-lint run --fix
1515
cd riverdriver/riverdatabasesql && golangci-lint run --fix
1616
cd riverdriver/riverpgxv5 && golangci-lint run --fix
@@ -19,7 +19,7 @@ lint:
1919
.PHONY: test
2020
test:
2121
cd . && go test ./... -p 1
22-
# cd cmd/river && go test ./...
22+
cd cmd/river && go test ./...
2323
cd riverdriver && go test ./...
2424
cd riverdriver/riverdatabasesql && go test ./...
2525
cd riverdriver/riverpgxv5 && go test ./...

0 commit comments

Comments
 (0)