From 19700cc331267d788cfaa570ed8946d0a7822452 Mon Sep 17 00:00:00 2001 From: uno/hurtki Date: Mon, 16 Mar 2026 13:07:20 +0200 Subject: [PATCH 1/2] add: CI staticcheck job: formatting|go test|spelling --- .github/workflows/staticcheck.yaml | 37 ++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 .github/workflows/staticcheck.yaml diff --git a/.github/workflows/staticcheck.yaml b/.github/workflows/staticcheck.yaml new file mode 100644 index 0000000..7ec7826 --- /dev/null +++ b/.github/workflows/staticcheck.yaml @@ -0,0 +1,37 @@ +on: [push, pull_request] +jobs: + test: + runs-on: ubuntu-latest + env: + GO111MODULE: on + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-go@v4 + with: + go-version: '1.25.5' + cache: false + - run: go env + # formating checking + - name: Check gofmt + run: | + if [ -n "$(gofmt -s -l .)" ]; then + echo "Go files are not formatted. Run 'gofmt -s -w .' to fix." + exit 1 + fi + # Running tests + - name: Run tests + run: | + cd api + go test -v ./... --count=1 + cd ../renderer/ + go test -v ./... --count=1 + cd ../storage/ + go test -v ./... --count=1 + cd .. + - name: Check spelling + run: | + curl -L -o ./install-misspell.sh https://git.io/misspell + sh ./install-misspell.sh + mv ./bin/misspell . + chmod +x ./misspell + ./misspell -source=auto -error . From 5b2373d591709dce308b531650a76ec7144003a8 Mon Sep 17 00:00:00 2001 From: uno/hurtki Date: Mon, 16 Mar 2026 13:14:01 +0200 Subject: [PATCH 2/2] fix: spelling using misspell -source=auto -w . --- .github/workflows/staticcheck.yaml | 5 +++-- api/internal/domain/long-term/usecase.go | 2 +- api/internal/handlers/error_response.go | 2 +- api/internal/infrastructure/github/clients_pool.go | 2 +- api/internal/infrastructure/github/fetcher.go | 2 +- api/internal/repo/errors.go | 2 +- api/internal/repo/github_user_data/get.go | 2 +- api/internal/repo/github_user_data/save.go | 2 +- api/internal/repo/github_user_data/storage_test.go | 2 +- api/internal/repo/github_user_data/usernames.go | 4 ++-- api/main.go | 2 +- renderer/internal/handlers/http/preview.go | 2 +- .../infrastructure/kafka/cg_handlers/banner_update.go | 2 +- renderer/internal/infrastructure/kafka/consumer.go | 2 +- storage/internal/handlers/error_response.go | 2 +- 15 files changed, 18 insertions(+), 17 deletions(-) diff --git a/.github/workflows/staticcheck.yaml b/.github/workflows/staticcheck.yaml index 7ec7826..8c50d50 100644 --- a/.github/workflows/staticcheck.yaml +++ b/.github/workflows/staticcheck.yaml @@ -1,6 +1,6 @@ on: [push, pull_request] jobs: - test: + verify: runs-on: ubuntu-latest env: GO111MODULE: on @@ -11,7 +11,7 @@ jobs: go-version: '1.25.5' cache: false - run: go env - # formating checking + # Formating checking - name: Check gofmt run: | if [ -n "$(gofmt -s -l .)" ]; then @@ -28,6 +28,7 @@ jobs: cd ../storage/ go test -v ./... --count=1 cd .. + # Spelling check - name: Check spelling run: | curl -L -o ./install-misspell.sh https://git.io/misspell diff --git a/api/internal/domain/long-term/usecase.go b/api/internal/domain/long-term/usecase.go index bebc573..6b1c0e5 100644 --- a/api/internal/domain/long-term/usecase.go +++ b/api/internal/domain/long-term/usecase.go @@ -49,7 +49,7 @@ func (u *LTBannersUsecase) CreateBanner(ctx context.Context, in CreateBannerIn) bnrMeta.UrlPath = generateUrlPath(bnrMeta.Username, bnrMeta.BannerType) bnrMeta.Active = true case errors.As(err, &errRepoInternal): - // if db internal error occured, we won't go to next services + // if db internal error occurred, we won't go to next services // because, then we could get same thing when saving a new banner and all the work will be useless return CreateBannerOut{}, ErrCantCreateBanner default: diff --git a/api/internal/handlers/error_response.go b/api/internal/handlers/error_response.go index 44ef197..c43effe 100644 --- a/api/internal/handlers/error_response.go +++ b/api/internal/handlers/error_response.go @@ -15,7 +15,7 @@ func (h *BannersHandler) error(rw http.ResponseWriter, statusCode int, message s if err != nil { h.logger.Error("can't marshal error response", "err", err, "source", fn) rw.WriteHeader(http.StatusInternalServerError) - _, err := rw.Write([]byte("{\"error\": \"server error occured\"}")) + _, err := rw.Write([]byte("{\"error\": \"server error occurred\"}")) if err != nil { h.logger.Warn("can't write error response", "err", err, "source", fn) } diff --git a/api/internal/infrastructure/github/clients_pool.go b/api/internal/infrastructure/github/clients_pool.go index 7d6305f..8106ac2 100644 --- a/api/internal/infrastructure/github/clients_pool.go +++ b/api/internal/infrastructure/github/clients_pool.go @@ -32,7 +32,7 @@ func (f *Fetcher) acquireClient(ctx context.Context) *GithubClient { rl, _, err := cl.Client.RateLimit.Get(ctx) cancel() if err != nil { - f.logger.Error("found client, that its Reset time is before Now(), error occured when getting its rate limit, skipping", "err", err, "source", fn) + f.logger.Error("found client, that its Reset time is before Now(), error occurred when getting its rate limit, skipping", "err", err, "source", fn) continue } // after net call, we are having new source of truth diff --git a/api/internal/infrastructure/github/fetcher.go b/api/internal/infrastructure/github/fetcher.go index 363e524..298ae9a 100644 --- a/api/internal/infrastructure/github/fetcher.go +++ b/api/internal/infrastructure/github/fetcher.go @@ -123,7 +123,7 @@ func (f *Fetcher) fetchRepositories(ctx context.Context, username string) ([]*gi } for { - // every page aquire a new client for one request + // every page acquire a new client for one request cl := f.acquireClient(ctx) if cl == nil { f.logger.Warn("can't find available client for github api request") diff --git a/api/internal/repo/errors.go b/api/internal/repo/errors.go index 33ff33b..479e1d8 100644 --- a/api/internal/repo/errors.go +++ b/api/internal/repo/errors.go @@ -21,7 +21,7 @@ func (e ErrEmptyField) Error() string { return fmt.Sprintf("field %s should be n type ErrRepoInternal struct{ Note string } func (e ErrRepoInternal) Error() string { - return fmt.Sprintf("internal repo occured, note: %s", e.Note) + return fmt.Sprintf("internal repo occurred, note: %s", e.Note) } var ( diff --git a/api/internal/repo/github_user_data/get.go b/api/internal/repo/github_user_data/get.go index 3faa143..84254c6 100644 --- a/api/internal/repo/github_user_data/get.go +++ b/api/internal/repo/github_user_data/get.go @@ -27,7 +27,7 @@ func (r *GithubDataPsgrRepo) GetUserData(ctx context.Context, username string) ( if !committed { rbErr := tx.Rollback() if rbErr != nil { - r.logger.Error("error occured, when rolling back transaction", "err", rbErr, "source", fn) + r.logger.Error("error occurred, when rolling back transaction", "err", rbErr, "source", fn) } } }() diff --git a/api/internal/repo/github_user_data/save.go b/api/internal/repo/github_user_data/save.go index a3a1184..cf17baa 100644 --- a/api/internal/repo/github_user_data/save.go +++ b/api/internal/repo/github_user_data/save.go @@ -29,7 +29,7 @@ func (r *GithubDataPsgrRepo) SaveUserData(ctx context.Context, userData domain.G if !committed { rbErr := tx.Rollback() if rbErr != nil { - r.logger.Error("error occured, when rolling back transaction", "err", rbErr, "source", fn) + r.logger.Error("error occurred, when rolling back transaction", "err", rbErr, "source", fn) } } }() diff --git a/api/internal/repo/github_user_data/storage_test.go b/api/internal/repo/github_user_data/storage_test.go index adba76d..c323239 100644 --- a/api/internal/repo/github_user_data/storage_test.go +++ b/api/internal/repo/github_user_data/storage_test.go @@ -19,7 +19,7 @@ func (m LoggerMock) Warn(a string, b ...any) {} func (m LoggerMock) Error(a string, b ...any) {} func (m LoggerMock) With(a ...any) logger.Logger { return m } -// helper for testing to create sql mock, create repoistory with it +// helper for testing to create sql mock, create repository with it // checks sqlmock expectations func getMockAndRepo(t *testing.T) (sqlmock.Sqlmock, *GithubDataPsgrRepo) { db, mock, _ := sqlmock.New( diff --git a/api/internal/repo/github_user_data/usernames.go b/api/internal/repo/github_user_data/usernames.go index e6ea732..399372a 100644 --- a/api/internal/repo/github_user_data/usernames.go +++ b/api/internal/repo/github_user_data/usernames.go @@ -19,14 +19,14 @@ func (r *GithubDataPsgrRepo) GetAllUsernames(ctx context.Context) ([]string, err username := "" err := rows.Scan(&username) if err != nil { - r.logger.Error("unexcpected error occured when scanning usernames", "source", fn, "err", err) + r.logger.Error("unexcpected error occurred when scanning usernames", "source", fn, "err", err) return nil, r.handleError(err, fn+".scanUsername") } usernames = append(usernames, username) } if err := rows.Err(); err != nil { - r.logger.Error("unexcpected error occured after scanning usernames", "source", fn, "err", err) + r.logger.Error("unexcpected error occurred after scanning usernames", "source", fn, "err", err) return nil, r.handleError(err, fn+".afterScanRowsError") } diff --git a/api/main.go b/api/main.go index cad8b84..d7ee4b4 100644 --- a/api/main.go +++ b/api/main.go @@ -133,7 +133,7 @@ func main() { srv := server.New(cfg, router, logger) srv.Start() - // gracefull shutdown + // graceful shutdown quit := make(chan os.Signal, 1) signal.Notify(quit, os.Interrupt, syscall.SIGTERM) <-quit diff --git a/renderer/internal/handlers/http/preview.go b/renderer/internal/handlers/http/preview.go index 35be11f..8a3cb1d 100644 --- a/renderer/internal/handlers/http/preview.go +++ b/renderer/internal/handlers/http/preview.go @@ -65,7 +65,7 @@ func (h *PreviewHandler) error(rw http.ResponseWriter, statusCode int, message s if err != nil { h.logger.Error("can't marshal error response", "err", err, "source", fn) rw.WriteHeader(http.StatusInternalServerError) - _, err := rw.Write([]byte("{\"error\": \"server error occured\"}")) + _, err := rw.Write([]byte("{\"error\": \"server error occurred\"}")) if err != nil { h.logger.Warn("can't write error response", "err", err, "source", fn) } diff --git a/renderer/internal/infrastructure/kafka/cg_handlers/banner_update.go b/renderer/internal/infrastructure/kafka/cg_handlers/banner_update.go index e5d88bc..428e6dd 100644 --- a/renderer/internal/infrastructure/kafka/cg_handlers/banner_update.go +++ b/renderer/internal/infrastructure/kafka/cg_handlers/banner_update.go @@ -64,7 +64,7 @@ func (h *BannerUpdateCGHandler) ConsumeClaim(session sarama.ConsumerGroupSession for range h.cfg.EventsBatchSize { select { - // if session context done, exiting immediatly + // if session context done, exiting immediately case <-session.Context().Done(): cancel() return nil diff --git a/renderer/internal/infrastructure/kafka/consumer.go b/renderer/internal/infrastructure/kafka/consumer.go index eee33d8..5991a0f 100644 --- a/renderer/internal/infrastructure/kafka/consumer.go +++ b/renderer/internal/infrastructure/kafka/consumer.go @@ -70,7 +70,7 @@ func (c *KafkaConsumerGroup) RegisterCGHandler(topics []string, handler sarama.C func (c *KafkaConsumerGroup) registerCGHandler(topics []string, handler sarama.ConsumerGroupHandler) { err := c.cg.Consume(c.ctx, topics, handler) if err != nil { - c.logger.Error("error occured, when registering consumer group handler", "err", err, "topics", topics) + c.logger.Error("error occurred, when registering consumer group handler", "err", err, "topics", topics) } } diff --git a/storage/internal/handlers/error_response.go b/storage/internal/handlers/error_response.go index 2fba382..8c7b46a 100644 --- a/storage/internal/handlers/error_response.go +++ b/storage/internal/handlers/error_response.go @@ -15,7 +15,7 @@ func (h *BannerSaveHandler) error(rw http.ResponseWriter, statusCode int, messag if err != nil { h.logger.Error("can't marshal error response", "err", err, "source", fn) rw.WriteHeader(http.StatusInternalServerError) - _, err := rw.Write([]byte("{\"error\": \"server error occured\"}")) + _, err := rw.Write([]byte("{\"error\": \"server error occurred\"}")) if err != nil { h.logger.Warn("can't write error response", "err", err, "source", fn) }