Skip to content

Commit 86b8a59

Browse files
committed
chore: upgrade CI workflows and fix all lint issues
- Upgrade CI: actions/checkout@v6, actions/setup-go@v6, golangci-lint-action@v9, goreleaser-action@v7, setup-protoc@v3 - Use go-version-file instead of hardcoded Go versions - Add concurrency groups and path filters - Update golangci-lint config to v2 schema - Fix all errcheck issues (unchecked MarkFlagRequired, json.Encode, etc.) - Fix staticcheck issues (deprecated ioutil/rand, redundant nil checks) - Add comments on exported types
1 parent 0c25425 commit 86b8a59

30 files changed

Lines changed: 167 additions & 115 deletions

.github/workflows/docs.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
1-
name: docs
1+
name: Docs
22

33
on:
44
push:
55
branches:
66
- main
7+
paths-ignore:
8+
- "**.md"
79
workflow_dispatch:
810

911
jobs:
1012
documentation:
1113
runs-on: ubuntu-latest
1214
steps:
13-
- uses: actions/checkout@v2
14-
- uses: actions/setup-node@v2
15+
- uses: actions/checkout@v6
16+
- uses: actions/setup-node@v4
1517
- name: Installation
1618
uses: bahmutov/npm-install@v1
1719
with:

.github/workflows/lint.yml

Lines changed: 27 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,34 @@
1-
name: "Lint"
1+
name: Lint
22

3-
on: [push, pull_request]
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths-ignore:
8+
- "**.md"
9+
- "docs/**"
10+
pull_request:
11+
paths-ignore:
12+
- "**.md"
13+
- "docs/**"
14+
15+
concurrency:
16+
group: lint-${{ github.ref }}
17+
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
418

519
jobs:
620
golangci:
7-
name: "Lint"
8-
runs-on: "ubuntu-latest"
21+
runs-on: ubuntu-latest
922
steps:
10-
- uses: actions/setup-go@v5
11-
- uses: actions/checkout@v4
12-
- name: Crete empty build directory
13-
run: mkdir ui/build && touch ui/build/.gitkeep
14-
- name: golangci-lint
15-
uses: golangci/golangci-lint-action@v6
23+
- uses: actions/checkout@v6
24+
- uses: actions/setup-go@v6
1625
with:
17-
version: v1.64
18-
19-
codeql:
20-
name: "Analyze with CodeQL"
21-
runs-on: "ubuntu-latest"
22-
permissions:
23-
actions: "read"
24-
contents: "read"
25-
security-events: "write"
26-
strategy:
27-
fail-fast: false
28-
matrix:
29-
language: ["go"]
30-
steps:
31-
- uses: "actions/checkout@v2"
32-
- uses: "github/codeql-action/init@v1"
26+
go-version-file: "go.mod"
27+
cache: true
28+
- name: Create empty UI build directory
29+
run: mkdir -p ui/build && touch ui/build/.gitkeep
30+
- name: golangci-lint
31+
uses: golangci/golangci-lint-action@v9
3332
with:
34-
languages: "${{ matrix.language }}"
35-
- uses: "github/codeql-action/autobuild@v1"
36-
- uses: "github/codeql-action/analyze@v1"
33+
version: latest
34+
args: --timeout=5m
Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
name: Release
2+
23
on:
34
push:
45
tags:
5-
- "v*.*.*"
6+
- "v*"
67
workflow_dispatch:
78
inputs:
89
goreleaserArgs:
@@ -14,24 +15,25 @@ jobs:
1415
runs-on: ubuntu-latest
1516
steps:
1617
- name: Checkout
17-
uses: actions/checkout@v3
18+
uses: actions/checkout@v6
1819
with:
1920
fetch-depth: 0
2021
- name: Set up Go
21-
uses: actions/setup-go@v4
22+
uses: actions/setup-go@v6
2223
with:
23-
go-version: "1.20"
24+
go-version-file: "go.mod"
25+
cache: true
2426
- name: Login to DockerHub
25-
uses: docker/login-action@v1
27+
uses: docker/login-action@v4
2628
with:
2729
registry: docker.io
2830
username: ${{ secrets.DOCKERHUB_USERNAME }}
2931
password: ${{ secrets.DOCKERHUB_TOKEN }}
3032
- name: Run GoReleaser
31-
uses: goreleaser/goreleaser-action@v5
33+
uses: goreleaser/goreleaser-action@v7
3234
with:
3335
distribution: goreleaser
34-
version: v1.21.2
35-
args: --rm-dist ${{ inputs.goreleaserArgs }}
36+
version: latest
37+
args: release --clean ${{ inputs.goreleaserArgs }}
3638
env:
3739
GITHUB_TOKEN: ${{ secrets.GO_RELEASER_TOKEN }}

