Skip to content

feat: verify with the JSONSchema by default #1171

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ 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 @@ -101,7 +100,6 @@ jobs:
args: --timeout=5m --issues-exit-code=0 ./sample/...
only-new-issues: true
install-mode: goinstall
verify: true

test-go-mod:
needs: [ build ]
Expand All @@ -127,4 +125,3 @@ jobs:
with:
working-directory: ${{ matrix.wd }}
args: --timeout=5m --issues-exit-code=0 ./...
verify: true
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ inputs:
required: false
verify:
description: "if set to true and the action verify the configuration file against the JSONSchema"
default: 'false'
default: 'true'
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"
Expand Down
41 changes: 32 additions & 9 deletions dist/post_run/index.js

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

41 changes: 32 additions & 9 deletions dist/run/index.js

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

50 changes: 39 additions & 11 deletions src/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,17 +137,7 @@ async function runLint(binPath: string, patchPath: string): Promise<void> {
cmdArgs.cwd = path.resolve(workingDirectory)
}

if (core.getBooleanInput(`verify`, { required: true })) {
let cmdVerify = `${binPath} config verify`
if (userArgsMap.get("config")) {
cmdVerify += ` --config=${userArgsMap.get("config")}`
}

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

const res = await execShellCommand(cmdVerify, cmdArgs)
printOutput(res)
}
await runVerify(binPath, userArgsMap, cmdArgs)

const cmd = `${binPath} run ${addedArgs.join(` `)} ${userArgs}`.trimEnd()

Expand All @@ -173,6 +163,44 @@ async function runLint(binPath: string, patchPath: string): Promise<void> {
core.info(`Ran golangci-lint in ${Date.now() - startedAt}ms`)
}

async function runVerify(binPath: string, userArgsMap: Map<string, string>, cmdArgs: ExecOptions): Promise<void> {
const verify = core.getBooleanInput(`verify`, { required: true })
if (!verify) {
return
}

const cfgPath = await getConfigPath(binPath, userArgsMap, cmdArgs)
if (!cfgPath) {
return
}

let cmdVerify = `${binPath} config verify`
if (userArgsMap.get("config")) {
cmdVerify += ` --config=${userArgsMap.get("config")}`
}

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

const res = await execShellCommand(cmdVerify, cmdArgs)
printOutput(res)
}

async function getConfigPath(binPath: string, userArgsMap: Map<string, string>, cmdArgs: ExecOptions): Promise<string> {
let cmdConfigPath = `${binPath} config path`
if (userArgsMap.get("config")) {
cmdConfigPath += ` --config=${userArgsMap.get("config")}`
}

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

try {
const resPath = await execShellCommand(cmdConfigPath, cmdArgs)
return resPath.stderr.trim()
} catch {
return ``
}
}

export async function run(): Promise<void> {
try {
const { binPath, patchPath } = await core.group(`prepare environment`, prepareEnv)
Expand Down
Loading