Skip to content

Commit 4d8ff62

Browse files
authored
Merge pull request #302 from joonas/chore/migrate-golangci-lint-v2
chore: Migrate `golangci-lint` to v2
2 parents ea0162a + 85db187 commit 4d8ff62

File tree

30 files changed

+297
-320
lines changed

30 files changed

+297
-320
lines changed

.github/workflows/component-go.yaml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ on:
1616

1717
env:
1818
TINYGO_VERSION: "0.36.0"
19-
GOLANGCI_VERSION: "v1.64.2"
19+
GOLANGCI_VERSION: "v2.1.6"
2020
WASH_VERSION: "0.37.0"
2121
WASM_TOOLS_VERSION: "1.225.0"
2222

@@ -38,10 +38,11 @@ jobs:
3838
runs-on: ubuntu-latest
3939
steps:
4040
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
41-
- uses: golangci/golangci-lint-action@4696ba8babb6127d732c3c6dde519db15edab9ea # v6.5.1
41+
- uses: golangci/golangci-lint-action@4afd733a84b1f43292c63897423277bb7f4313a9 # v8.0.0
4242
with:
4343
version: ${{ env.GOLANGCI_VERSION }}
4444
working-directory: ./component
45+
args: --config=${{ github.workspace }}/.golangci.yml
4546
- uses: taiki-e/install-action@86c23eed46c17b80677df6d8151545ce3e236c61 # v2.50.7
4647
with:
4748
tool: ${{ format('wasm-tools@{0}', env.WASM_TOOLS_VERSION) }}
@@ -98,10 +99,11 @@ jobs:
9899
- uses: acifani/setup-tinygo@b2ba42b249c7d3efdfe94166ec0f48b3191404f7 # v2.0.0
99100
with:
100101
tinygo-version: ${{ env.TINYGO_VERSION }}
101-
- uses: golangci/golangci-lint-action@4696ba8babb6127d732c3c6dde519db15edab9ea # v6.5.1
102+
- uses: golangci/golangci-lint-action@4afd733a84b1f43292c63897423277bb7f4313a9 # v8.0.0
102103
with:
103104
version: ${{ env.GOLANGCI_VERSION }}
104105
working-directory: "./examples/component/${{ matrix.example }}"
106+
args: --config=${{ github.workspace }}/.golangci.yml
105107
- uses: taiki-e/install-action@86c23eed46c17b80677df6d8151545ce3e236c61 # v2.50.7
106108
with:
107109
tool: ${{ format('wash@{0},wasm-tools@{1}', env.WASH_VERSION, env.WASM_TOOLS_VERSION) }}

.github/workflows/provider-go.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ on:
1515
- 'examples/provider/**'
1616

1717
env:
18-
GOLANGCI_VERSION: "v1.64.2"
18+
GOLANGCI_VERSION: "v2.1.6"
1919

2020
permissions:
2121
contents: read
@@ -52,7 +52,8 @@ jobs:
5252
with:
5353
go-version-file: "./provider/go.mod"
5454
- name: golangci-lint
55-
uses: golangci/golangci-lint-action@4696ba8babb6127d732c3c6dde519db15edab9ea # v6.5.1
55+
uses: golangci/golangci-lint-action@4afd733a84b1f43292c63897423277bb7f4313a9 # v8.0.0
5656
with:
5757
version: ${{ env.GOLANGCI_VERSION }}
5858
working-directory: ./provider
59+
args: --config=${{ github.workspace }}/.golangci.yml

.github/workflows/templates-go.yaml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ on:
1414