.github/workflows/test-server.yaml

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,24 @@ on:
44
push:
55
branches:
66
- main
7+
paths-ignore:
8+
- "**.md"
9+
- "docs/**"
710
pull_request:
8-
workflow_dispatch:
11+
paths-ignore:
12+
- "**.md"
13+
- "docs/**"
14+
15+
concurrency:
16+
group: test-${{ github.ref }}
17+
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
918

1019
jobs:
1120
test:
1221
runs-on: ubuntu-latest
1322
services:
1423
postgres:
15-
image: postgres:13
24+
image: postgres:15
1625
env:
1726
POSTGRES_HOST: localhost
1827
POSTGRES_USER: postgres
@@ -26,18 +35,24 @@ jobs:
2635
ports:
2736
- 5432:5432
2837
steps:
29-
- name: Set up Go 1.x
30-
uses: actions/setup-go@v4
38+
- uses: actions/checkout@v6
39+
- uses: actions/setup-go@v6
3140
with:
32-
go-version: ^1.20
33-
id: go
41+
go-version-file: "go.mod"
42+
cache: true
43+
- name: Create empty UI build directory
44+
run: mkdir -p ui/build && touch ui/build/.gitkeep
3445
- name: Install Protoc
35-
uses: arduino/setup-protoc@v1
46+
uses: arduino/setup-protoc@v3
3647
with:
37-
version: "3.x"
38-
- name: Check out code into the Go module directory
39-
uses: actions/checkout@v2
40-
- name: Test
48+
version: "25.x"
49+
- name: Run Test
4150
run: make test
4251
env:
4352
TEST_DB_CONNECTIONSTRING: "postgres://postgres:postgres@localhost:5432/test_stencil_db?sslmode=disable"
53+
- name: Install goveralls and send coverage
54+
env:
55+
COVERALLS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
56+
run: |
57+
go install github.com/mattn/goveralls@latest
58+
goveralls -coverprofile=coverage.out -service=github

.golangci.yaml

Lines changed: 15 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,27 @@
1+
version: "2"
12
run:
23
timeout: 5m
3-
output:
4-
formats:
5-
- format: colored-line-number
4+
formatters:
5+
enable:
6+
- goimports
7+
- gofmt
68
linters:
7-
enable-all: false
8-
disable-all: true
99
enable:
1010
- govet
11-
- goimports
1211
- thelper
1312
- tparallel
1413
- unconvert
1514
- wastedassign
16-
- revive
1715
- unused
18-
- gofmt
1916
- whitespace
2017
- misspell
21-
linters-settings:
22-
revive:
23-
ignore-generated-header: true
24-
severity: warning
25-
issues:
26-
exclude-dirs:
27-
- api/proto
28-
- clients/java
29-
- clients/js
30-
- docs
31-
- scripts
32-
- ui
33-
fix: true
34-
severity:
35-
default-severity: error
18+
- errcheck
19+
- staticcheck
20+
exclusions:
21+
paths:
22+
- clients/java
23+
- clients/js
24+
- docs
25+
- scripts
26+
- ui
27+
- gen

cmd/check.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,13 @@ func checkSchemaCmd(cdk *CDK) *cobra.Command {
6060
}
6161

6262
cmd.Flags().StringVarP(&namespaceID, "namespace", "n", "", "Parent namespace ID")
63-
cmd.MarkFlagRequired("namespace")
63+
_ = cmd.MarkFlagRequired("namespace")
6464

