Skip to content

Commit f7463c5

Browse files
authored
feat: add an option to verify with the JSONSchema (#1167)
1 parent 32f9614 commit f7463c5

File tree

9 files changed

+69
-24
lines changed

9 files changed

+69
-24
lines changed

.github/workflows/test.yml

+8-24
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ jobs:
7373
version: ${{ matrix.version }}
7474
args: --timeout=5m --issues-exit-code=0 ./sample/...
7575
only-new-issues: true
76+
verify: true
7677

7778
test-go-install: # make sure the action works on a clean machine without building (go-install mode)
7879
needs: [ build ]
@@ -103,8 +104,9 @@ jobs:
103104
args: --timeout=5m --issues-exit-code=0 ./sample/...
104105
only-new-issues: true
105106
install-mode: goinstall
107+
verify: true
106108

107-
test-go-mod-version:
109+
test-go-mod:
108110
needs: [ build ]
109111
strategy:
110112
matrix:
@@ -113,6 +115,9 @@ jobs:
113115
- ubuntu-24.04-arm
114116
- macos-latest
115117
- windows-latest
118+
wd:
119+
- sample-go-mod
120+
- sample-go-tool
116121
runs-on: ${{ matrix.os }}
117122
permissions:
118123
contents: read
@@ -123,27 +128,6 @@ jobs:
123128
go-version: oldstable
124129
- uses: ./
125130
with:
126-
working-directory: sample-go-mod
127-
args: --timeout=5m --issues-exit-code=0 ./...
128-
129-
test-go-tool-version:
130-
needs: [ build ]
131-
strategy:
132-
matrix:
133-
os:
134-
- ubuntu-latest
135-
- ubuntu-24.04-arm
136-
- macos-latest
137-
- windows-latest
138-
runs-on: ${{ matrix.os }}
139-
permissions:
140-
contents: read
141-
steps:
142-
- uses: actions/checkout@v4
143-
- uses: actions/setup-go@v5
144-
with:
145-
go-version: stable
146-
- uses: ./
147-
with:
148-
working-directory: sample-go-tool
131+
working-directory: ${{ matrix.wd }}
149132
args: --timeout=5m --issues-exit-code=0 ./...
133+
verify: true

.golangci.yml

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
output:
2+
show-stats: true
3+
sort-results: true
4+
sort-order:
5+
- linter
6+
- file

README.md

+18
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,24 @@ with:
318318

319319
</details>
320320

321+
### `verify`
322+
323+
(optional)
324+
325+
If set to true and the action verify the configuration file against the JSONSchema.
326+
327+
<details>
328+
<summary>Example</summary>
329+
330+
```yml
331+
uses: golangci/golangci-lint-action@v6
332+
with:
333+
verify: true
334+
# ...
335+
```
336+
337+
</details>
338+
321339
### `only-new-issues`
322340

323341
(optional)

action.yml

+4
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ inputs:
2222
description: "the token is used for fetching patch of a pull request to show only new issues"
2323
default: ${{ github.token }}
2424
required: false
25+
verify:
26+
description: "if set to true and the action verify the configuration file against the JSONSchema"
27+
default: 'false'
28+
required: false
2529
only-new-issues:
2630
description: "if set to true and the action runs on a pull request - the action outputs only newly found issues"
2731
default: 'false'

dist/post_run/index.js

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/run/index.js

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sample-go-mod/.golangci.yml

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
output:
2+
show-stats: true
3+
sort-results: true
4+
sort-order:
5+
- linter
6+
- file

sample-go-tool/.golangci.yml

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
output:
2+
show-stats: true
3+
sort-results: true
4+
sort-order:
5+
- linter
6+
- file

src/run.ts

+9
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,15 @@ async function runLint(binPath: string, patchPath: string): Promise<void> {
137137
cmdArgs.cwd = path.resolve(workingDirectory)
138138
}
139139

140+
if (core.getBooleanInput(`verify`, { required: true })) {
141+
const cmdVerify = `${binPath} config verify`
142+
143+
core.info(`Running [${cmdVerify}] in [${cmdArgs.cwd || process.cwd()}] ...`)
144+
145+
const res = await execShellCommand(cmdVerify, cmdArgs)
146+
printOutput(res)
147+
}
148+
140149
const cmd = `${binPath} run ${addedArgs.join(` `)} ${userArgs}`.trimEnd()
141150

142151
core.info(`Running [${cmd}] in [${cmdArgs.cwd || process.cwd()}] ...`)

0 commit comments

Comments
 (0)