feat: add an option to verify with the JSONSchema (#1167)

This commit is contained in:
Ludovic Fernandez
2025-02-13 23:14:24 +01:00
committed by GitHub
parent 32f961426b
commit f7463c56f6
9 changed files with 69 additions and 24 deletions

View File

@ -73,6 +73,7 @@ jobs:
version: ${{ matrix.version }} version: ${{ matrix.version }}
args: --timeout=5m --issues-exit-code=0 ./sample/... args: --timeout=5m --issues-exit-code=0 ./sample/...
only-new-issues: true only-new-issues: true
verify: true
test-go-install: # make sure the action works on a clean machine without building (go-install mode) test-go-install: # make sure the action works on a clean machine without building (go-install mode)
needs: [ build ] needs: [ build ]
@ -103,8 +104,9 @@ jobs:
args: --timeout=5m --issues-exit-code=0 ./sample/... args: --timeout=5m --issues-exit-code=0 ./sample/...
only-new-issues: true only-new-issues: true
install-mode: goinstall install-mode: goinstall
verify: true
test-go-mod-version: test-go-mod:
needs: [ build ] needs: [ build ]
strategy: strategy:
matrix: matrix:
@ -113,6 +115,9 @@ jobs:
- ubuntu-24.04-arm - ubuntu-24.04-arm
- macos-latest - macos-latest
- windows-latest - windows-latest
wd:
- sample-go-mod
- sample-go-tool
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
permissions: permissions:
contents: read contents: read
@ -123,27 +128,6 @@ jobs:
go-version: oldstable go-version: oldstable
- uses: ./ - uses: ./
with: with:
working-directory: sample-go-mod working-directory: ${{ matrix.wd }}
args: --timeout=5m --issues-exit-code=0 ./...
test-go-tool-version:
needs: [ build ]
strategy:
matrix:
os:
- ubuntu-latest
- ubuntu-24.04-arm
- macos-latest
- windows-latest
runs-on: ${{ matrix.os }}
permissions:
contents: read
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: stable
- uses: ./
with:
working-directory: sample-go-tool
args: --timeout=5m --issues-exit-code=0 ./... args: --timeout=5m --issues-exit-code=0 ./...
verify: true

6
.golangci.yml Normal file
View File

@ -0,0 +1,6 @@
output:
show-stats: true
sort-results: true
sort-order:
- linter
- file

View File

@ -318,6 +318,24 @@ with:
</details> </details>
### `verify`
(optional)
If set to true and the action verify the configuration file against the JSONSchema.
<details>
<summary>Example</summary>
```yml
uses: golangci/golangci-lint-action@v6
with:
verify: true
# ...
```
</details>
### `only-new-issues` ### `only-new-issues`
(optional) (optional)

View File

@ -22,6 +22,10 @@ inputs:
description: "the token is used for fetching patch of a pull request to show only new issues" description: "the token is used for fetching patch of a pull request to show only new issues"
default: ${{ github.token }} default: ${{ github.token }}
required: false required: false
verify:
description: "if set to true and the action verify the configuration file against the JSONSchema"
default: 'false'
required: false
only-new-issues: only-new-issues:
description: "if set to true and the action runs on a pull request - the action outputs only newly found issues" description: "if set to true and the action runs on a pull request - the action outputs only newly found issues"
default: 'false' default: 'false'

6
dist/post_run/index.js generated vendored
View File

@ -94123,6 +94123,12 @@ async function runLint(binPath, patchPath) {
} }
cmdArgs.cwd = path.resolve(workingDirectory); cmdArgs.cwd = path.resolve(workingDirectory);
} }
if (core.getBooleanInput(`verify`, { required: true })) {
const cmdVerify = `${binPath} config verify`;
core.info(`Running [${cmdVerify}] in [${cmdArgs.cwd || process.cwd()}] ...`);
const res = await execShellCommand(cmdVerify, cmdArgs);
printOutput(res);
}
const cmd = `${binPath} run ${addedArgs.join(` `)} ${userArgs}`.trimEnd(); const cmd = `${binPath} run ${addedArgs.join(` `)} ${userArgs}`.trimEnd();
core.info(`Running [${cmd}] in [${cmdArgs.cwd || process.cwd()}] ...`); core.info(`Running [${cmd}] in [${cmdArgs.cwd || process.cwd()}] ...`);
const startedAt = Date.now(); const startedAt = Date.now();

6
dist/run/index.js generated vendored
View File

@ -94123,6 +94123,12 @@ async function runLint(binPath, patchPath) {
} }
cmdArgs.cwd = path.resolve(workingDirectory); cmdArgs.cwd = path.resolve(workingDirectory);
} }
if (core.getBooleanInput(`verify`, { required: true })) {
const cmdVerify = `${binPath} config verify`;
core.info(`Running [${cmdVerify}] in [${cmdArgs.cwd || process.cwd()}] ...`);
const res = await execShellCommand(cmdVerify, cmdArgs);
printOutput(res);
}
const cmd = `${binPath} run ${addedArgs.join(` `)} ${userArgs}`.trimEnd(); const cmd = `${binPath} run ${addedArgs.join(` `)} ${userArgs}`.trimEnd();
core.info(`Running [${cmd}] in [${cmdArgs.cwd || process.cwd()}] ...`); core.info(`Running [${cmd}] in [${cmdArgs.cwd || process.cwd()}] ...`);
const startedAt = Date.now(); const startedAt = Date.now();

View File

@ -0,0 +1,6 @@
output:
show-stats: true
sort-results: true
sort-order:
- linter
- file

View File

@ -0,0 +1,6 @@
output:
show-stats: true
sort-results: true
sort-order:
- linter
- file

View File

@ -137,6 +137,15 @@ async function runLint(binPath: string, patchPath: string): Promise<void> {
cmdArgs.cwd = path.resolve(workingDirectory) cmdArgs.cwd = path.resolve(workingDirectory)
} }
if (core.getBooleanInput(`verify`, { required: true })) {
const cmdVerify = `${binPath} config verify`
core.info(`Running [${cmdVerify}] in [${cmdArgs.cwd || process.cwd()}] ...`)
const res = await execShellCommand(cmdVerify, cmdArgs)
printOutput(res)
}
const cmd = `${binPath} run ${addedArgs.join(` `)} ${userArgs}`.trimEnd() const cmd = `${binPath} run ${addedArgs.join(` `)} ${userArgs}`.trimEnd()
core.info(`Running [${cmd}] in [${cmdArgs.cwd || process.cwd()}] ...`) core.info(`Running [${cmd}] in [${cmdArgs.cwd || process.cwd()}] ...`)