Skip to content

Commit 190031d

Browse files
committed
feat: verify with the JSONSchema by default
1 parent 0e58f8e commit 190031d

File tree

2 files changed

+35
-12
lines changed

2 files changed

+35
-12
lines changed

action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ inputs:
2424
required: false
2525
verify:
2626
description: "if set to true and the action verify the configuration file against the JSONSchema"
27-
default: 'false'
27+
default: 'true'
2828
required: false
2929
only-new-issues:
3030
description: "if set to true and the action runs on a pull request - the action outputs only newly found issues"

src/run.ts

Lines changed: 34 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -137,17 +137,7 @@ 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-
let cmdVerify = `${binPath} config verify`
142-
if (userArgsMap.get("config")) {
143-
cmdVerify += ` --config=${userArgsMap.get("config")}`
144-
}
145-
146-
core.info(`Running [${cmdVerify}] in [${cmdArgs.cwd || process.cwd()}] ...`)
147-
148-
const res = await execShellCommand(cmdVerify, cmdArgs)
149-
printOutput(res)
150-
}
140+
await runVerify(binPath, userArgsMap, cmdArgs)
151141

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

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

166+
async function runVerify(binPath: string, userArgsMap: Map<string, string>, cmdArgs: ExecOptions): Promise<void> {
167+
const cfgPath = await getConfigPath(binPath, userArgsMap, cmdArgs)
168+
const verify = core.getBooleanInput(`verify`, { required: true })
169+
170+
if (!verify || !cfgPath) {
171+
return
172+
}
173+
174+
let cmdVerify = `${binPath} config verify`
175+
if (userArgsMap.get("config")) {
176+
cmdVerify += ` --config=${userArgsMap.get("config")}`
177+
}
178+
179+
core.info(`Running [${cmdVerify}] in [${cmdArgs.cwd || process.cwd()}] ...`)
180+
181+
const res = await execShellCommand(cmdVerify, cmdArgs)
182+
printOutput(res)
183+
}
184+
185+
async function getConfigPath(binPath: string, userArgsMap: Map<string, string>, cmdArgs: ExecOptions): Promise<string> {
186+
let cmdConfigPath = `${binPath} config path`
187+
if (userArgsMap.get("config")) {
188+
cmdConfigPath += ` --config=${userArgsMap.get("config")}`
189+
}
190+
191+
try {
192+
const resPath = await execShellCommand(cmdConfigPath, cmdArgs)
193+
return resPath.stdout.trim()
194+
} catch {
195+
return ``
196+
}
197+
}
198+
176199
export async function run(): Promise<void> {
177200
try {
178201
const { binPath, patchPath } = await core.group(`prepare environment`, prepareEnv)

0 commit comments

Comments
 (0)