Skip to content

Commit 8e375c5

Browse files
committed
docs: improve options description and README
1 parent 3f6d2b9 commit 8e375c5

File tree

2 files changed

+54
-54
lines changed

2 files changed

+54
-54
lines changed

README.md

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
[![Build Status](https://github.com/golangci/golangci-lint-action/workflows/build-and-test/badge.svg)](https://github.com/golangci/golangci-lint-action/actions)
44

5-
It's the official GitHub action for [golangci-lint](https://github.com/golangci/golangci-lint) from its authors.
5+
It's the official GitHub Action for [golangci-lint](https://github.com/golangci/golangci-lint) from its authors.
66

77
The action runs [golangci-lint](https://github.com/golangci/golangci-lint) and reports issues from linters.
88

@@ -25,7 +25,7 @@ If you value it, consider supporting us; we appreciate it! :heart:
2525
We recommend running this action in a job separate from other jobs (`go test`, etc.)
2626
because different jobs [run in parallel](https://help.github.com/en/actions/getting-started-with-github-actions/core-concepts-for-github-actions#job).
2727

28-
Add `.github/workflows/golangci-lint.yml` with the following contents:
28+
Add a `.github/workflows/golangci-lint.yml` file with the following contents:
2929

3030
<details>
3131
<summary>Simple Example</summary>
@@ -41,7 +41,7 @@ on:
4141

4242
permissions:
4343
contents: read
44-
# Optional: allow read access to pull request. Use with `only-new-issues` option.
44+
# Optional: allow read access to pull requests. Use with `only-new-issues` option.
4545
# pull-requests: read
4646

4747
jobs:
@@ -75,7 +75,7 @@ on:
7575

7676
permissions:
7777
contents: read
78-
# Optional: allow read access to pull request. Use with `only-new-issues` option.
78+
# Optional: allow read access to pull requests. Use with `only-new-issues` option.
7979
# pull-requests: read
8080

8181
jobs:
@@ -214,7 +214,7 @@ jobs:
214214
with:
215215
go-version: ${{ inputs.go-version }}
216216
- id: set-modules
217-
shell: bash # require for Windows to be able to use $GITHUB_OUTPUT https://github.com/actions/runner/issues/2224
217+
shell: bash # required for Windows to be able to use $GITHUB_OUTPUT https://github.com/actions/runner/issues/2224
218218
run: echo "modules=$(go list -m -json | jq -s '.' | jq -c '[.[].Dir]')" >> $GITHUB_OUTPUT
219219
220220
golangci-lint:
@@ -264,7 +264,7 @@ You will also likely need to add the following `.gitattributes` file to ensure t
264264
The version of golangci-lint to use.
265265

266266
When `install-mode` is:
267-
* `binary` (default): the value can be v2.3 or v2.3.4 or `latest` to use the latest version.
267+
* `binary` (default): the value can be v2.3, v2.3.4, or `latest` to use the latest version.
268268
* `goinstall`: the value can be v2.3.4, `latest`, or the hash of a commit.
269269
* `none`: the value is ignored.
270270

@@ -304,7 +304,7 @@ with:
304304

305305
(optional)
306306

307-
When using `only-new-issues` option, the GitHub API is used, so a token is required.
307+
When using the `only-new-issues` option, the GitHub API is used, so a token is required.
308308

309309
By default, it uses the `github.token` from the action.
310310

@@ -326,8 +326,8 @@ with:
326326

327327
This option is `true` by default.
328328

329-
If the GitHub Action detects a configuration file, the validation will be performed unless this option is set to `false`.
330-
If there is no configuration file, the validation is skipped.
329+
If the GitHub Action detects a configuration file, validation will be performed unless this option is set to `false`.
330+
If there is no configuration file, validation is skipped.
331331

332332
The JSON Schema used to validate the configuration depends on the version of golangci-lint you are using.
333333

@@ -352,9 +352,9 @@ Show only new issues.
352352
The default value is `false`.
353353

354354
* `pull_request` and `pull_request_target`: the action gets the diff of the PR content from the [GitHub API](https://docs.github.com/en/rest/pulls/pulls?apiVersion=2022-11-28#get-a-pull-request) and uses it with `--new-from-patch`.
355-
* `push`: the action gets the diff of the push content (difference between commits before and after the push) from the [GitHub API](https://docs.github.com/en/rest/commits/commits?apiVersion=2022-11-28#compare-two-commits) and uses it with `--new-from-patch`.
356-
* `merge_group`: the action gets the diff by using `--new-from-rev` option (relies on git).
357-
You should add the option `fetch-depth: 0` to `actions/checkout` step.
355+
* `push`: the action gets the diff of the push content (the difference between commits before and after the push) from the [GitHub API](https://docs.github.com/en/rest/commits/commits?apiVersion=2022-11-28#compare-two-commits) and uses it with `--new-from-patch`.
356+
* `merge_group`: the action gets the diff by using the `--new-from-rev` option (relies on git).
357+
You should add the option `fetch-depth: 0` to the `actions/checkout` step.
358358

359359
<details>
360360
<summary>Example</summary>
@@ -372,7 +372,7 @@ with:
372372

373373
(optional)
374374

375-
Working directory, useful for monorepos.
375+
The golangci-lint working directory, useful for monorepos. The default is the project root.
376376

377377
<details>
378378
<summary>Example</summary>
@@ -406,7 +406,7 @@ golangci-lint command line arguments.
406406
uses: golangci/golangci-lint-action@v8
407407
with:
408408
# In some rare cases,
409-
# you could have to use `${{ github.workspace }}` as base directory to reference your configuration file.
409+
# you may need to use `${{ github.workspace }}` as the base directory to reference your configuration file.
410410
args: --config=/my/path/.golangci.yml --issues-exit-code=0
411411
# ...
412412
```
@@ -417,11 +417,11 @@ with:
417417

418418
(optional)
419419

420-
Force the usage of the embedded problem matchers.
420+
Forces the usage of the embedded problem matchers.
421421

422422
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`).
423423

424-
Works only with `text` format (the golangci-lint default).
424+
Works only with the `text` format (the golangci-lint default).
425425

426426
https://golangci-lint.run/usage/configuration/#output-configuration
427427

@@ -443,8 +443,8 @@ with:
443443

444444
(optional)
445445

446-
If set to `true`, then all caching functionality will be completely disabled,
447-
takes precedence over all other caching options.
446+
If set to `true`, all caching functionality will be completely disabled.
447+
This takes precedence over all other caching options.
448448

449449
The default value is `false`.
450450

@@ -484,11 +484,11 @@ with:
484484

485485
(optional)
486486

487-
Periodically invalidate the cache every `cache-invalidation-interval` days to ensure that outdated data is removed and fresh data is loaded.
487+
Periodically invalidate a cache every `cache-invalidation-interval` days to ensure that outdated data is removed and fresh data is loaded.
488488

489489
The default value is `7`.
490490

491-
If the number is `<= 0`, the cache will always be invalidated (Not recommended).
491+
If the number is `<= 0`, the cache will always be invalidated (not recommended).
492492

493493
<details>
494494
<summary>Example</summary>
@@ -506,11 +506,11 @@ with:
506506

507507
Currently, GitHub parses the action's output and creates [annotations](https://github.blog/2018-12-14-introducing-check-runs-and-annotations/).
508508

509-
The restrictions of annotations are the following:
509+
The restrictions of annotations are as follows:
510510

511-
1. Currently, they don't support Markdown formatting (see the [feature request](https://github.community/t5/GitHub-API-Development-and/Checks-Ability-to-include-Markdown-in-line-annotations/m-p/56704))
511+
1. Currently, they don't support Markdown formatting (see the [feature request](https://github.community/t5/GitHub-API-Development-and/Checks-Ability-to-include-Markdown-in-line-annotations/m-p/56704)).
512512
2. They aren't shown in the list of comments.
513-
If you would like to have comments - please, up-vote [the issue](https://github.com/golangci/golangci-lint-action/issues/5).
513+
If you would like to have comments, please up-vote [the issue](https://github.com/golangci/golangci-lint-action/issues/5).
514514
3. The number of annotations is [limited](https://github.com/actions/toolkit/blob/main/docs/problem-matchers.md#limitations).
515515

516516
Permissions required:
@@ -519,7 +519,7 @@ Permissions required:
519519
permissions:
520520
# Required: allow read access to the content for analysis.
521521
contents: read
522-
# Optional: allow read access to pull request. Use with `only-new-issues` option.
522+
# Optional: allow read access to pull requests. Use with `only-new-issues` option.
523523
pull-requests: read
524524
```
525525
@@ -531,42 +531,42 @@ The action was implemented with performance in mind:
531531

532532
1. We cache data from golangci-lint analysis between builds by using [@actions/cache](https://github.com/actions/toolkit/tree/HEAD/packages/cache).
533533
2. We don't use Docker because image pulling is slow.
534-
3. We do as much as we can in parallel, e.g. we download cache, and golangci-lint binary in parallel.
534+
3. We do as much as we can in parallel, e.g., we download the cache and the golangci-lint binary in parallel.
535535

536-
For example, in a repository of [golangci-lint](https://github.com/golangci/golangci-lint) running this action without the cache takes 50s, but with cache takes 14s:
536+
For example, in the [golangci-lint](https://github.com/golangci/golangci-lint) repository, running this action without the cache takes 50s, but with the cache it takes 14s:
537537
* in parallel:
538538
* 4s to restore 50 MB of cache
539539
* 1s to find and install `golangci-lint`
540540
* 1s to run `golangci-lint` (it takes 35s without cache)
541541

542542
## Internals
543543

544-
We use JavaScript-based action.
545-
We don't use Docker-based action because:
544+
We use a JavaScript-based action.
545+
We don't use a Docker-based action because:
546546

547-
1. Docker pulling is slow currently
548-
2. it's easier to use caching from [@actions/cache](https://github.com/actions/toolkit/tree/HEAD/packages/cache)
547+
1. Pulling Docker images is currently slow.
548+
2. It is easier to use caching from [@actions/cache](https://github.com/actions/toolkit/tree/HEAD/packages/cache).
549549

550-
We support different platforms, such as `ubuntu`, `macos`, and `windows` with `x32` and `x64` archs.
550+
We support different platforms, such as `ubuntu`, `macos`, and `windows` with `x32` and `x64` architectures.
551551

552-
Inside our action, we perform 3 steps:
552+
Inside our action, we perform three steps:
553553

554-
1. Setup environment running in parallel:
555-
* restore [cache](https://github.com/actions/cache) of previous analyses
556-
* fetch [action config](https://github.com/golangci/golangci-lint/blob/HEAD/assets/github-action-config.json) and find the latest `golangci-lint` patch version for needed version
557-
(users of this action can specify only minor version of `golangci-lint`).
558-
After that install [golangci-lint](https://github.com/golangci/golangci-lint) using [@actions/tool-cache](https://github.com/actions/toolkit/tree/HEAD/packages/tool-cache)
559-
2. Run `golangci-lint` with specified by user `args`
560-
3. Save cache for later builds
554+
1. Set up the environment in parallel:
555+
* Restore the [cache](https://github.com/actions/cache) from previous analyses.
556+
* Fetch the [action config](https://github.com/golangci/golangci-lint/blob/HEAD/assets/github-action-config.json) and find the latest `golangci-lint` patch version for the required version
557+
(users of this action can specify only the minor version of `golangci-lint`).
558+
After that, install [golangci-lint](https://github.com/golangci/golangci-lint) using [@actions/tool-cache](https://github.com/actions/toolkit/tree/HEAD/packages/tool-cache).
559+
2. Run `golangci-lint` with the arguments `args` specified by the user.
560+
3. Save the cache for later builds.
561561

562562
### Caching internals
563563

564564
1. We save and restore the following directory: `~/.cache/golangci-lint`.
565565
2. The primary caching key looks like `golangci-lint.cache-{runner_os}-{working_directory}-{interval_number}-{go.mod_hash}`.
566-
Interval number ensures that we periodically invalidate our cache (every 7 days).
567-
`go.mod` hash ensures that we invalidate the cache early - as soon as dependencies have changed.
566+
The interval number ensures that we periodically invalidate our cache (every 7 days).
567+
The `go.mod` hash ensures that we invalidate the cache early as soon as dependencies have changed.
568568
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):
569569
`golangci-lint.cache-{runner_os}-{working_directory}-{interval_number}-`.
570-
GitHub matches keys by prefix if we have no exact match for the primary cache.
570+
GitHub matches keys by prefix if there is no exact match for the primary cache.
571571

572572
This scheme is basic and needs improvements. Pull requests and ideas are welcome.

action.yml

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
# https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions
22
name: "Golangci-lint"
3-
description: "Official golangci-lint action with line-attached annotations for found issues, caching and parallel execution."
3+
description: "Official golangci-lint action with line-attached annotations for found issues, caching, and parallel execution."
44
author: "golangci"
55
inputs:
66
version:
77
description: |
88
The version of golangci-lint to use.
99
When `install-mode` is:
10-
- `binary` (default): the value can be v2.3 or v2.3.4 or `latest` to use the latest version.
10+
- `binary` (default): the value can be v2.3, v2.3.4, or `latest` to use the latest version.
1111
- `goinstall`: the value can be v2.3.4, `latest`, or the hash of a commit.
1212
- `none`: the value is ignored.
1313
required: false
@@ -16,42 +16,42 @@ inputs:
1616
default: "binary"
1717
required: false
1818
working-directory:
19-
description: "golangci-lint working directory, default is project root"
19+
description: "golangci-lint working directory. The default is the project root."
2020
required: false
2121
github-token:
22-
description: "the token is used for fetching patch of a pull request to show only new issues"
22+
description: "The token is used for fetching the patch of a pull request to show only new issues."
2323
default: ${{ github.token }}
2424
required: false
2525
verify:
26-
description: "if set to true and the action verify the configuration file against the JSONSchema"
26+
description: "If set to true, the action verifies the configuration file against the JSONSchema."
2727
default: 'true'
2828
required: false
2929
only-new-issues:
30-
description: "if set to true and the action runs on a pull request - the action outputs only newly found issues"
30+
description: "If set to true and the action runs on a pull request, the action outputs only newly found issues."
3131
default: 'false'
3232
required: false
3333
skip-cache:
3434
description: |
35-
if set to true then the all caching functionality will be complete disabled,
36-
takes precedence over all other caching options.
35+
If set to true, all caching functionality will be completely disabled.
36+
This takes precedence over all other caching options.
3737
default: 'false'
3838
required: false
3939
skip-save-cache:
4040
description: |
41-
if set to true then the action will not save any caches, but it may still
41+
If set to true, the action will not save any caches, but it may still
4242
restore existing caches, subject to other options.
4343
default: 'false'
4444
required: false
4545
problem-matchers:
46-
description: "Force the usage of the embedded problem matchers"
46+
description: "Force the usage of the embedded problem matchers."
4747
default: 'false'
4848
required: false
4949
args:
50-
description: "golangci-lint command line arguments"
50+
description: "golangci-lint command line arguments."
5151
default: ""
5252
required: false
5353
cache-invalidation-interval:
54-
description: "Periodically invalidate a cache because a new code being added. (number of days)"
54+
description: "Periodically invalidate a cache when new code is added (number of days)."
5555
default: '7'
5656
required: false
5757
runs:

0 commit comments

Comments
 (0)