From 47d1bdb76232ed96e1259094a5502d76fadadbf4 Mon Sep 17 00:00:00 2001 From: Fernandez Ludovic Date: Thu, 13 Feb 2025 22:18:22 +0100 Subject: [PATCH 01/11] chore: simplify workflow --- .github/workflows/test.yml | 29 +++++------------------------ 1 file changed, 5 insertions(+), 24 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index aa8ab55de2..c2e3e55fc5 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -104,7 +104,7 @@ jobs: only-new-issues: true install-mode: goinstall - test-go-mod-version: + test-go-mod: needs: [ build ] strategy: matrix: @@ -113,6 +113,9 @@ jobs: - ubuntu-24.04-arm - macos-latest - windows-latest + wd: + - sample-go-mod + - sample-go-tool runs-on: ${{ matrix.os }} permissions: contents: read @@ -123,27 +126,5 @@ 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 ./... From 646655a0f0e72727473a4c0599f193741dbbefed Mon Sep 17 00:00:00 2001 From: Fernandez Ludovic Date: Thu, 13 Feb 2025 22:21:05 +0100 Subject: [PATCH 02/11] feat: verify with the JSONSchema --- README.md | 18 ++++++++++++++++++ action.yml | 4 ++++ src/run.ts | 5 +++++ 3 files changed, 27 insertions(+) diff --git a/README.md b/README.md index be93de974d..282afa91ec 100644 --- a/README.md +++ b/README.md @@ -318,6 +318,24 @@ with: +### `verify` + +(optional) + +If set to true and the action verify the configuration file against the JSONSchema. + +
+Example + +```yml +uses: golangci/golangci-lint-action@v6 +with: + verify: true + # ... +``` + +
+ ### `only-new-issues` (optional) diff --git a/action.yml b/action.yml index f4bdaaa181..5e8e8e3be1 100644 --- a/action.yml +++ b/action.yml @@ -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' diff --git a/src/run.ts b/src/run.ts index 09b0e1d69e..1bd2461bdb 100644 --- a/src/run.ts +++ b/src/run.ts @@ -51,6 +51,11 @@ async function runLint(binPath: string, patchPath: string): Promise { printOutput(res) } + if (core.getBooleanInput(`verify`, { required: true })) { + const res = await execShellCommand(`${binPath} verify`) + printOutput(res) + } + let userArgs = core.getInput(`args`) const addedArgs: string[] = [] From d51ca1ec8ba28e9046b6af5f5191d47d9893c8ee Mon Sep 17 00:00:00 2001 From: Fernandez Ludovic Date: Thu, 13 Feb 2025 22:21:50 +0100 Subject: [PATCH 03/11] chore: generate --- dist/post_run/index.js | 4 ++++ dist/run/index.js | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/dist/post_run/index.js b/dist/post_run/index.js index 8978b4d15a..7cc8005e23 100644 --- a/dist/post_run/index.js +++ b/dist/post_run/index.js @@ -94053,6 +94053,10 @@ async function runLint(binPath, patchPath) { const res = await execShellCommand(`${binPath} cache status`); printOutput(res); } + if (core.getBooleanInput(`verify`, { required: true })) { + const res = await execShellCommand(`${binPath} verify`); + printOutput(res); + } let userArgs = core.getInput(`args`); const addedArgs = []; const userArgsList = userArgs diff --git a/dist/run/index.js b/dist/run/index.js index 1ab7483a27..a4572c0d68 100644 --- a/dist/run/index.js +++ b/dist/run/index.js @@ -94053,6 +94053,10 @@ async function runLint(binPath, patchPath) { const res = await execShellCommand(`${binPath} cache status`); printOutput(res); } + if (core.getBooleanInput(`verify`, { required: true })) { + const res = await execShellCommand(`${binPath} verify`); + printOutput(res); + } let userArgs = core.getInput(`args`); const addedArgs = []; const userArgsList = userArgs From c9bc13a1b25c992b1c5c9f773f136889456473ed Mon Sep 17 00:00:00 2001 From: Fernandez Ludovic Date: Thu, 13 Feb 2025 22:32:08 +0100 Subject: [PATCH 04/11] chore: run verify --- .github/workflows/test.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c2e3e55fc5..af8bb9aeac 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -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 ] @@ -103,6 +104,7 @@ jobs: args: --timeout=5m --issues-exit-code=0 ./sample/... only-new-issues: true install-mode: goinstall + verify: true test-go-mod: needs: [ build ] @@ -128,3 +130,4 @@ jobs: with: working-directory: ${{ matrix.wd }} args: --timeout=5m --issues-exit-code=0 ./... + verify: true From 816019cb269fa18e542a774e7b4609f02cad7fe4 Mon Sep 17 00:00:00 2001 From: Fernandez Ludovic Date: Thu, 13 Feb 2025 22:34:32 +0100 Subject: [PATCH 05/11] fix: verify command --- dist/post_run/index.js | 2 +- dist/run/index.js | 2 +- src/run.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/dist/post_run/index.js b/dist/post_run/index.js index 7cc8005e23..297e712572 100644 --- a/dist/post_run/index.js +++ b/dist/post_run/index.js @@ -94054,7 +94054,7 @@ async function runLint(binPath, patchPath) { printOutput(res); } if (core.getBooleanInput(`verify`, { required: true })) { - const res = await execShellCommand(`${binPath} verify`); + const res = await execShellCommand(`${binPath} config verify`); printOutput(res); } let userArgs = core.getInput(`args`); diff --git a/dist/run/index.js b/dist/run/index.js index a4572c0d68..c18aa3b6d6 100644 --- a/dist/run/index.js +++ b/dist/run/index.js @@ -94054,7 +94054,7 @@ async function runLint(binPath, patchPath) { printOutput(res); } if (core.getBooleanInput(`verify`, { required: true })) { - const res = await execShellCommand(`${binPath} verify`); + const res = await execShellCommand(`${binPath} config verify`); printOutput(res); } let userArgs = core.getInput(`args`); diff --git a/src/run.ts b/src/run.ts index 1bd2461bdb..8881de8a41 100644 --- a/src/run.ts +++ b/src/run.ts @@ -52,7 +52,7 @@ async function runLint(binPath: string, patchPath: string): Promise { } if (core.getBooleanInput(`verify`, { required: true })) { - const res = await execShellCommand(`${binPath} verify`) + const res = await execShellCommand(`${binPath} config verify`) printOutput(res) } From 320de798450a83fdaf6dd6a62c1192553cdbd66a Mon Sep 17 00:00:00 2001 From: Fernandez Ludovic Date: Thu, 13 Feb 2025 22:37:32 +0100 Subject: [PATCH 06/11] chore: add configuration file --- sample-go-mod/.golangci.yml | 6 ++++++ sample-go-tool/.golangci.yml | 6 ++++++ sample/.golangci.yml | 6 ++++++ 3 files changed, 18 insertions(+) create mode 100644 sample-go-mod/.golangci.yml create mode 100644 sample-go-tool/.golangci.yml create mode 100644 sample/.golangci.yml diff --git a/sample-go-mod/.golangci.yml b/sample-go-mod/.golangci.yml new file mode 100644 index 0000000000..ad24fce4c0 --- /dev/null +++ b/sample-go-mod/.golangci.yml @@ -0,0 +1,6 @@ +output: + show-stats: true + sort-results: true + sort-order: + - linter + - file \ No newline at end of file diff --git a/sample-go-tool/.golangci.yml b/sample-go-tool/.golangci.yml new file mode 100644 index 0000000000..ad24fce4c0 --- /dev/null +++ b/sample-go-tool/.golangci.yml @@ -0,0 +1,6 @@ +output: + show-stats: true + sort-results: true + sort-order: + - linter + - file \ No newline at end of file diff --git a/sample/.golangci.yml b/sample/.golangci.yml new file mode 100644 index 0000000000..ad24fce4c0 --- /dev/null +++ b/sample/.golangci.yml @@ -0,0 +1,6 @@ +output: + show-stats: true + sort-results: true + sort-order: + - linter + - file \ No newline at end of file From 3b8d935c852abd5657d6bfc6a5e96fd715d8b61f Mon Sep 17 00:00:00 2001 From: Fernandez Ludovic Date: Thu, 13 Feb 2025 22:41:29 +0100 Subject: [PATCH 07/11] fix: use working directory --- src/run.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/run.ts b/src/run.ts index 8881de8a41..a624c57c9d 100644 --- a/src/run.ts +++ b/src/run.ts @@ -51,11 +51,6 @@ async function runLint(binPath: string, patchPath: string): Promise { printOutput(res) } - if (core.getBooleanInput(`verify`, { required: true })) { - const res = await execShellCommand(`${binPath} config verify`) - printOutput(res) - } - let userArgs = core.getInput(`args`) const addedArgs: string[] = [] @@ -142,6 +137,11 @@ async function runLint(binPath: string, patchPath: string): Promise { cmdArgs.cwd = path.resolve(workingDirectory) } + if (core.getBooleanInput(`verify`, { required: true })) { + const res = await execShellCommand(`${binPath} config verify`, cmdArgs) + printOutput(res) + } + const cmd = `${binPath} run ${addedArgs.join(` `)} ${userArgs}`.trimEnd() core.info(`Running [${cmd}] in [${cmdArgs.cwd || process.cwd()}] ...`) From 0ec7daf6a5c64dc35ed75864b50c88ddf1ff32c3 Mon Sep 17 00:00:00 2001 From: Fernandez Ludovic Date: Thu, 13 Feb 2025 22:43:02 +0100 Subject: [PATCH 08/11] chore: generate --- dist/post_run/index.js | 8 ++++---- dist/run/index.js | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/dist/post_run/index.js b/dist/post_run/index.js index 297e712572..7e4424bdc8 100644 --- a/dist/post_run/index.js +++ b/dist/post_run/index.js @@ -94053,10 +94053,6 @@ async function runLint(binPath, patchPath) { const res = await execShellCommand(`${binPath} cache status`); printOutput(res); } - if (core.getBooleanInput(`verify`, { required: true })) { - const res = await execShellCommand(`${binPath} config verify`); - printOutput(res); - } let userArgs = core.getInput(`args`); const addedArgs = []; const userArgsList = userArgs @@ -94127,6 +94123,10 @@ async function runLint(binPath, patchPath) { } cmdArgs.cwd = path.resolve(workingDirectory); } + if (core.getBooleanInput(`verify`, { required: true })) { + const res = await execShellCommand(`${binPath} config verify`, cmdArgs); + printOutput(res); + } const cmd = `${binPath} run ${addedArgs.join(` `)} ${userArgs}`.trimEnd(); core.info(`Running [${cmd}] in [${cmdArgs.cwd || process.cwd()}] ...`); const startedAt = Date.now(); diff --git a/dist/run/index.js b/dist/run/index.js index c18aa3b6d6..3fb964e779 100644 --- a/dist/run/index.js +++ b/dist/run/index.js @@ -94053,10 +94053,6 @@ async function runLint(binPath, patchPath) { const res = await execShellCommand(`${binPath} cache status`); printOutput(res); } - if (core.getBooleanInput(`verify`, { required: true })) { - const res = await execShellCommand(`${binPath} config verify`); - printOutput(res); - } let userArgs = core.getInput(`args`); const addedArgs = []; const userArgsList = userArgs @@ -94127,6 +94123,10 @@ async function runLint(binPath, patchPath) { } cmdArgs.cwd = path.resolve(workingDirectory); } + if (core.getBooleanInput(`verify`, { required: true })) { + const res = await execShellCommand(`${binPath} config verify`, cmdArgs); + printOutput(res); + } const cmd = `${binPath} run ${addedArgs.join(` `)} ${userArgs}`.trimEnd(); core.info(`Running [${cmd}] in [${cmdArgs.cwd || process.cwd()}] ...`); const startedAt = Date.now(); From 6cfba591bb0b3b4cb5c5cd8ba68bfb3d1e15fa98 Mon Sep 17 00:00:00 2001 From: Fernandez Ludovic Date: Thu, 13 Feb 2025 22:50:09 +0100 Subject: [PATCH 09/11] chore: more logs --- dist/post_run/index.js | 4 +++- dist/run/index.js | 4 +++- src/run.ts | 6 +++++- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/dist/post_run/index.js b/dist/post_run/index.js index 7e4424bdc8..8586a27319 100644 --- a/dist/post_run/index.js +++ b/dist/post_run/index.js @@ -94124,7 +94124,9 @@ async function runLint(binPath, patchPath) { cmdArgs.cwd = path.resolve(workingDirectory); } if (core.getBooleanInput(`verify`, { required: true })) { - const res = await execShellCommand(`${binPath} config verify`, cmdArgs); + 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(); diff --git a/dist/run/index.js b/dist/run/index.js index 3fb964e779..b9e694e10a 100644 --- a/dist/run/index.js +++ b/dist/run/index.js @@ -94124,7 +94124,9 @@ async function runLint(binPath, patchPath) { cmdArgs.cwd = path.resolve(workingDirectory); } if (core.getBooleanInput(`verify`, { required: true })) { - const res = await execShellCommand(`${binPath} config verify`, cmdArgs); + 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(); diff --git a/src/run.ts b/src/run.ts index a624c57c9d..3addc14efa 100644 --- a/src/run.ts +++ b/src/run.ts @@ -138,7 +138,11 @@ async function runLint(binPath: string, patchPath: string): Promise { } if (core.getBooleanInput(`verify`, { required: true })) { - const res = await execShellCommand(`${binPath} config verify`, cmdArgs) + const cmdVerify = `${binPath} config verify` + + core.info(`Running [${cmdVerify}] in [${cmdArgs.cwd || process.cwd()}] ...`) + + const res = await execShellCommand(cmdVerify, cmdArgs) printOutput(res) } From 613697a009d045b3119d6c235d2392d43d911257 Mon Sep 17 00:00:00 2001 From: Fernandez Ludovic Date: Thu, 13 Feb 2025 22:56:18 +0100 Subject: [PATCH 10/11] wip: debug --- .github/workflows/test.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index af8bb9aeac..1ab1691c78 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -128,6 +128,7 @@ jobs: go-version: oldstable - uses: ./ with: - working-directory: ${{ matrix.wd }} + working-directory: sample-go-mod + #working-directory: ${{ matrix.wd }} args: --timeout=5m --issues-exit-code=0 ./... verify: true From 594fb07c1e4c07cf5aca70f6775681cf2a580d44 Mon Sep 17 00:00:00 2001 From: Fernandez Ludovic Date: Thu, 13 Feb 2025 23:03:52 +0100 Subject: [PATCH 11/11] fix: move configuration file --- .github/workflows/test.yml | 3 +-- sample/.golangci.yml => .golangci.yml | 0 2 files changed, 1 insertion(+), 2 deletions(-) rename sample/.golangci.yml => .golangci.yml (100%) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 1ab1691c78..af8bb9aeac 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -128,7 +128,6 @@ jobs: go-version: oldstable - uses: ./ with: - working-directory: sample-go-mod - #working-directory: ${{ matrix.wd }} + working-directory: ${{ matrix.wd }} args: --timeout=5m --issues-exit-code=0 ./... verify: true diff --git a/sample/.golangci.yml b/.golangci.yml similarity index 100% rename from sample/.golangci.yml rename to .golangci.yml