Skip to content
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
File renamed without changes.
29 changes: 29 additions & 0 deletions .github/.golangci.v2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# https://golangci-lint.run/usage/configuration/
version: "2"
linters-settings:
govet:
check-shadowing: true
misspell:
locale: US
errcheck:
check-type-assertions: false
check-blank: false

linters:
default: none
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

enable:
- govet
- misspell
- errcheck
exclusions:
presets:
- comments
- common-false-positives
- legacy
- std-error-handling
Comment on lines +18 to +23
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


formatters:
default: none

issues:
max-same-issues: 0
34 changes: 13 additions & 21 deletions .github/workflows/reviewdog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ jobs:
golangci-lint:
name: runner / golangci-lint
runs-on: ubuntu-latest
strategy:
matrix:
golangci-lint-version: ["v1", "v2"]
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
Expand All @@ -15,14 +18,16 @@ jobs:
with:
github_token: ${{ secrets.github_token }}
level: warning
golangci_lint_flags: "--config=.github/.golangci.yml ./testdata"
golangci_lint_version: ${{ matrix.golangci-lint-version == 'v1' && 'v1.64.8' || 'latest' }}
golangci_lint_flags: "--config=.github/.golangci.${{ matrix.golangci-lint-version }}.yml ./testdata"

golangci-lint-platform:
name: runner / golangci-lint-platform
strategy:
fail-fast: false
matrix:
platform: [ubuntu-latest, macos-latest, windows-latest]
golangci-lint-version: ["v1", "v2"]
runs-on: ${{ matrix.platform }}
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
Expand All @@ -32,7 +37,8 @@ jobs:
github_token: ${{ secrets.github_token }}
tool_name: golangci-lint-${{ matrix.platform }}
level: warning
golangci_lint_flags: "--config=.github/.golangci.yml ./testdata --timeout 10m"
golangci_lint_version: ${{ matrix.golangci-lint-version == 'v1' && 'v1.64.8' || 'latest' }}
golangci_lint_flags: "--config=.github/.golangci.${{ matrix.golangci-lint-version }}.yml ./testdata --timeout 10m"

golangci-lint-github-pr-review:
name: runner / golangci-lint (github-pr-review)
Expand Down Expand Up @@ -88,7 +94,7 @@ jobs:
github_token: ${{ secrets.github_token }}
tool_name: "golangci-lint-all-in-one"
level: warning
golangci_lint_flags: "--enable-all --exclude-use-default=false ./testdata"
golangci_lint_flags: "--default all ./testdata"

govet:
name: runner / govet
Expand All @@ -100,7 +106,7 @@ jobs:
uses: ./
with:
github_token: ${{ secrets.github_token }}
golangci_lint_flags: "--disable-all -E govet ./testdata"
golangci_lint_flags: "--default none -E govet ./testdata"
tool_name: govet

staticcheck:
Expand All @@ -113,23 +119,9 @@ jobs:
uses: ./
with:
github_token: ${{ secrets.github_token }}
golangci_lint_flags: "--disable-all -E staticcheck ./testdata"
golangci_lint_flags: "--default none -E staticcheck ./testdata"
tool_name: staticcheck

golint:
name: runner / golint
runs-on: ubuntu-latest
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: golint
uses: ./
with:
github_token: ${{ secrets.github_token }}
golangci_lint_flags: "--disable-all -E golint ./testdata"
tool_name: golint
level: warning

Comment on lines -119 to -132
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

errcheck:
name: runner / errcheck
runs-on: ubuntu-latest
Expand All @@ -140,7 +132,7 @@ jobs:
uses: ./
with:
github_token: ${{ secrets.github_token }}
golangci_lint_flags: "--disable-all -E errcheck ./testdata"
golangci_lint_flags: "--default none -E errcheck ./testdata"
tool_name: errcheck
level: warning

Expand All @@ -154,7 +146,7 @@ jobs:
uses: ./
with:
github_token: ${{ secrets.github_token }}
golangci_lint_flags: "--disable-all -E misspell ./testdata"
golangci_lint_flags: "--default none -E misspell ./testdata"
tool_name: misspell
level: info

Expand Down
15 changes: 15 additions & 0 deletions __test__/main.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { isGolangciLintV1 } from "../src/main";

describe("isV1", () => {
it("should return false if the version is latest", () => {
expect(isGolangciLintV1("latest")).toBe(false);
});

it("should return true if the version is v1.x.x", () => {
expect(isGolangciLintV1("v1.0.0")).toBe(true);
});

it("should return true if the version is v2.x.x", () => {
expect(isGolangciLintV1("v2.0.0")).toBe(false);
});
});
16 changes: 15 additions & 1 deletion dist/index.js

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

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

29 changes: 21 additions & 8 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,14 @@ async function run(): Promise<void> {
}

const output = await core.group("Running golangci-lint ...", async (): Promise<exec.ExecOutput> => {
return await exec.getExecOutput(
golangci,
["run", "--out-format", "line-number", ...flags.parse(golangciLintFlags)],
{
cwd,
ignoreReturnCode: true,
},
);
const options = isGolangciLintV1(golangciLintVersion)
? ["run", "--out-format", "line-number", ...flags.parse(golangciLintFlags)]
: ["run", "--output.text.path", "stdout", ...flags.parse(golangciLintFlags)];

return await exec.getExecOutput(golangci, options, {
cwd,
ignoreReturnCode: true,
});
});

switch (output.exitCode) {
Expand Down Expand Up @@ -132,4 +132,17 @@ async function run(): Promise<void> {
}
}

export function isGolangciLintV1(version: string): boolean {
if (version === "latest") {
return false;
}

const match = version.match(/^v?(\d+)/);
if (!match) {
throw new Error(`Invalid golangci-lint version: ${version}`);
}

return parseInt(match[1], 10) === 1;
}

void run();
Loading