1515
env:
1616
TINYGO_VERSION: "0.37.0"
17-
GOLANGCI_VERSION: "v1.64.2"
17+
GOLANGCI_VERSION: "v2.1.6"
1818
WASH_VERSION: "0.37.0"
1919
WASM_TOOLS_VERSION: "1.225.0"
2020
WRPC_VERSION: "0.11.1"
@@ -53,10 +53,11 @@ jobs:
5353
run: wash build
5454
working-directory: "${{ runner.temp }}/sample-provider"
5555
- name: Go Lint
56-
uses: golangci/golangci-lint-action@4696ba8babb6127d732c3c6dde519db15edab9ea # v6.5.1
56+
uses: golangci/golangci-lint-action@4afd733a84b1f43292c63897423277bb7f4313a9 # v8.0.0
5757
with:
5858
version: ${{ env.GOLANGCI_VERSION }}
5959
working-directory: "${{ runner.temp }}/sample-provider"
60+
args: --config=${{ github.workspace }}/.golangci.yml
6061
- name: Go Test
6162
run: go test -v ./...
6263
working-directory: "${{ runner.temp }}/sample-provider"
@@ -94,10 +95,11 @@ jobs:
9495
run: wash build
9596
working-directory: "${{ runner.temp }}/sample-component"
9697
- name: Go Lint
97-
uses: golangci/golangci-lint-action@4696ba8babb6127d732c3c6dde519db15edab9ea # v6.5.1
98+
uses: golangci/golangci-lint-action@4afd733a84b1f43292c63897423277bb7f4313a9 # v8.0.0
9899
with:
99100
version: ${{ env.GOLANGCI_VERSION }}
100101
working-directory: "${{ runner.temp }}/sample-component"
102+
args: --config=${{ github.workspace }}/.golangci.yml
101103
- name: Go Test
102104
run: go test -v ./...
103105
working-directory: "${{ runner.temp }}/sample-component"

.github/workflows/wasmbus-go.yaml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ on:
1313
- "x/wasmbus/**"
1414

1515
env:
16-
GOLANGCI_VERSION: "v1.64.2"
16+
GOLANGCI_VERSION: "v2.1.6"
1717
WASH_VERSION: "0.37.0"
1818

1919
permissions:
@@ -30,10 +30,11 @@ jobs:
3030
runs-on: ubuntu-latest
3131
steps:
3232
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
33-
- uses: golangci/golangci-lint-action@4696ba8babb6127d732c3c6dde519db15edab9ea # v6.5.1
33+
- uses: golangci/golangci-lint-action@4afd733a84b1f43292c63897423277bb7f4313a9 # v8.0.0
3434
with:
3535
version: ${{ env.GOLANGCI_VERSION }}
3636
working-directory: x/wasmbus
37+
args: --config=${{ github.workspace }}/.golangci.yml
3738

3839
- name: Go generate
3940
working-directory: x/wasmbus
@@ -95,10 +96,11 @@ jobs:
9596
- uses: actions/setup-go@0aaccfd150d50ccaeb58ebd88d36e91967a5f35b # v5.4.0
9697
with:
9798
go-version-file: "./examples/wasmbus/${{ matrix.example }}/go.mod"
98-
- uses: golangci/golangci-lint-action@4696ba8babb6127d732c3c6dde519db15edab9ea # v6.5.1
99+
- uses: golangci/golangci-lint-action@4afd733a84b1f43292c63897423277bb7f4313a9 # v8.0.0
99100
with:
100101
version: ${{ env.GOLANGCI_VERSION }}
101102
working-directory: "./examples/wasmbus/${{ matrix.example }}"
103+
args: --config=${{ github.workspace }}/.golangci.yml
102104
- uses: taiki-e/install-action@86c23eed46c17b80677df6d8151545ce3e236c61 # v2.50.7
103105
with:
104106
tool: ${{ format('wash-cli@{0}', env.WASH_VERSION) }}

.golangci.yml

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
version: "2"
2+
run:
3+
modules-download-mode: readonly
4+
tests: false
5+
output:
6+
sort-order:
7+
- linter
8+
- severity
9+
- file
10+
linters:
11+
enable:
12+
- dupword
13+
- mirror
14+
- misspell
15+
- revive
16+
- staticcheck
17+
- thelper
18+
- usestdlibvars
19+
settings:
20+
misspell:
21+
locale: US
22+
ignore-rules:
23+
- WASM
24+
revive:
25+
rules:
26+
- name: blank-imports
27+
- name: context-as-argument
28+
arguments:
29+
- allowTypesBefore: '*testing.T'
30+
- name: context-keys-type
31+
- name: dot-imports
32+
- name: empty-block
33+
- name: error-naming
34+
- name: error-return
35+
- name: error-strings
36+
- name: errorf
37+
- name: increment-decrement
38+
- name: indent-error-flow
39+
- name: range
40+
- name: receiver-naming
41+
- name: redefines-builtin-id
42+
- name: superfluous-else
43+
- name: time-naming
44+
- name: unexported-return
45+
- name: unreachable-code
46+
- name: unused-parameter
47+
- name: var-declaration
48+
- name: var-naming
49+
exclusions:
50+
generated: lax
51+
presets:
52+
- comments
53+
- common-false-positives
54+
- legacy
55+
- std-error-handling
56+
paths:
57+
- third_party$
58+
- builtin$
59+
- examples$
60+
issues:
61+
uniq-by-line: false
62+
formatters:
63+
enable:
64+
- gofmt
65+
exclusions:
66+
generated: lax
67+
paths:
68+
- third_party$
69+
- builtin$
70+
- examples$

