Skip to content

Commit

Permalink
Consolidate lint steps in GitHub Actions
Browse files Browse the repository at this point in the history
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.

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.

[1] golangci/golangci-lint-action#271
  • Loading branch information
brandur committed Feb 25, 2024
1 parent 8fbad91 commit 416604d
Showing 1 changed file with 2 additions and 30 deletions.
32 changes: 2 additions & 30 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -164,37 +164,9 @@ jobs:
uses: golangci/golangci-lint-action@v4
with:
version: ${{ env.GOLANGCI_LINT_VERSION }}
working-directory: .

- name: Lint cmd/river
uses: golangci/golangci-lint-action@v4
with:
version: ${{ env.GOLANGCI_LINT_VERSION }}
working-directory: ./cmd/river

- name: Lint riverdriver
uses: golangci/golangci-lint-action@v4
with:
version: ${{ env.GOLANGCI_LINT_VERSION }}
working-directory: ./riverdriver

- name: Lint riverdriver/riverdatabasesql
uses: golangci/golangci-lint-action@v4
with:
version: ${{ env.GOLANGCI_LINT_VERSION }}
working-directory: ./riverdriver/riverdatabasesql

- name: Lint riverdriver/riverpgxv5
uses: golangci/golangci-lint-action@v4
with:
version: ${{ env.GOLANGCI_LINT_VERSION }}
working-directory: ./riverdriver/riverpgxv5

- name: Lint rivertype
uses: golangci/golangci-lint-action@v3
with:
version: ${{ env.GOLANGCI_LINT_VERSION }}
working-directory: ./rivertype
- name: Run lint
run: make lint

producer_sample:
runs-on: ubuntu-latest
Expand Down

0 comments on commit 416604d

Please sign in to comment.