6565
cmd.Flags().StringVarP(&comp, "comp", "c", "", "Schema compatibility")
66-
cmd.MarkFlagRequired("comp")
66+
_ = cmd.MarkFlagRequired("comp")
6767

6868
cmd.Flags().StringVarP(&file, "file", "F", "", "Path to the schema file")
69-
cmd.MarkFlagRequired("file")
69+
_ = cmd.MarkFlagRequired("file")
7070

7171
return cmd
7272
}

cmd/create.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,14 @@ func createSchemaCmd(cdk *CDK) *cobra.Command {
6464
}
6565

6666
cmd.Flags().StringVarP(&namespaceID, "namespace", "n", "", "Namespace ID")
67-
cmd.MarkFlagRequired("namespace")
67+
_ = cmd.MarkFlagRequired("namespace")
6868

6969
cmd.Flags().StringVarP(&format, "format", "f", "", "Schema format")
7070

7171
cmd.Flags().StringVarP(&comp, "comp", "c", "", "Schema compatibility")
7272

7373
cmd.Flags().StringVarP(&file, "file", "F", "", "Path to the schema file")
74-
cmd.MarkFlagRequired("file")
74+
_ = cmd.MarkFlagRequired("file")
7575

7676
return cmd
7777
}

cmd/delete.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ func deleteSchemaCmd(cdk *CDK) *cobra.Command {
5959
}
6060

6161
cmd.Flags().StringVarP(&namespaceID, "namespace", "n", "", "Parent namespace ID")
62-
cmd.MarkFlagRequired("namespace")
62+
_ = cmd.MarkFlagRequired("namespace")
6363

6464
cmd.Flags().Int32VarP(&version, "version", "v", 0, "Particular version to be deleted")
6565

cmd/diff.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,9 @@ func diffSchemaCmd(cdk *CDK) *cobra.Command {
123123
}
124124

125125
var placeholder map[string]interface{}
126-
json.Unmarshal(eJson, &placeholder)
126+
if err := json.Unmarshal(eJson, &placeholder); err != nil {
127+
return err
128+
}
127129
config := formatter.AsciiFormatterConfig{
128130
ShowArrayIndex: true,
129131
Coloring: true,
@@ -147,11 +149,11 @@ func diffSchemaCmd(cdk *CDK) *cobra.Command {
147149
}
148150

149151
cmd.Flags().StringVarP(&namespace, "namespace", "n", "", "Parent namespace ID")
150-
cmd.MarkFlagRequired("namespace")
152+
_ = cmd.MarkFlagRequired("namespace")
151153
cmd.Flags().Int32Var(&earlierVersion, "earlier-version", 0, "Earlier version of the schema")
152-
cmd.MarkFlagRequired("earlier-version")
154+
_ = cmd.MarkFlagRequired("earlier-version")
153155
cmd.Flags().Int32Var(&laterVersion, "later-version", 0, "Later version of the schema")
154-
cmd.MarkFlagRequired("later-version")
156+
_ = cmd.MarkFlagRequired("later-version")
155157
cmd.Flags().StringVar(&fullname, "fullname", "", "Only applicable for FORMAT_PROTO. fullname of proto schema eg: raystack.common.v1.Version")
156158
return cmd
157159
}

cmd/download.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,12 @@ func downloadSchemaCmd(cdk *CDK) *cobra.Command {
4646
}
4747

4848
cmd.Flags().StringVarP(&namespaceID, "namespace", "n", "", "Parent namespace ID")
49-
cmd.MarkFlagRequired("namespace")
49+
_ = cmd.MarkFlagRequired("namespace")
5050

5151
cmd.Flags().Int32VarP(&version, "version", "v", 0, "Version of the schema")
5252

5353
cmd.Flags().StringVarP(&output, "output", "o", "", "Path to the output file")
54-
cmd.MarkFlagRequired("output")
54+
_ = cmd.MarkFlagRequired("output")
5555

5656
return cmd
5757
}

0 commit comments

Comments
 (0)