Skip to content

Commit

Permalink
feat: add an option to verify with the JSONSchema (#1167)
Browse files Browse the repository at this point in the history
  • Loading branch information
ldez authored Feb 13, 2025
1 parent 32f9614 commit f7463c5
Show file tree
Hide file tree
Showing 9 changed files with 69 additions and 24 deletions.
32 changes: 8 additions & 24 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ jobs:
version: ${{ matrix.version }}
args: --timeout=5m --issues-exit-code=0 ./sample/...
only-new-issues: true
verify: true

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

test-go-mod-version:
test-go-mod:
needs: [ build ]
strategy:
matrix:
Expand All @@ -113,6 +115,9 @@ jobs:
- ubuntu-24.04-arm
- macos-latest
- windows-latest
wd:
- sample-go-mod
- sample-go-tool
runs-on: ${{ matrix.os }}
permissions:
contents: read
Expand All @@ -123,27 +128,6 @@ jobs:
go-version: oldstable
- uses: ./
with:
working-directory: sample-go-mod
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
working-directory: ${{ matrix.wd }}
args: --timeout=5m --issues-exit-code=0 ./...
verify: true
6 changes: 6 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
output:
show-stats: true
sort-results: true
sort-order:
- linter
- file
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,24 @@ with:

</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`

(optional)
Expand Down
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ inputs:
description: "the token is used for fetching patch of a pull request to show only new issues"
default: ${{ github.token }}
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:
description: "if set to true and the action runs on a pull request - the action outputs only newly found issues"
default: 'false'
Expand Down
6 changes: 6 additions & 0 deletions dist/post_run/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions dist/run/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions sample-go-mod/.golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
output:
show-stats: true
sort-results: true
sort-order:
- linter
- file
6 changes: 6 additions & 0 deletions sample-go-tool/.golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
output:
show-stats: true
sort-results: true
sort-order:
- linter
- file
9 changes: 9 additions & 0 deletions src/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,15 @@ async function runLint(binPath: string, patchPath: string): Promise<void> {
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()

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

0 comments on commit f7463c5

Please sign in to comment.