Compare commits
42 Commits
Author | SHA1 | Date | |
---|---|---|---|
aaa42aa062 | |||
9ec89731c3 | |||
58838cffc6 | |||
9f3ba2c3a8 | |||
2bd7a04e91 | |||
db819a10bd | |||
d09fb0808a | |||
605617a3e2 | |||
66f63c74bb | |||
2c01d264ab | |||
d8028e1f20 | |||
a0231c4ff0 | |||
e43020d72a | |||
9e57efc106 | |||
27d925f9c0 | |||
24b3d93762 | |||
26b1e83940 | |||
081b216ccf | |||
0d98fecd83 | |||
031a2fcd4a | |||
96843aea6d | |||
8032b26298 | |||
dfd6a77317 | |||
e1ff6fb1c1 | |||
4145754745 | |||
16507ab8ef | |||
725e01551b | |||
32b7e669bc | |||
e2918bb1f8 | |||
3f51204e49 | |||
b7f3daa60e | |||
952b7b2e57 | |||
7a82e5f967 | |||
4655d13902 | |||
182ce0be58 | |||
bc05d62e37 | |||
8a8f91e859 | |||
34be59169b | |||
abbeba8940 | |||
d7e9c664d4 | |||
42ebe7fde9 | |||
7b547992bc |
25
.github/CONTRIBUTING.md
vendored
Normal file
25
.github/CONTRIBUTING.md
vendored
Normal file
@ -0,0 +1,25 @@
|
||||
## How to contribute
|
||||
|
||||
### Did you find a bug?
|
||||
|
||||
* **Ensure the bug was not already reported** by searching on GitHub under [Issues](https://github.com/golangci/golangci-lint-action/issues).
|
||||
|
||||
* If you're unable to find an open issue addressing the problem, [open a new one](https://github.com/golangci/golangci-lint-action/issues/new).
|
||||
Be sure to include a **title and clear description**, as much relevant information as possible,
|
||||
and a **code sample** or an **executable test case** demonstrating the expected behavior that is not occurring.
|
||||
|
||||
* **Do not open up a GitHub issue if the bug is a security vulnerability**,
|
||||
and instead to refer to our [security policy](https://github.com/golangci/golangci-lint-action?tab=security-ov-file).
|
||||
|
||||
### Do you intend to add a new feature or change an existing one?
|
||||
|
||||
* Suggest your change inside an [issue](https://github.com/golangci/golangci-lint-action/issues).
|
||||
|
||||
* Do not open a pull request on GitHub until you have collected positive feedback about the change.
|
||||
|
||||
### Did you write a patch that fixes a bug?
|
||||
|
||||
* Open a new GitHub pull request with the patch.
|
||||
|
||||
* Ensure the PR description clearly describes the problem and solution.
|
||||
Include the relevant issue number if applicable.
|
21
.github/ISSUE_TEMPLATE/bug_report.yml
vendored
21
.github/ISSUE_TEMPLATE/bug_report.yml
vendored
@ -1,4 +1,4 @@
|
||||
name: Bug Report
|
||||
name: 🐞 Bug Report
|
||||
description: "Create a report to help us improve."
|
||||
body:
|
||||
- type: checkboxes
|
||||
@ -36,14 +36,29 @@ body:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: config
|
||||
id: workflow-file
|
||||
attributes:
|
||||
label: Workflow file
|
||||
value: |-
|
||||
<details>
|
||||
|
||||
```yml
|
||||
<add your file content here>
|
||||
```
|
||||
<add you file here>
|
||||
|
||||
</details>
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: config
|
||||
attributes:
|
||||
label: Golangci-lint configuration
|
||||
value: |-
|
||||
<details>
|
||||
|
||||
```yml
|
||||
<add your file content here>
|
||||
```
|
||||
|
||||
</details>
|
||||
|
17
.github/ISSUE_TEMPLATE/config.yml
vendored
17
.github/ISSUE_TEMPLATE/config.yml
vendored
@ -1,11 +1,14 @@
|
||||
blank_issues_enabled: false
|
||||
contact_links:
|
||||
- name: Questions
|
||||
url: https://github.com/golangci/golangci-lint-action/discussions
|
||||
about: If you have a question, or are looking for advice, please post on our Discussions forum!
|
||||
- name: golangci-lint main repository
|
||||
url: https://github.com/golangci/golangci-lint
|
||||
about: The main repository of golangci-lint.
|
||||
- name: golangci-lint documentation
|
||||
- name: 📖 Golangci-lint documentation
|
||||
url: https://golangci-lint.run
|
||||
about: Please take a look to our documentation.
|
||||
- name: ❓ Questions
|
||||
url: https://github.com/golangci/golangci-lint-action/discussions
|
||||
about: If you have a question, or are looking for advice, please post on our Discussions forum!
|
||||
- name: 💬 Chat on Slack
|
||||
url: https://gophers.slack.com/archives/CS0TBRKPC
|
||||
about: Maybe chatting with the community can help
|
||||
- name: 🏡 Golangci-lint main repository
|
||||
url: https://github.com/golangci/golangci-lint
|
||||
about: The main repository of golangci-lint.
|
||||
|
2
.github/ISSUE_TEMPLATE/feature_request.yml
vendored
2
.github/ISSUE_TEMPLATE/feature_request.yml
vendored
@ -1,4 +1,4 @@
|
||||
name: Feature request
|
||||
name: 💡 Feature request
|
||||
description: "Suggest an idea for this project."
|
||||
body:
|
||||
- type: checkboxes
|
||||
|
5
.github/dependabot.yml
vendored
5
.github/dependabot.yml
vendored
@ -6,5 +6,10 @@ updates:
|
||||
interval: weekly
|
||||
- package-ecosystem: npm
|
||||
directory: "/"
|
||||
groups:
|
||||
dev-dependencies:
|
||||
dependency-type: development
|
||||
dependencies:
|
||||
dependency-type: production
|
||||
schedule:
|
||||
interval: weekly
|
||||
|
409
README.md
409
README.md
@ -10,20 +10,26 @@ The action runs [golangci-lint](https://github.com/golangci/golangci-lint) and r
|
||||
|
||||

|
||||
|
||||
## Compatibility
|
||||
## Supporting Us
|
||||
|
||||
* `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`.
|
||||
The `skip-go-installation` option has been removed.
|
||||
* `v2.0.0+` works with `golangci-lint` version >= `v1.28.3`
|
||||
* `v1.2.2` is deprecated due to we forgot to change the minimum version of `golangci-lint` to `v1.28.3` ([issue](https://github.com/golangci/golangci-lint-action/issues/39))
|
||||
* `v1.2.1` works with `golangci-lint` version >= `v1.14.0` ([issue](https://github.com/golangci/golangci-lint-action/issues/39))
|
||||
<!-- [](https://github.com/sponsors/golangci) -->
|
||||
[](https://opencollective.com/golangci-lint)
|
||||
[](https://golangci-lint.run/product/thanks/)
|
||||
|
||||
`golangci-lint` is a free and open-source project built by volunteers.
|
||||
|
||||
If you value it, consider supporting us, we appreciate it! :heart:
|
||||
|
||||
## How to use
|
||||
|
||||
We recommend running this action in a job separate from other jobs (`go test`, etc.)
|
||||
because different jobs [run in parallel](https://help.github.com/en/actions/getting-started-with-github-actions/core-concepts-for-github-actions#job).
|
||||
|
||||
Add `.github/workflows/golangci-lint.yml` with the following contents:
|
||||
|
||||
<details>
|
||||
<summary>Simple Example</summary>
|
||||
|
||||
```yaml
|
||||
name: golangci-lint
|
||||
on:
|
||||
@ -46,21 +52,17 @@ jobs:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version: '1.22'
|
||||
go-version: stable
|
||||
- name: golangci-lint
|
||||
uses: golangci/golangci-lint-action@v6
|
||||
with:
|
||||
version: latest
|
||||
version: v1.59
|
||||
```
|
||||
|
||||
We recommend running this action in a job separate from other jobs (`go test`, etc.)
|
||||
because different jobs [run in parallel](https://help.github.com/en/actions/getting-started-with-github-actions/core-concepts-for-github-actions#job).
|
||||
</details>
|
||||
|
||||
### Multiple OS Support
|
||||
|
||||
If you need to run linters for specific operating systems, you will need to use the action `>=v2`.
|
||||
|
||||
Here is a sample configuration file:
|
||||
<details>
|
||||
<summary>Multiple OS Example</summary>
|
||||
|
||||
```yaml
|
||||
name: golangci-lint
|
||||
@ -80,7 +82,7 @@ jobs:
|
||||
golangci:
|
||||
strategy:
|
||||
matrix:
|
||||
go: ['1.22']
|
||||
go: [stable]
|
||||
os: [ubuntu-latest, macos-latest, windows-latest]
|
||||
name: lint
|
||||
runs-on: ${{ matrix.os }}
|
||||
@ -92,7 +94,7 @@ jobs:
|
||||
- name: golangci-lint
|
||||
uses: golangci/golangci-lint-action@v6
|
||||
with:
|
||||
version: latest
|
||||
version: v1.59
|
||||
```
|
||||
|
||||
You will also likely need to add the following `.gitattributes` file to ensure that line endings for Windows builds are properly formatted:
|
||||
@ -101,6 +103,156 @@ You will also likely need to add the following `.gitattributes` file to ensure t
|
||||
*.go text eol=lf
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary>Go Workspace Example</summary>
|
||||
|
||||
```yaml
|
||||
name: golangci-lint
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
push:
|
||||
branches:
|
||||
- "main"
|
||||
- "master"
|
||||
|
||||
env:
|
||||
GO_VERSION: stable
|
||||
GOLANGCI_LINT_VERSION: v1.59
|
||||
|
||||
jobs:
|
||||
detect-modules:
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
modules: ${{ steps.set-modules.outputs.modules }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version: ${{ env.GO_VERSION }}
|
||||
- id: set-modules
|
||||
run: echo "modules=$(go list -m -json | jq -s '.' | jq -c '[.[].Dir]')" >> $GITHUB_OUTPUT
|
||||
|
||||
golangci-lint:
|
||||
needs: detect-modules
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
modules: ${{ fromJSON(needs.detect-modules.outputs.modules) }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version: ${{ env.GO_VERSION }}
|
||||
- name: golangci-lint ${{ matrix.modules }}
|
||||
uses: golangci/golangci-lint-action@v6
|
||||
with:
|
||||
version: ${{ env.GOLANGCI_LINT_VERSION }}
|
||||
working-directory: ${{ matrix.modules }}
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary>Go Workspace Example (Multiple OS)</summary>
|
||||
|
||||
```yaml
|
||||
# ./.github/workflows/golangci-lint.yml
|
||||
name: golangci-lint (multi OS)
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
push:
|
||||
branches:
|
||||
- "main"
|
||||
- "master"
|
||||
|
||||
jobs:
|
||||
golangci-lint:
|
||||
strategy:
|
||||
matrix:
|
||||
go-version: [ stable, oldstable ]
|
||||
os: [ubuntu-latest, macos-latest, windows-latest]
|
||||
uses: ./.github/workflows/.golangci-lint-reusable.yml
|
||||
with:
|
||||
os: ${{ matrix.os }}
|
||||
go-version: ${{ matrix.go-version }}
|
||||
golangci-lint-version: v1.59
|
||||
```
|
||||
|
||||
```yaml
|
||||
# ./.github/workflows/.golangci-lint-reusable.yml
|
||||
name: golangci-lint-reusable
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
inputs:
|
||||
os:
|
||||
description: 'OS'
|
||||
required: true
|
||||
type: string
|
||||
go-version:
|
||||
description: 'Go version'
|
||||
required: true
|
||||
type: string
|
||||
default: stable
|
||||
golangci-lint-version:
|
||||
description: 'Golangci-lint version'
|
||||
type: string
|
||||
default: 'v1.59.1'
|
||||
|
||||
jobs:
|
||||
detect-modules:
|
||||
runs-on: ${{ inputs.os }}
|
||||
outputs:
|
||||
modules: ${{ steps.set-modules.outputs.modules }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version: ${{ inputs.go-version }}
|
||||
- id: set-modules
|
||||
shell: bash # require for Windows to be able to use $GITHUB_OUTPUT https://github.com/actions/runner/issues/2224
|
||||
run: echo "modules=$(go list -m -json | jq -s '.' | jq -c '[.[].Dir]')" >> $GITHUB_OUTPUT
|
||||
|
||||
golangci-lint:
|
||||
needs: detect-modules
|
||||
runs-on: ${{ inputs.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
modules: ${{ fromJSON(needs.detect-modules.outputs.modules) }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version: ${{ inputs.go-version }}
|
||||
- name: golangci-lint ${{ matrix.modules }}
|
||||
uses: golangci/golangci-lint-action@v6
|
||||
with:
|
||||
version: ${{ inputs.golangci-lint-version }}
|
||||
working-directory: ${{ matrix.modules }}
|
||||
```
|
||||
|
||||
You will also likely need to add the following `.gitattributes` file to ensure that line endings for Windows builds are properly formatted:
|
||||
|
||||
```.gitattributes
|
||||
*.go text eol=lf
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
## Compatibility
|
||||
|
||||
* `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`.
|
||||
The `skip-go-installation` option has been removed.
|
||||
* `v2.0.0+` works with `golangci-lint` version >= `v1.28.3`
|
||||
* `v1.2.2` is deprecated due to we forgot to change the minimum version of `golangci-lint` to `v1.28.3` ([issue](https://github.com/golangci/golangci-lint-action/issues/39))
|
||||
* `v1.2.1` works with `golangci-lint` version >= `v1.14.0` ([issue](https://github.com/golangci/golangci-lint-action/issues/39))
|
||||
|
||||
## Options
|
||||
|
||||
### `version`
|
||||
@ -109,24 +261,34 @@ 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.
|
||||
* When `install-mode` is `goinstall` the value can be v1.2.3, `latest`, or the hash of a commit.
|
||||
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.
|
||||
* `none`: the value is ignored.
|
||||
|
||||
<details>
|
||||
<summary>Example</summary>
|
||||
|
||||
```yml
|
||||
uses: golangci/golangci-lint-action@v6
|
||||
with:
|
||||
version: latest
|
||||
version: v1.58
|
||||
# ...
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
### `install-mode`
|
||||
|
||||
(optional)
|
||||
|
||||
The mode to install golangci-lint: it can be `binary` or `goinstall`.
|
||||
The mode to install golangci-lint: it can be `binary`, `goinstall`, or `none`.
|
||||
|
||||
The default value is `binary`.
|
||||
|
||||
<details>
|
||||
<summary>Example</summary>
|
||||
|
||||
```yml
|
||||
uses: golangci/golangci-lint-action@v6
|
||||
with:
|
||||
@ -134,6 +296,28 @@ with:
|
||||
# ...
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
### `github-token`
|
||||
|
||||
(optional)
|
||||
|
||||
When using `only-new-issues` option, the GitHub API is used, so a token is required.
|
||||
|
||||
By default, it uses the `github.token` from the action.
|
||||
|
||||
<details>
|
||||
<summary>Example</summary>
|
||||
|
||||
```yml
|
||||
uses: golangci/golangci-lint-action@v6
|
||||
with:
|
||||
github-token: xxx
|
||||
# ...
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
### `only-new-issues`
|
||||
|
||||
(optional)
|
||||
@ -142,6 +326,14 @@ Show only new issues.
|
||||
|
||||
The default value is `false`.
|
||||
|
||||
* `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 use it with `--new-from-patch`.
|
||||
* `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 use it with `--new-from-patch`.
|
||||
* `merge_group`: the action gets the diff by using `--new-from-rev` option (relies on git).
|
||||
You should add the option `fetch-depth: 0` to `actions/checkout` step.
|
||||
|
||||
<details>
|
||||
<summary>Example</summary>
|
||||
|
||||
```yml
|
||||
uses: golangci/golangci-lint-action@v6
|
||||
with:
|
||||
@ -149,10 +341,7 @@ with:
|
||||
# ...
|
||||
```
|
||||
|
||||
* `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 use it with `--new-from-patch`.
|
||||
* `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 use it with `--new-from-patch`.
|
||||
* `merge_group`: the action gets the diff by using `--new-from-rev` option (relies on git).
|
||||
You should add the option `fetch-depth: 0` to `actions/checkout` step.
|
||||
</details>
|
||||
|
||||
### `working-directory`
|
||||
|
||||
@ -160,6 +349,9 @@ with:
|
||||
|
||||
Working directory, useful for monorepos.
|
||||
|
||||
<details>
|
||||
<summary>Example</summary>
|
||||
|
||||
```yml
|
||||
uses: golangci/golangci-lint-action@v6
|
||||
with:
|
||||
@ -167,74 +359,7 @@ with:
|
||||
# ...
|
||||
```
|
||||
|
||||
### `skip-cache`
|
||||
|
||||
(optional)
|
||||
|
||||
If set to `true`, then all caching functionality will be completely disabled,
|
||||
takes precedence over all other caching options.
|
||||
|
||||
The default value is `false`.
|
||||
|
||||
```yml
|
||||
uses: golangci/golangci-lint-action@v6
|
||||
with:
|
||||
skip-cache: true
|
||||
# ...
|
||||
```
|
||||
|
||||
### `skip-save-cache`
|
||||
|
||||
(optional)
|
||||
|
||||
If set to `true`, caches will not be saved, but they may still be restored, required `skip-cache: false`.
|
||||
|
||||
The default value is `false`.
|
||||
|
||||
```yml
|
||||
uses: golangci/golangci-lint-action@v6
|
||||
with:
|
||||
skip-save-cache: true
|
||||
# ...
|
||||
```
|
||||
|
||||
### `cache-invalidation-interval`
|
||||
|
||||
(optional)
|
||||
|
||||
Periodically invalidate the cache every `cache-invalidation-interval` days to ensure that outdated data is removed and fresh data is loaded.
|
||||
|
||||
The default value is `7`.
|
||||
|
||||
```yml
|
||||
uses: golangci/golangci-lint-action@v6
|
||||
with:
|
||||
cache-invalidation-interval: 15
|
||||
# ...
|
||||
```
|
||||
|
||||
If set the number is `<= 0`, the cache will be always invalidate (Not recommended).
|
||||
|
||||
### `problem-matchers`
|
||||
|
||||
(optional)
|
||||
|
||||
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`).
|
||||
|
||||
Works only with `colored-line-number` (the golangci-lint default).
|
||||
|
||||
https://golangci-lint.run/usage/configuration/#output-configuration
|
||||
|
||||
The default value is `false`.
|
||||
|
||||
```yml
|
||||
uses: golangci/golangci-lint-action@v6
|
||||
with:
|
||||
problem-matchers: true
|
||||
# ...
|
||||
```
|
||||
</details>
|
||||
|
||||
### `args`
|
||||
|
||||
@ -245,6 +370,9 @@ golangci-lint command line arguments.
|
||||
Note: By default, the `.golangci.yml` file should be at the root of the repository.
|
||||
The location of the configuration file can be changed by using `--config=`
|
||||
|
||||
<details>
|
||||
<summary>Example</summary>
|
||||
|
||||
```yml
|
||||
uses: golangci/golangci-lint-action@v6
|
||||
with:
|
||||
@ -252,6 +380,97 @@ with:
|
||||
# ...
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
### `problem-matchers`
|
||||
|
||||
(optional)
|
||||
|
||||
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`).
|
||||
|
||||
Works only with `colored-line-number` (the golangci-lint default).
|
||||
|
||||
https://golangci-lint.run/usage/configuration/#output-configuration
|
||||
|
||||
The default value is `false`.
|
||||
|
||||
<details>
|
||||
<summary>Example</summary>
|
||||
|
||||
```yml
|
||||
uses: golangci/golangci-lint-action@v6
|
||||
with:
|
||||
problem-matchers: true
|
||||
# ...
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
### `skip-cache`
|
||||
|
||||
(optional)
|
||||
|
||||
If set to `true`, then all caching functionality will be completely disabled,
|
||||
takes precedence over all other caching options.
|
||||
|
||||
The default value is `false`.
|
||||
|
||||
<details>
|
||||
<summary>Example</summary>
|
||||
|
||||
```yml
|
||||
uses: golangci/golangci-lint-action@v6
|
||||
with:
|
||||
skip-cache: true
|
||||
# ...
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
### `skip-save-cache`
|
||||
|
||||
(optional)
|
||||
|
||||
If set to `true`, caches will not be saved, but they may still be restored, required `skip-cache: false`.
|
||||
|
||||
The default value is `false`.
|
||||
|
||||
<details>
|
||||
<summary>Example</summary>
|
||||
|
||||
```yml
|
||||
uses: golangci/golangci-lint-action@v6
|
||||
with:
|
||||
skip-save-cache: true
|
||||
# ...
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
### `cache-invalidation-interval`
|
||||
|
||||
(optional)
|
||||
|
||||
Periodically invalidate the cache every `cache-invalidation-interval` days to ensure that outdated data is removed and fresh data is loaded.
|
||||
|
||||
The default value is `7`.
|
||||
|
||||
If set the number is `<= 0`, the cache will be always invalidate (Not recommended).
|
||||
|
||||
<details>
|
||||
<summary>Example</summary>
|
||||
|
||||
```yml
|
||||
uses: golangci/golangci-lint-action@v6
|
||||
with:
|
||||
cache-invalidation-interval: 15
|
||||
# ...
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
## Annotations
|
||||
|
||||
Currently, GitHub parses the action's output and creates [annotations](https://github.blog/2018-12-14-introducing-check-runs-and-annotations/).
|
||||
|
@ -6,11 +6,13 @@ inputs:
|
||||
version:
|
||||
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.
|
||||
When `install-mode` is `goinstall` the value can be v1.2.3, `latest`, or the hash of a commit.
|
||||
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.
|
||||
- `none`: the value is ignored.
|
||||
required: false
|
||||
install-mode:
|
||||
description: "The mode to install golangci-lint. It can be 'binary' or 'goinstall'."
|
||||
description: "The mode to install golangci-lint. It can be 'binary', 'goinstall', or 'none'."
|
||||
default: "binary"
|
||||
required: false
|
||||
working-directory:
|
||||
|
10097
dist/post_run/index.js
generated
vendored
10097
dist/post_run/index.js
generated
vendored
File diff suppressed because it is too large
Load Diff
10097
dist/run/index.js
generated
vendored
10097
dist/run/index.js
generated
vendored
File diff suppressed because it is too large
Load Diff
4891
package-lock.json
generated
4891
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
18
package.json
18
package.json
@ -30,21 +30,23 @@
|
||||
"@actions/github": "^6.0.0",
|
||||
"@actions/http-client": "^2.2.1",
|
||||
"@actions/tool-cache": "^2.0.1",
|
||||
"@types/node": "^20.12.8",
|
||||
"@types/node": "^22.0.0",
|
||||
"@types/semver": "^7.5.8",
|
||||
"@types/tmp": "^0.2.6",
|
||||
"tmp": "^0.2.3"
|
||||
"@types/which": "^3.0.4",
|
||||
"tmp": "^0.2.3",
|
||||
"which": "^4.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@typescript-eslint/eslint-plugin": "^7.8.0",
|
||||
"@typescript-eslint/parser": "^7.8.0",
|
||||
"@typescript-eslint/eslint-plugin": "^7.17.0",
|
||||
"@typescript-eslint/parser": "^7.17.0",
|
||||
"@vercel/ncc": "^0.38.1",
|
||||
"eslint": "^8.57.0",
|
||||
"eslint-config-prettier": "^9.1.0",
|
||||
"eslint-plugin-import": "^2.29.1",
|
||||
"eslint-plugin-prettier": "^5.1.3",
|
||||
"eslint-plugin-simple-import-sort": "^12.1.0",
|
||||
"prettier": "^3.2.5",
|
||||
"typescript": "^5.4.5"
|
||||
"eslint-plugin-prettier": "^5.2.1",
|
||||
"eslint-plugin-simple-import-sort": "^12.1.1",
|
||||
"prettier": "^3.3.3",
|
||||
"typescript": "^5.5.4"
|
||||
}
|
||||
}
|
||||
|
@ -20,7 +20,9 @@ function checksumFile(hashName: string, path: string): Promise<string> {
|
||||
const pathExists = async (path: string): Promise<boolean> => !!(await fs.promises.stat(path).catch(() => false))
|
||||
|
||||
const getLintCacheDir = (): string => {
|
||||
return path.resolve(`${process.env.HOME}/.cache/golangci-lint`)
|
||||
const home = process.platform === "win32" ? process.env.USERPROFILE : process.env.HOME
|
||||
|
||||
return path.resolve(`${home}`, `.cache`, `golangci-lint`)
|
||||
}
|
||||
|
||||
const getIntervalKey = (invalidationIntervalDays: number): string => {
|
||||
|
@ -38,6 +38,7 @@ const getAssetURL = (versionConfig: VersionConfig): string => {
|
||||
export enum InstallMode {
|
||||
Binary = "binary",
|
||||
GoInstall = "goinstall",
|
||||
None = "none",
|
||||
}
|
||||
|
||||
type ExecRes = {
|
||||
|
11
src/run.ts
11
src/run.ts
@ -6,6 +6,7 @@ import * as fs from "fs"
|
||||
import * as path from "path"
|
||||
import { dir } from "tmp"
|
||||
import { promisify } from "util"
|
||||
import which from "which"
|
||||
|
||||
import { restoreCache, saveCache } from "./cache"
|
||||
import { installLint, InstallMode } from "./install"
|
||||
@ -22,6 +23,15 @@ function isOnlyNewIssues(): boolean {
|
||||
|
||||
async function prepareLint(): Promise<string> {
|
||||
const mode = core.getInput("install-mode").toLowerCase()
|
||||
|
||||
if (mode === InstallMode.None) {
|
||||
const bin = await which("golangci-lint", { nothrow: true })
|
||||
if (!bin) {
|
||||
throw new Error("golangci-lint binary not found in the PATH")
|
||||
}
|
||||
return bin
|
||||
}
|
||||
|
||||
const versionConfig = await findLintVersion(<InstallMode>mode)
|
||||
|
||||
return await installLint(versionConfig, <InstallMode>mode)
|
||||
@ -41,7 +51,6 @@ async function fetchPatch(): Promise<string> {
|
||||
case `push`:
|
||||
return await fetchPushPatch(ctx)
|
||||
case `merge_group`:
|
||||
core.info(JSON.stringify(ctx.payload))
|
||||
return ``
|
||||
default:
|
||||
core.info(`Not fetching patch for showing only new issues because it's not a pull request context: event name is ${ctx.eventName}`)
|
||||
|
Reference in New Issue
Block a user