Skip to content

Commit

Permalink
feat: golangci-lint v2 support (#1198)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ludovic Fernandez authored and GitHub committed Mar 24, 2025
1 parent 1f07148 commit dec74fa
Show file tree
Hide file tree
Showing 15 changed files with 106 additions and 165 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ jobs:
version:
- ""
- "latest"
- "v1.63" # TODO(ldez): it should be updated for v2.
- "v1.63.4" # TODO(ldez): it should be updated for v2.
- "v2.0"
- "v2.0.0"
runs-on: ${{ matrix.os }}
permissions:
contents: read
Expand Down Expand Up @@ -83,8 +83,8 @@ jobs:
version:
- ""
- "latest"
- "v1.63.4" # TODO(ldez): it should be updated for v2.
- "95c39ac1fbaf66475705c06c16259ffd9d6bf9a2" # TODO(ldez): it should be updated for v2.
- "v2.0.0"
- "1f032fbc4b117e4247b19ff606cc847ab5383bc9"
runs-on: ${{ matrix.os }}
permissions:
contents: read
Expand Down
5 changes: 3 additions & 2 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
version: "2"

output:
show-stats: true
sort-results: true
sort-order:
- file
- linter
- file
53 changes: 27 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ jobs:
with:
go-version: stable
- name: golangci-lint
uses: golangci/golangci-lint-action@v6
uses: golangci/golangci-lint-action@v7
with:
version: v1.64
version: v2.0
```
</details>
Expand Down Expand Up @@ -92,9 +92,9 @@ jobs:
with:
go-version: ${{ matrix.go }}
- name: golangci-lint
uses: golangci/golangci-lint-action@v6
uses: golangci/golangci-lint-action@v7
with:
version: v1.64
version: v2.0
```
You will also likely need to add the following `.gitattributes` file to ensure that line endings for Windows builds are properly formatted:
Expand All @@ -120,7 +120,7 @@ on:
env:
GO_VERSION: stable
GOLANGCI_LINT_VERSION: v1.64
GOLANGCI_LINT_VERSION: v2.0
jobs:
detect-modules:
Expand All @@ -147,7 +147,7 @@ jobs:
with:
go-version: ${{ env.GO_VERSION }}
- name: golangci-lint ${{ matrix.modules }}
uses: golangci/golangci-lint-action@v6
uses: golangci/golangci-lint-action@v7
with:
version: ${{ env.GOLANGCI_LINT_VERSION }}
working-directory: ${{ matrix.modules }}
Expand Down Expand Up @@ -179,7 +179,7 @@ jobs:
with:
os: ${{ matrix.os }}
go-version: ${{ matrix.go-version }}
golangci-lint-version: v1.64
golangci-lint-version: v2.0
```

```yaml
Expand All @@ -201,7 +201,7 @@ on:
golangci-lint-version:
description: 'Golangci-lint version'
type: string
default: 'v1.64'
default: 'v2.0'
jobs:
detect-modules:
Expand Down Expand Up @@ -229,7 +229,7 @@ jobs:
with:
go-version: ${{ inputs.go-version }}
- name: golangci-lint ${{ matrix.modules }}
uses: golangci/golangci-lint-action@v6
uses: golangci/golangci-lint-action@v7
with:
version: ${{ inputs.golangci-lint-version }}
working-directory: ${{ matrix.modules }}
Expand All @@ -245,6 +245,7 @@ You will also likely need to add the following `.gitattributes` file to ensure t

## Compatibility

* `v7.0.0` supports golangci-lint v2 only.
* `v6.0.0+` removes `annotations` option, removes the default output format (`github-actions`).
* `v5.0.0+` removes `skip-pkg-cache` and `skip-build-cache` because the cache related to Go itself is already handled by `actions/setup-go`.
* `v4.0.0+` requires an explicit `actions/setup-go` installation step before using this action: `uses: actions/setup-go@v5`.
Expand All @@ -262,17 +263,17 @@ You will also likely need to add the following `.gitattributes` file to ensure t
The version of golangci-lint to use.

When `install-mode` is:
* `binary` (default): the value can be v1.2 or v1.2.3 or `latest` to use the latest version.
* `goinstall`: the value can be v1.2.3, `latest`, or the hash of a commit.
* `binary` (default): the value can be v2.3 or v2.3.4 or `latest` to use the latest version.
* `goinstall`: the value can be v2.3.4, `latest`, or the hash of a commit.
* `none`: the value is ignored.

<details>
<summary>Example</summary>

```yml
uses: golangci/golangci-lint-action@v6
uses: golangci/golangci-lint-action@v7
with:
version: v1.58
version: v2.0
# ...
```

Expand All @@ -290,7 +291,7 @@ The default value is `binary`.
<summary>Example</summary>

```yml
uses: golangci/golangci-lint-action@v6
uses: golangci/golangci-lint-action@v7
with:
install-mode: "goinstall"
# ...
Expand All @@ -310,7 +311,7 @@ By default, it uses the `github.token` from the action.
<summary>Example</summary>

```yml
uses: golangci/golangci-lint-action@v6
uses: golangci/golangci-lint-action@v7
with:
github-token: xxx
# ...
Expand All @@ -333,7 +334,7 @@ The JSONSchema used to validate the configuration depends on the version of gola
<summary>Example</summary>

```yml
uses: golangci/golangci-lint-action@v6
uses: golangci/golangci-lint-action@v7
with:
verify: false
# ...
Expand All @@ -358,7 +359,7 @@ The default value is `false`.
<summary>Example</summary>

```yml
uses: golangci/golangci-lint-action@v6
uses: golangci/golangci-lint-action@v7
with:
only-new-issues: true
# ...
Expand All @@ -376,7 +377,7 @@ Working directory, useful for monorepos.
<summary>Example</summary>

```yml
uses: golangci/golangci-lint-action@v6
uses: golangci/golangci-lint-action@v7
with:
working-directory: somedir
# ...
Expand All @@ -397,9 +398,9 @@ The location of the configuration file can be changed by using `--config=`
<summary>Example</summary>

```yml
uses: golangci/golangci-lint-action@v6
uses: golangci/golangci-lint-action@v7
with:
args: --timeout=30m --config=/my/path/.golangci.yml --issues-exit-code=0
args: --config=/my/path/.golangci.yml --issues-exit-code=0
# ...
```

Expand All @@ -411,7 +412,7 @@ with:

Force the usage of the embedded problem matchers.

By default, the [problem matcher of Go (`actions/setup-go`)](https://github.com/actions/setup-go/blob/main/matchers.json) already handles the golangci-lint output (`colored-line-number`).
By default, the [problem matcher of Go (`actions/setup-go`)](https://github.com/actions/setup-go/blob/main/matchers.json) already handles the default golangci-lint output (`text`).

Works only with `colored-line-number` (the golangci-lint default).

Expand All @@ -423,7 +424,7 @@ The default value is `false`.
<summary>Example</summary>

```yml
uses: golangci/golangci-lint-action@v6
uses: golangci/golangci-lint-action@v7
with:
problem-matchers: true
# ...
Expand All @@ -444,7 +445,7 @@ The default value is `false`.
<summary>Example</summary>

```yml
uses: golangci/golangci-lint-action@v6
uses: golangci/golangci-lint-action@v7
with:
skip-cache: true
# ...
Expand All @@ -464,7 +465,7 @@ The default value is `false`.
<summary>Example</summary>

```yml
uses: golangci/golangci-lint-action@v6
uses: golangci/golangci-lint-action@v7
with:
skip-save-cache: true
# ...
Expand All @@ -486,7 +487,7 @@ If set the number is `<= 0`, the cache will be always invalidate (Not recommende
<summary>Example</summary>

```yml
uses: golangci/golangci-lint-action@v6
uses: golangci/golangci-lint-action@v7
with:
cache-invalidation-interval: 15
# ...
Expand Down Expand Up @@ -515,7 +516,7 @@ permissions:
pull-requests: read
```
For annotations to work use the default `colored-line-number` output and either use `actions/setup-go` in the job or enable the internal [problem matchers](#problem-matchers).
For annotations to work use the default format output (`text`) and either use `actions/setup-go` in the job or enable the internal [problem matchers](#problem-matchers).

## Performance

Expand Down
4 changes: 2 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ inputs:
description: |
The version of golangci-lint to use.
When `install-mode` is:
- `binary` (default): the value can be v1.2 or v1.2.3 or `latest` to use the latest version.
- `goinstall`: the value can be v1.2.3, `latest`, or the hash of a commit.
- `binary` (default): the value can be v2.3 or v2.3.4 or `latest` to use the latest version.
- `goinstall`: the value can be v2.3.4, `latest`, or the hash of a commit.
- `none`: the value is ignored.
required: false
install-mode:
Expand Down
58 changes: 19 additions & 39 deletions dist/post_run/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit dec74fa

Please sign in to comment.