From a84c1436cb95fe41ed1aae0f653de970638080c9 Mon Sep 17 00:00:00 2001 From: Nathan ter Bogt Date: Tue, 22 Sep 2026 20:17:28 +1200 Subject: [PATCH 1/6] Initial setup of golangci --- .golangci.yml | 26 +++++++++++++++++++++ .mise.toml | 9 +++---- internal/server/mock/metrics/server.go | 3 ++- internal/server/mock/metrics/server_test.go | 3 ++- 4 files changed, 35 insertions(+), 6 deletions(-) create mode 100644 .golangci.yml diff --git a/.golangci.yml b/.golangci.yml new file mode 100644 index 0000000..384c0ff --- /dev/null +++ b/.golangci.yml @@ -0,0 +1,26 @@ +version: "2" + +issues: + max-issues-per-linter: 0 + max-same-issues: 0 + +linters: + enable: + - gosec + disable: + # We check error as part of our PR process. + - errcheck + +formatters: + enable: + - gci + settings: + gci: + sections: + - standard + - default + - localmodule + no-inline-comments: true + no-prefix-comments: true + custom-order: true + no-lex-order: true diff --git a/.mise.toml b/.mise.toml index 77b1557..4475a65 100644 --- a/.mise.toml +++ b/.mise.toml @@ -1,12 +1,13 @@ [tools] go = "1.26" "go:github.com/daixiang0/gci" = "latest" -"ubi:golangci/golangci-lint" = "2.10" -"ubi:goreleaser/goreleaser" = "2.14" +"github:golangci/golangci-lint" = "latest" +"github:securego/gosec" = "latest" +"github:goreleaser/goreleaser" = "latest" [env] CGO_ENABLED=0 -LGFLAGS="-extldflags '-static'" +LDFLAGS="-extldflags '-static'" IMAGE="skpr/grpc-go:latest" PB_DIR="./pb" @@ -32,7 +33,7 @@ docker run -w /data -v .:/data $IMAGE /bin/bash -c 'protoc --go_out=./pb --go_op [tasks."build"] description = "Build the application" -run = "go build -o bin/apiserver-mock -ldflags=${CLI_LDFLAGS} github.com/skpr/api/cmd/apiserver-mock" +run = "go build -o bin/apiserver-mock -ldflags=\"${LDFLAGS}\" github.com/skpr/api/cmd/apiserver-mock" depends = ["vendor"] [tasks.mock] diff --git a/internal/server/mock/metrics/server.go b/internal/server/mock/metrics/server.go index 22afd33..e61ac79 100644 --- a/internal/server/mock/metrics/server.go +++ b/internal/server/mock/metrics/server.go @@ -7,10 +7,11 @@ import ( "strings" "time" - "github.com/skpr/api/pb" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" "google.golang.org/protobuf/types/known/timestamppb" + + "github.com/skpr/api/pb" ) // Server implements the GRPC "events" definition. diff --git a/internal/server/mock/metrics/server_test.go b/internal/server/mock/metrics/server_test.go index 3ffe83a..031f58d 100644 --- a/internal/server/mock/metrics/server_test.go +++ b/internal/server/mock/metrics/server_test.go @@ -5,10 +5,11 @@ import ( "testing" "time" - "github.com/skpr/api/pb" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" "google.golang.org/protobuf/types/known/timestamppb" + + "github.com/skpr/api/pb" ) var srv = &Server{} From b21e11131f007488290f96ce8d83d18a1085afac Mon Sep 17 00:00:00 2001 From: Nathan ter Bogt Date: Tue, 22 Sep 2026 20:21:32 +1200 Subject: [PATCH 2/6] Use the action for installing --- .github/workflows/quality.yml | 9 ++------- .github/workflows/release.yml | 8 ++------ .github/workflows/test.yml | 7 ++----- 3 files changed, 6 insertions(+), 18 deletions(-) diff --git a/.github/workflows/quality.yml b/.github/workflows/quality.yml index 6470184..4e1760d 100644 --- a/.github/workflows/quality.yml +++ b/.github/workflows/quality.yml @@ -13,12 +13,7 @@ jobs: uses: actions/checkout@v6 - name: ๐Ÿ“ฆ Install Mise - run: | - curl https://mise.run | sh - mise install - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + uses: jdx/mise-action@v4 - name: ๐Ÿงช Lint - run: | - mise run lint + run: mise run lint diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 57bd4c9..08e694d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -26,16 +26,12 @@ jobs: password: ${{ secrets.GITHUB_TOKEN }} - name: ๐Ÿ“ฆ Install Mise - run: | - curl https://mise.run | sh - mise install - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + uses: jdx/mise-action@v4 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - name: Run GoReleaser - run: mise release + run: mise run release env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 34df649..ff218ec 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -18,10 +18,7 @@ jobs: uses: actions/checkout@v6 - name: ๐Ÿ“ฆ Install Mise - run: | - curl https://mise.run | sh - mise install + uses: jdx/mise-action@v4 - name: ๐Ÿงช Test - run: | - mise run test + run: mise run test From a52df1ef1f3c48229daf16e9e4f65d11f10c3ef2 Mon Sep 17 00:00:00 2001 From: Nathan ter Bogt Date: Tue, 22 Sep 2026 20:29:44 +1200 Subject: [PATCH 3/6] Fixing the int32 issue and surpressing a crypto safe warning. --- internal/model/model.go | 8 ++++---- internal/random/string.go | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/internal/model/model.go b/internal/model/model.go index f544b0f..3204da3 100644 --- a/internal/model/model.go +++ b/internal/model/model.go @@ -40,7 +40,7 @@ func (s *Model) GetEnvironments() []*Environment { return response } -func (s *Model) CreateEnvironment(name string, size int, metrics bool) { +func (s *Model) CreateEnvironment(name string, size int32, metrics bool) { environment := &pb.Environment{ Name: name, Version: "v0.0.1", @@ -62,9 +62,9 @@ func (s *Model) CreateEnvironment(name string, size int, metrics bool) { Limit: 512 * int64(size) * 1024, }, Replicas: &pb.EnvironmentResourcesReplicas{ - Current: 1 * int32(size), - Min: 1 * int32(size), - Max: 5 * int32(size), + Current: 1 * size, + Min: 1 * size, + Max: 5 * size, }, }, Cron: []*pb.Cron{ diff --git a/internal/random/string.go b/internal/random/string.go index b883486..92375e0 100644 --- a/internal/random/string.go +++ b/internal/random/string.go @@ -9,7 +9,7 @@ const charset = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" func StringOfLength(length int) string { b := make([]byte, length) for i := range b { - b[i] = charset[rand.Intn(len(charset))] + b[i] = charset[rand.Intn(len(charset))] //nolint:gosec // G404: cosmetic random string, not used for auth/tokens } return string(b) } From eab3ac95b10b5b3b4890def83f5342ab7491d110 Mon Sep 17 00:00:00 2001 From: Nathan ter Bogt Date: Tue, 22 Sep 2026 20:32:52 +1200 Subject: [PATCH 4/6] Include errcheck issues too --- .golangci.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 384c0ff..2285de2 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -7,9 +7,6 @@ issues: linters: enable: - gosec - disable: - # We check error as part of our PR process. - - errcheck formatters: enable: From 47ee2d2395e71319717ad9795dc25251f79a0b85 Mon Sep 17 00:00:00 2001 From: Nathan ter Bogt Date: Tue, 22 Sep 2026 20:36:01 +1200 Subject: [PATCH 5/6] Renaming workflow --- .github/workflows/quality.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/quality.yml b/.github/workflows/quality.yml index 4e1760d..bc214e0 100644 --- a/.github/workflows/quality.yml +++ b/.github/workflows/quality.yml @@ -1,4 +1,4 @@ -name: ๐Ÿ“‹ GolangCI Checks +name: ๐Ÿ“‹ Lint on: pull_request: @@ -6,7 +6,7 @@ on: jobs: lint: - name: ๐Ÿ“‹ GolangCI + name: ๐Ÿ“‹ Lint runs-on: ubuntu-latest steps: - name: โฌ‡๏ธ Git clone the repository From 37d1d22da9c76039b709859cffec44742b84d1bf Mon Sep 17 00:00:00 2001 From: Nathan ter Bogt Date: Tue, 22 Sep 2026 20:37:31 +1200 Subject: [PATCH 6/6] Even better naming --- .github/workflows/quality.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/quality.yml b/.github/workflows/quality.yml index bc214e0..e148157 100644 --- a/.github/workflows/quality.yml +++ b/.github/workflows/quality.yml @@ -6,7 +6,6 @@ on: jobs: lint: - name: ๐Ÿ“‹ Lint runs-on: ubuntu-latest steps: - name: โฌ‡๏ธ Git clone the repository