Compare commits
7 Commits
Author | SHA1 | Date | |
---|---|---|---|
d9c9b53e53 | |||
aebff4bd9c | |||
2bff406277 | |||
7a6f31107b | |||
57c4c9d189 | |||
3519a25e89 | |||
d073fb8ea7 |
11
.github/workflows/test.yml
vendored
11
.github/workflows/test.yml
vendored
@ -52,8 +52,8 @@ jobs:
|
|||||||
version:
|
version:
|
||||||
- ""
|
- ""
|
||||||
- "latest"
|
- "latest"
|
||||||
- "v1.56"
|
- "v1.58"
|
||||||
- "v1.56.1"
|
- "v1.58.0"
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
permissions:
|
permissions:
|
||||||
contents: read
|
contents: read
|
||||||
@ -63,7 +63,6 @@ jobs:
|
|||||||
- uses: actions/setup-go@v5
|
- uses: actions/setup-go@v5
|
||||||
with:
|
with:
|
||||||
go-version: oldstable
|
go-version: oldstable
|
||||||
cache: false # setup-go v4 caches by default
|
|
||||||
- uses: ./
|
- uses: ./
|
||||||
with:
|
with:
|
||||||
version: ${{ matrix.version }}
|
version: ${{ matrix.version }}
|
||||||
@ -81,8 +80,8 @@ jobs:
|
|||||||
version:
|
version:
|
||||||
- ""
|
- ""
|
||||||
- "latest"
|
- "latest"
|
||||||
- "v1.56.1"
|
- "v1.58.0"
|
||||||
- "bf5008a11acf2da5fe76716eb21d808499e079fa"
|
- "4bf574a12bb61234e28e3d6172be6ed95b0e8baf"
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
permissions:
|
permissions:
|
||||||
contents: read
|
contents: read
|
||||||
@ -92,7 +91,6 @@ jobs:
|
|||||||
- uses: actions/setup-go@v5
|
- uses: actions/setup-go@v5
|
||||||
with:
|
with:
|
||||||
go-version: oldstable
|
go-version: oldstable
|
||||||
cache: false # setup-go v4 caches by default
|
|
||||||
- uses: ./
|
- uses: ./
|
||||||
with:
|
with:
|
||||||
version: ${{ matrix.version }}
|
version: ${{ matrix.version }}
|
||||||
@ -116,7 +114,6 @@ jobs:
|
|||||||
- uses: actions/setup-go@v5
|
- uses: actions/setup-go@v5
|
||||||
with:
|
with:
|
||||||
go-version: oldstable
|
go-version: oldstable
|
||||||
cache: false # setup-go v4 caches by default
|
|
||||||
- uses: ./
|
- uses: ./
|
||||||
with:
|
with:
|
||||||
working-directory: sample-go-mod
|
working-directory: sample-go-mod
|
||||||
|
159
README.md
159
README.md
@ -43,39 +43,11 @@ jobs:
|
|||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- uses: actions/setup-go@v5
|
- uses: actions/setup-go@v5
|
||||||
with:
|
with:
|
||||||
go-version: '1.21'
|
go-version: '1.22'
|
||||||
- name: golangci-lint
|
- name: golangci-lint
|
||||||
uses: golangci/golangci-lint-action@v5
|
uses: golangci/golangci-lint-action@v5
|
||||||
with:
|
with:
|
||||||
# Require: The version of golangci-lint to use.
|
version: latest
|
||||||
# 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.
|
|
||||||
version: v1.57
|
|
||||||
|
|
||||||
# Optional: working directory, useful for monorepos
|
|
||||||
# working-directory: somedir
|
|
||||||
|
|
||||||
# Optional: 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=`
|
|
||||||
# args: --timeout=30m --config=/my/path/.golangci.yml --issues-exit-code=0
|
|
||||||
|
|
||||||
# Optional: Show only new issues.
|
|
||||||
# If you are using `merge_group` event (merge queue) you should add the option `fetch-depth: 0` to `actions/checkout` step.
|
|
||||||
# The default value is `false`.
|
|
||||||
# only-new-issues: true
|
|
||||||
|
|
||||||
# Optional: if set to true, then all caching functionality will be completely disabled,
|
|
||||||
# takes precedence over all other caching options.
|
|
||||||
# skip-cache: true
|
|
||||||
|
|
||||||
# Optional: if set to true, caches will not be saved, but they may still be restored,
|
|
||||||
# subject to other options
|
|
||||||
# skip-save-cache: true
|
|
||||||
|
|
||||||
# Optional: The mode to install golangci-lint. It can be 'binary' or 'goinstall'.
|
|
||||||
# install-mode: "goinstall"
|
|
||||||
```
|
```
|
||||||
|
|
||||||
We recommend running this action in a job separate from other jobs (`go test`, etc.)
|
We recommend running this action in a job separate from other jobs (`go test`, etc.)
|
||||||
@ -105,7 +77,7 @@ jobs:
|
|||||||
golangci:
|
golangci:
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
go: ['1.21']
|
go: ['1.22']
|
||||||
os: [ubuntu-latest, macos-latest, windows-latest]
|
os: [ubuntu-latest, macos-latest, windows-latest]
|
||||||
name: lint
|
name: lint
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
@ -117,35 +89,7 @@ jobs:
|
|||||||
- name: golangci-lint
|
- name: golangci-lint
|
||||||
uses: golangci/golangci-lint-action@v5
|
uses: golangci/golangci-lint-action@v5
|
||||||
with:
|
with:
|
||||||
# Require: The version of golangci-lint to use.
|
version: latest
|
||||||
# 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.
|
|
||||||
version: v1.57
|
|
||||||
|
|
||||||
# Optional: working directory, useful for monorepos
|
|
||||||
# working-directory: somedir
|
|
||||||
|
|
||||||
# Optional: 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=`
|
|
||||||
# args: --timeout=30m --config=/my/path/.golangci.yml --issues-exit-code=0
|
|
||||||
|
|
||||||
# Optional: Show only new issues.
|
|
||||||
# If you are using `merge_group` event (merge queue) you should add the option `fetch-depth: 0` to `actions/checkout` step.
|
|
||||||
# The default value is `false`.
|
|
||||||
# only-new-issues: true
|
|
||||||
|
|
||||||
# Optional: if set to true, then all caching functionality will be completely disabled,
|
|
||||||
# takes precedence over all other caching options.
|
|
||||||
# skip-cache: true
|
|
||||||
|
|
||||||
# Optional: if set to true, caches will not be saved, but they may still be restored,
|
|
||||||
# subject to other options
|
|
||||||
# skip-save-cache: true
|
|
||||||
|
|
||||||
# Optional: The mode to install golangci-lint. It can be 'binary' or 'goinstall'.
|
|
||||||
# install-mode: "goinstall"
|
|
||||||
```
|
```
|
||||||
|
|
||||||
You will also likely need to add the following `.gitattributes` file to ensure that line endings for Windows builds are properly formatted:
|
You will also likely need to add the following `.gitattributes` file to ensure that line endings for Windows builds are properly formatted:
|
||||||
@ -154,7 +98,95 @@ You will also likely need to add the following `.gitattributes` file to ensure t
|
|||||||
*.go text eol=lf
|
*.go text eol=lf
|
||||||
```
|
```
|
||||||
|
|
||||||
## Comments and Annotations
|
## Options
|
||||||
|
|
||||||
|
`version`: (required) 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.
|
||||||
|
|
||||||
|
```yml
|
||||||
|
uses: golangci/golangci-lint-action@v5
|
||||||
|
with:
|
||||||
|
version: latest
|
||||||
|
# ...
|
||||||
|
```
|
||||||
|
|
||||||
|
`install-mode`: (optional) The mode to install golangci-lint.
|
||||||
|
It can be `binary` or `goinstall`.
|
||||||
|
The default value is `binary`.
|
||||||
|
|
||||||
|
```yml
|
||||||
|
uses: golangci/golangci-lint-action@v5
|
||||||
|
with:
|
||||||
|
install-mode: "goinstall"
|
||||||
|
# ...
|
||||||
|
```
|
||||||
|
|
||||||
|
`only-new-issues`: (optional) Show only new issues.
|
||||||
|
If you are using `merge_group` event (merge queue) you should add the option `fetch-depth: 0` to `actions/checkout` step.
|
||||||
|
The default value is `false`.
|
||||||
|
|
||||||
|
```yml
|
||||||
|
uses: golangci/golangci-lint-action@v5
|
||||||
|
with:
|
||||||
|
only-new-issues: true
|
||||||
|
# ...
|
||||||
|
```
|
||||||
|
|
||||||
|
`working-directory`: (optional) working directory, useful for monorepos.
|
||||||
|
|
||||||
|
```yml
|
||||||
|
uses: golangci/golangci-lint-action@v5
|
||||||
|
with:
|
||||||
|
working-directory: somedir
|
||||||
|
# ...
|
||||||
|
```
|
||||||
|
|
||||||
|
`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@v5
|
||||||
|
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@v5
|
||||||
|
with:
|
||||||
|
skip-save-cache: true
|
||||||
|
# ...
|
||||||
|
```
|
||||||
|
|
||||||
|
`annotations`: (optional) To enable/disable GitHub Action annotations.
|
||||||
|
If disabled (`false`), the output format(s) will follow the golangci-lint configuration file and use the same default as golangci-lint (i.e. `colored-line-number`).
|
||||||
|
https://golangci-lint.run/usage/configuration/#output-configuration
|
||||||
|
The default value is `true`.
|
||||||
|
|
||||||
|
```yml
|
||||||
|
uses: golangci/golangci-lint-action@v5
|
||||||
|
with:
|
||||||
|
annotations: false
|
||||||
|
# ...
|
||||||
|
```
|
||||||
|
|
||||||
|
`args`: (optional) 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=`
|
||||||
|
|
||||||
|
```yml
|
||||||
|
uses: golangci/golangci-lint-action@v5
|
||||||
|
with:
|
||||||
|
args: --timeout=30m --config=/my/path/.golangci.yml --issues-exit-code=0
|
||||||
|
# ...
|
||||||
|
```
|
||||||
|
|
||||||
|
## Annotations
|
||||||
|
|
||||||
Currently, GitHub parses the action's output and creates [annotations](https://github.blog/2018-12-14-introducing-check-runs-and-annotations/).
|
Currently, GitHub parses the action's output and creates [annotations](https://github.blog/2018-12-14-introducing-check-runs-and-annotations/).
|
||||||
|
|
||||||
@ -163,8 +195,9 @@ The restrictions of annotations are the following:
|
|||||||
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))
|
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))
|
||||||
2. They aren't shown in the list of comments.
|
2. They aren't shown in the list of comments.
|
||||||
If you would like to have comments - please, up-vote [the issue](https://github.com/golangci/golangci-lint-action/issues/5).
|
If you would like to have comments - please, up-vote [the issue](https://github.com/golangci/golangci-lint-action/issues/5).
|
||||||
|
3. The number of annotations is [limited](https://github.com/actions/toolkit/blob/main/docs/problem-matchers.md#limitations).
|
||||||
|
|
||||||
To enable annotations, you need to add the `checks' permission to your action.
|
To enable annotations, you need to add the `checks` permission to your action.
|
||||||
|
|
||||||
```yaml annotate
|
```yaml annotate
|
||||||
permissions:
|
permissions:
|
||||||
@ -172,7 +205,7 @@ permissions:
|
|||||||
contents: read
|
contents: read
|
||||||
# Optional: allow read access to pull request. Use with `only-new-issues` option.
|
# Optional: allow read access to pull request. Use with `only-new-issues` option.
|
||||||
pull-requests: read
|
pull-requests: read
|
||||||
# Optional: Allow write access to checks to allow the action to annotate code in the PR.
|
# Optional: allow write access to checks to allow the action to annotate code in the PR.
|
||||||
checks: write
|
checks: write
|
||||||
```
|
```
|
||||||
|
|
||||||
|
21
action.yml
21
action.yml
@ -1,4 +1,5 @@
|
|||||||
name: "Run golangci-lint"
|
# https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions
|
||||||
|
name: "Golangci-lint"
|
||||||
description: "Official golangci-lint action with line-attached annotations for found issues, caching and parallel execution."
|
description: "Official golangci-lint action with line-attached annotations for found issues, caching and parallel execution."
|
||||||
author: "golangci"
|
author: "golangci"
|
||||||
inputs:
|
inputs:
|
||||||
@ -8,9 +9,9 @@ inputs:
|
|||||||
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 `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 `goinstall` the value can be v1.2.3, `latest`, or the hash of a commit.
|
||||||
required: false
|
required: false
|
||||||
args:
|
install-mode:
|
||||||
description: "golangci-lint command line arguments"
|
description: "The mode to install golangci-lint. It can be 'binary' or 'goinstall'."
|
||||||
default: ""
|
default: "binary"
|
||||||
required: false
|
required: false
|
||||||
working-directory:
|
working-directory:
|
||||||
description: "golangci-lint working directory, default is project root"
|
description: "golangci-lint working directory, default is project root"
|
||||||
@ -35,9 +36,13 @@ inputs:
|
|||||||
restore existing caches, subject to other options.
|
restore existing caches, subject to other options.
|
||||||
default: 'false'
|
default: 'false'
|
||||||
required: false
|
required: false
|
||||||
install-mode:
|
annotations:
|
||||||
description: "The mode to install golangci-lint. It can be 'binary' or 'goinstall'."
|
description: "To Enable/disable GitHub Action annotations"
|
||||||
default: "binary"
|
default: 'true'
|
||||||
|
required: false
|
||||||
|
args:
|
||||||
|
description: "golangci-lint command line arguments"
|
||||||
|
default: ""
|
||||||
required: false
|
required: false
|
||||||
runs:
|
runs:
|
||||||
using: "node20"
|
using: "node20"
|
||||||
@ -45,4 +50,4 @@ runs:
|
|||||||
post: "dist/post_run/index.js"
|
post: "dist/post_run/index.js"
|
||||||
branding:
|
branding:
|
||||||
icon: "shield"
|
icon: "shield"
|
||||||
color: "yellow"
|
color: "white"
|
||||||
|
3
dist/post_run/index.js
generated
vendored
3
dist/post_run/index.js
generated
vendored
@ -89287,6 +89287,8 @@ async function runLint(lintPath, patchPath) {
|
|||||||
.map(([key, value]) => [key.toLowerCase(), value ?? ""]);
|
.map(([key, value]) => [key.toLowerCase(), value ?? ""]);
|
||||||
const userArgsMap = new Map(userArgsList);
|
const userArgsMap = new Map(userArgsList);
|
||||||
const userArgNames = new Set(userArgsList.map(([key]) => key));
|
const userArgNames = new Set(userArgsList.map(([key]) => key));
|
||||||
|
const annotations = core.getInput(`annotations`).trim() !== "false";
|
||||||
|
if (annotations) {
|
||||||
const formats = (userArgsMap.get("out-format") || "")
|
const formats = (userArgsMap.get("out-format") || "")
|
||||||
.trim()
|
.trim()
|
||||||
.split(",")
|
.split(",")
|
||||||
@ -89296,6 +89298,7 @@ async function runLint(lintPath, patchPath) {
|
|||||||
.join(",");
|
.join(",");
|
||||||
addedArgs.push(`--out-format=${formats}`);
|
addedArgs.push(`--out-format=${formats}`);
|
||||||
userArgs = userArgs.replace(/--out-format=\S*/gi, "").trim();
|
userArgs = userArgs.replace(/--out-format=\S*/gi, "").trim();
|
||||||
|
}
|
||||||
if (isOnlyNewIssues()) {
|
if (isOnlyNewIssues()) {
|
||||||
if (userArgNames.has(`new`) || userArgNames.has(`new-from-rev`) || userArgNames.has(`new-from-patch`)) {
|
if (userArgNames.has(`new`) || userArgNames.has(`new-from-rev`) || userArgNames.has(`new-from-patch`)) {
|
||||||
throw new Error(`please, don't specify manually --new* args when requesting only new issues`);
|
throw new Error(`please, don't specify manually --new* args when requesting only new issues`);
|
||||||
|
3
dist/run/index.js
generated
vendored
3
dist/run/index.js
generated
vendored
@ -89287,6 +89287,8 @@ async function runLint(lintPath, patchPath) {
|
|||||||
.map(([key, value]) => [key.toLowerCase(), value ?? ""]);
|
.map(([key, value]) => [key.toLowerCase(), value ?? ""]);
|
||||||
const userArgsMap = new Map(userArgsList);
|
const userArgsMap = new Map(userArgsList);
|
||||||
const userArgNames = new Set(userArgsList.map(([key]) => key));
|
const userArgNames = new Set(userArgsList.map(([key]) => key));
|
||||||
|
const annotations = core.getInput(`annotations`).trim() !== "false";
|
||||||
|
if (annotations) {
|
||||||
const formats = (userArgsMap.get("out-format") || "")
|
const formats = (userArgsMap.get("out-format") || "")
|
||||||
.trim()
|
.trim()
|
||||||
.split(",")
|
.split(",")
|
||||||
@ -89296,6 +89298,7 @@ async function runLint(lintPath, patchPath) {
|
|||||||
.join(",");
|
.join(",");
|
||||||
addedArgs.push(`--out-format=${formats}`);
|
addedArgs.push(`--out-format=${formats}`);
|
||||||
userArgs = userArgs.replace(/--out-format=\S*/gi, "").trim();
|
userArgs = userArgs.replace(/--out-format=\S*/gi, "").trim();
|
||||||
|
}
|
||||||
if (isOnlyNewIssues()) {
|
if (isOnlyNewIssues()) {
|
||||||
if (userArgNames.has(`new`) || userArgNames.has(`new-from-rev`) || userArgNames.has(`new-from-patch`)) {
|
if (userArgNames.has(`new`) || userArgNames.has(`new-from-rev`) || userArgNames.has(`new-from-patch`)) {
|
||||||
throw new Error(`please, don't specify manually --new* args when requesting only new issues`);
|
throw new Error(`please, don't specify manually --new* args when requesting only new issues`);
|
||||||
|
@ -192,6 +192,9 @@ async function runLint(lintPath: string, patchPath: string): Promise<void> {
|
|||||||
const userArgsMap = new Map<string, string>(userArgsList)
|
const userArgsMap = new Map<string, string>(userArgsList)
|
||||||
const userArgNames = new Set<string>(userArgsList.map(([key]) => key))
|
const userArgNames = new Set<string>(userArgsList.map(([key]) => key))
|
||||||
|
|
||||||
|
const annotations = core.getInput(`annotations`).trim() !== "false"
|
||||||
|
|
||||||
|
if (annotations) {
|
||||||
const formats = (userArgsMap.get("out-format") || "")
|
const formats = (userArgsMap.get("out-format") || "")
|
||||||
.trim()
|
.trim()
|
||||||
.split(",")
|
.split(",")
|
||||||
@ -202,6 +205,7 @@ async function runLint(lintPath: string, patchPath: string): Promise<void> {
|
|||||||
|
|
||||||
addedArgs.push(`--out-format=${formats}`)
|
addedArgs.push(`--out-format=${formats}`)
|
||||||
userArgs = userArgs.replace(/--out-format=\S*/gi, "").trim()
|
userArgs = userArgs.replace(/--out-format=\S*/gi, "").trim()
|
||||||
|
}
|
||||||
|
|
||||||
if (isOnlyNewIssues()) {
|
if (isOnlyNewIssues()) {
|
||||||
if (userArgNames.has(`new`) || userArgNames.has(`new-from-rev`) || userArgNames.has(`new-from-patch`)) {
|
if (userArgNames.has(`new`) || userArgNames.has(`new-from-rev`) || userArgNames.has(`new-from-patch`)) {
|
||||||
|
Reference in New Issue
Block a user