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
38 changes: 38 additions & 0 deletions .github/workflows/staticcheck.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
on: [push, pull_request]
jobs:
verify:
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 ..
# Spelling check
- 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 .
2 changes: 1 addition & 1 deletion api/internal/domain/long-term/usecase.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion api/internal/handlers/error_response.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
2 changes: 1 addition & 1 deletion api/internal/infrastructure/github/clients_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion api/internal/infrastructure/github/fetcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion api/internal/repo/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
2 changes: 1 addition & 1 deletion api/internal/repo/github_user_data/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
}()
Expand Down
2 changes: 1 addition & 1 deletion api/internal/repo/github_user_data/save.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
}()
Expand Down
2 changes: 1 addition & 1 deletion api/internal/repo/github_user_data/storage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
4 changes: 2 additions & 2 deletions api/internal/repo/github_user_data/usernames.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}

Expand Down
2 changes: 1 addition & 1 deletion api/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion renderer/internal/handlers/http/preview.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion renderer/internal/infrastructure/kafka/consumer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

Expand Down
2 changes: 1 addition & 1 deletion storage/internal/handlers/error_response.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
Loading