Compare commits

...

42 Commits
v6.0.1 ... v6

Author SHA1 Message Date
aaa42aa062 feat: allow to skip golangci-lint installation (#1079) 2024-07-30 00:16:22 +02:00
9ec89731c3 build(deps): bump @types/node from 20.14.11 to 22.0.0 in the dependencies group (#1078) 2024-07-29 14:51:39 +02:00
58838cffc6 build(deps-dev): bump the dev-dependencies group with 3 updates (#1077) 2024-07-29 14:51:11 +02:00
9f3ba2c3a8 build(deps): bump @types/node from 20.14.10 to 20.14.11 in the dependencies group (#1075) 2024-07-22 13:13:46 +02:00
2bd7a04e91 build(deps-dev): bump the dev-dependencies group with 3 updates (#1074) 2024-07-22 13:13:20 +02:00
db819a10bd build(deps-dev): bump the dev-dependencies group with 3 updates (#1073) 2024-07-15 12:41:18 +02:00
d09fb0808a build(deps): bump @types/node from 20.14.9 to 20.14.10 in the dependencies group (#1072) 2024-07-08 13:50:27 +02:00
605617a3e2 build(deps-dev): bump the dev-dependencies group with 4 updates (#1071) 2024-07-08 13:50:01 +02:00
66f63c74bb chore: generate 2024-07-03 01:03:27 +02:00
2c01d264ab fix: home dir on Windows 2024-07-03 00:49:42 +02:00
d8028e1f20 build(deps): bump @types/node from 20.14.8 to 20.14.9 in the dependencies group (#1068) 2024-07-01 14:38:39 +02:00
a0231c4ff0 build(deps-dev): bump the dev-dependencies group with 2 updates (#1067) 2024-07-01 14:38:19 +02:00
e43020d72a build(deps-dev): bump the dev-dependencies group with 3 updates (#1065)
Co-authored-by: Fernandez Ludovic <ldez@users.noreply.github.com>
2024-06-24 14:17:02 +02:00
9e57efc106 build(deps): bump @types/node from 20.14.2 to 20.14.8 in the dependencies group (#1066) 2024-06-24 14:08:00 +02:00
27d925f9c0 docs: fix workflow example 2024-06-22 22:40:58 +02:00
24b3d93762 docs: fix workflow example path 2024-06-22 22:37:29 +02:00
26b1e83940 docs: clarify workflow example path 2024-06-22 22:36:44 +02:00
081b216ccf docs: add Go workspace examples (#1064) 2024-06-22 22:34:31 +02:00
0d98fecd83 build(deps-dev): bump the dev-dependencies group with 3 updates (#1063) 2024-06-17 14:07:20 +02:00
031a2fcd4a build(deps): bump @types/node from 20.14.0 to 20.14.2 in the dependencies group (#1062) 2024-06-10 12:55:17 +02:00
96843aea6d build(deps-dev): bump the dev-dependencies group with 3 updates (#1061) 2024-06-10 12:54:48 +02:00
8032b26298 build(deps-dev): bump the dev-dependencies group across 1 directory with 3 updates (#1053) 2024-06-03 12:25:39 +00:00
dfd6a77317 build(deps): bump @types/node from 20.12.12 to 20.14.0 in the dependencies group (#1051) 2024-06-03 14:13:35 +02:00
e1ff6fb1c1 docs: improve examples 2024-05-27 04:48:36 +02:00
4145754745 docs: add sponsoring links 2024-05-27 02:12:12 +02:00
16507ab8ef docs: improve workflow example 2024-05-26 21:19:24 +02:00
725e01551b docs: improve option examples 2024-05-26 21:16:11 +02:00
32b7e669bc chore: update lock (nodejs 20) 2024-05-24 20:13:29 +02:00
e2918bb1f8 build(deps-dev): bump the dev-dependencies group with 2 updates (#1047) 2024-05-24 19:50:28 +02:00
3f51204e49 chore: improve issues chooser 2024-05-24 19:22:56 +02:00
b7f3daa60e chore: fix typo 2024-05-24 19:20:15 +02:00
952b7b2e57 chore: improve issues chooser 2024-05-24 19:16:52 +02:00
7a82e5f967 chore: groups dependabot updates 2024-05-24 19:16:09 +02:00
4655d13902 chore: add contributing guide 2024-05-23 18:32:17 +02:00
182ce0be58 build(deps-dev): bump @typescript-eslint/parser from 7.8.0 to 7.9.0 (#1044) 2024-05-20 18:37:21 +02:00
bc05d62e37 docs: add explanation for github-token option 2024-05-20 18:31:17 +02:00
8a8f91e859 build(deps): bump @types/node from 20.12.11 to 20.12.12 (#1043) 2024-05-20 14:29:30 +02:00
34be59169b build(deps-dev): bump @typescript-eslint/eslint-plugin from 7.8.0 to 7.9.0 (#1042) 2024-05-20 14:29:08 +02:00
abbeba8940 build(deps): bump @types/node from 20.12.8 to 20.12.11 (#1041) 2024-05-13 12:09:47 +02:00
d7e9c664d4 docs: use a fixed version 2024-05-12 22:03:15 +02:00
42ebe7fde9 chore: generate 2024-05-10 03:49:44 +02:00
7b547992bc fix: remove debug logs 2024-05-10 03:47:36 +02:00
14 changed files with 11981 additions and 13625 deletions

25
.github/CONTRIBUTING.md vendored Normal file
View 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.

View File

@ -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>

View File

@ -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.

View File

@ -1,4 +1,4 @@
name: Feature request
name: 💡 Feature request
description: "Suggest an idea for this project."
body:
- type: checkboxes

View File

@ -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
View File

@ -10,20 +10,26 @@ The action runs [golangci-lint](https://github.com/golangci/golangci-lint) and r
![Logs](./static/colored-line-number.png)
## 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))
<!-- [![GitHub Sponsors](https://img.shields.io/badge/GitHub-Donate-blue?logo=github&style=for-the-badge)](https://github.com/sponsors/golangci) -->
[![Open Collective backers and sponsors](https://img.shields.io/badge/OpenCollective-Donate-blue?logo=opencollective&style=for-the-badge)](https://opencollective.com/golangci-lint)
[![Linter Authors](https://img.shields.io/badge/Linter_Authors-Donate-blue?style=for-the-badge)](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/).

View File

@ -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

File diff suppressed because it is too large Load Diff

10097
dist/run/index.js generated vendored

File diff suppressed because it is too large Load Diff

4891
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -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"
}
}

View File

@ -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 => {

View File

@ -38,6 +38,7 @@ const getAssetURL = (versionConfig: VersionConfig): string => {
export enum InstallMode {
Binary = "binary",
GoInstall = "goinstall",
None = "none",
}
type ExecRes = {

View File

@ -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}`)