component/.golangci.yaml

Lines changed: 0 additions & 103 deletions
This file was deleted.

examples/component/sqldb-postgres-query/postgres.go

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package main
33

44
import (
55
"fmt"
6-
76
"sqldb-postgres-query/gen/wasmcloud/examples/invoke"
87
"sqldb-postgres-query/gen/wasmcloud/postgres/query"
98
"sqldb-postgres-query/gen/wasmcloud/postgres/types"
@@ -12,7 +11,7 @@ import (
1211
"go.wasmcloud.dev/component/log/wasilog"
1312
)
1413

15-
const CREATE_TABLE_QUERY = `
14+
const CreateTableQuery = `
1615
CREATE TABLE IF NOT EXISTS example (
1716
id bigint GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
1817
description text NOT NULL,
@@ -22,11 +21,11 @@ CREATE TABLE IF NOT EXISTS example (
2221

2322
// A basic insert query, using Postgres `RETURNING` syntax,
2423
// which returns the contents of the row that was inserted
25-
const INSERT_QUERY = `
24+
const InsertQuery = `
2625
INSERT INTO example (description) VALUES ($1) RETURNING *;
2726
`
2827

29-
const SELECT_QUERY = `
28+
const SelectQuery = `
3029
SELECT * FROM example WHERE description = $1;
3130
`
3231

@@ -37,20 +36,20 @@ func init() {
3736
func call() string {
3837
logger := wasilog.ContextLogger("call")
3938

40-
query := Query(CREATE_TABLE_QUERY)
39+
query := Query(CreateTableQuery)
4140
if query.IsErr() {
4241
logger.Error("failed to create table", "err", query.Err())
4342
return fmt.Sprintf("ERROR: failed to create table: %v", query.Err())
4443
}
4544

4645
val := "inserted example go row!"
47-
insertResult := Query(INSERT_QUERY, types.PgValueText(val))
46+
insertResult := Query(InsertQuery, types.PgValueText(val))
4847
if insertResult.IsErr() {
4948
logger.Error("failed to insert row", "err", insertResult.Err())
5049
return fmt.Sprintf("ERROR: failed to insert row: %v", insertResult.Err())
5150
}
5251

53-
selectResult := Query(SELECT_QUERY, types.PgValueText(val))
52+
selectResult := Query(SelectQuery, types.PgValueText(val))
5453
if selectResult.IsErr() {
5554
logger.Error("failed to select rows", "err", selectResult.Err())
5655
return fmt.Sprintf("ERROR: failed to select rows: %v", selectResult.Err())

examples/provider/keyvalue-inmemory/main_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ func TestListKeys(t *testing.T) {
320320

321321
func NewTestEnvironment(ctx context.Context, t testing.TB) (*TestEnvironment, error) {
322322
natsServer, err := startContainer(ctx)
323-
normalizedName := strings.Replace(t.Name(), "/", "-", -1)
323+
normalizedName := strings.ReplaceAll(t.Name(), "/", "-")
324324
testcontainers.CleanupContainer(t, natsServer.Container)
325325
if err != nil {
326326
return nil, err

examples/wasmbus/wasmcloud-rpc/events.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ func eventCommand() *cli.Command {
4141
callback := func(_ context.Context, ev events.Event) {
4242
jsonEv, err := json.MarshalIndent(ev.BusEvent, "", " ")
4343
if err != nil {
44-
log.Printf("Error marshalling event: %s", err)
44+
log.Printf("Error marshaling event: %s", err)
4545
return
4646
}
4747

0 commit comments

Comments
 (0)