Skip to content

Feature request: run linter a few times #449

Open
@kolyshkin

Description

In my repository (https://github.com/opencontainers/runc) I use two distinct linter configs:

  • one where all default linters, and some non-default ones, are enabled
  • one where only a couple of extra linters are enabled

The first config is used everywhere (on main and release branches, as well as for PRs)

The second config is

  • aimed at new code only (and so it has only-new-issues: true)
  • aimed at PRs only (and so it has if: github.event_name == 'pull_request')

The idea behind this setup is simple: since we have a pretty big codebase, we can't possibly modify it to satisfy some more stricter and/or opinionated linters (such as godot, revive, gocritic, or dupl), nor it makes sense to do so -- but we can impose stricter standards for the newly added code.

Now, the GHA CI implementation (with the .golangci-extra.yml file with extra linters) looks like this:

jobs:

  lint:
    runs-on: ubuntu-20.04
    steps:
      - uses: actions/checkout@v3
      - uses: actions/setup-go@v3
        with:
          go-version: "${{ env.GO_VERSION }}"
      - name: install deps
        run: |
          sudo apt -q update
          sudo apt -q install libseccomp-dev
      - uses: golangci/golangci-lint-action@v3
        with:
          version: "${{ env.LINT_VERSION }}"
      # Extra linters, only checking new code from pull requests.
      - uses: golangci/golangci-lint-action@v3
        if: github.event_name == 'pull_request'
        with:
          only-new-issues: true
          args: --config .golangci-extra.yml
          version: "${{ env.LINT_VERSION }}"

All this works, except that since I use golangci/golangci-lint-action twice, it actually downloads and installs golangci-lint twice (for example, see the log at https://github.com/opencontainers/runc/runs/5982042602?check_suite_focus=true.

** Proposal ** modify the action to detect that it is being used for the second time, and skip the second, redundant golangci-lint setup.

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions