From 6714aa81a8921cb778156e1eeaa51a0e0602ecf7 Mon Sep 17 00:00:00 2001 From: Igor Shishkin Date: Sat, 17 Aug 2024 22:05:36 +0300 Subject: [PATCH] Fix ineffassign issues & add it to CI (#156) Signed-off-by: Igor Shishkin --- .github/workflows/release.yml | 13 +++++++++++++ .github/workflows/verify.yml | 13 +++++++++++++ cmd/manager/main.go | 3 +++ cmd/publisher/main.go | 3 +++ gc/service/service.go | 7 +++---- repositories/metadata/postgresql/stats.go | 3 +++ 6 files changed, 38 insertions(+), 4 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 20d1242..071cecd 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -44,6 +44,19 @@ jobs: - uses: actions/checkout@v4 - uses: articulate/actions-markdownlint@v1 + ineffassign: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Setup Go + uses: actions/setup-go@v5 + with: + go-version: '1.23.x' + - name: Install ineffassign + run: go install github.com/gordonklaus/ineffassign@latest + - name: Run ineffassign + run: ineffassign ./... + unittests: runs-on: ubuntu-latest steps: diff --git a/.github/workflows/verify.yml b/.github/workflows/verify.yml index cea269f..53ab973 100644 --- a/.github/workflows/verify.yml +++ b/.github/workflows/verify.yml @@ -50,6 +50,19 @@ jobs: - uses: actions/checkout@v4 - uses: articulate/actions-markdownlint@v1 + ineffassign: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Setup Go + uses: actions/setup-go@v5 + with: + go-version: '1.23.x' + - name: Install ineffassign + run: go install github.com/gordonklaus/ineffassign@latest + - name: Run ineffassign + run: ineffassign ./... + unittests: runs-on: ubuntu-latest steps: diff --git a/cmd/manager/main.go b/cmd/manager/main.go index 6c0b673..919f82d 100644 --- a/cmd/manager/main.go +++ b/cmd/manager/main.go @@ -88,6 +88,9 @@ func main() { cfg.BLOBS3AccessKeyID, cfg.BLOBS3SecretKey, "", ), }) + if err != nil { + panic(err) + } s3client := s3.New(awsSession) diff --git a/cmd/publisher/main.go b/cmd/publisher/main.go index 9a58f6d..20a0ade 100644 --- a/cmd/publisher/main.go +++ b/cmd/publisher/main.go @@ -113,6 +113,9 @@ func main() { cfg.BLOBS3AccessKeyID, cfg.BLOBS3SecretKey, "", ), }) + if err != nil { + panic(err) + } blobRepo := awsBlobRepo.New(s3.New(awsSession), cfg.BLOBS3Bucket, cfg.BLOBS3PresignedLinkTTL) diff --git a/gc/service/service.go b/gc/service/service.go index 7873e81..213852c 100644 --- a/gc/service/service.go +++ b/gc/service/service.go @@ -65,8 +65,8 @@ func (s *service) Run(ctx context.Context) error { } var ( - total uint64 = 0 - offset uint64 = 0 + total uint64 + offset uint64 ) for { @@ -77,8 +77,7 @@ func (s *service) Run(ctx context.Context) error { "limit": defaultLimit, }).Tracef("list objects loop iteration ...") - var objects []string = []string{} - + var objects []string total, objects, err = s.cfg.MdRepo.ListObjects(ctx, container, version.Name, offset, defaultLimit) if err != nil { return errors.Wrapf(err, "error listing objects for container `%s`; version `%s`", container, version.Name) diff --git a/repositories/metadata/postgresql/stats.go b/repositories/metadata/postgresql/stats.go index 6d748d2..e9f83c9 100644 --- a/repositories/metadata/postgresql/stats.go +++ b/repositories/metadata/postgresql/stats.go @@ -96,6 +96,9 @@ func (r *repository) CountStats(ctx context.Context) (*models.Stats, error) { GroupBy("c.name", "v.name", "v.is_published"). OrderBy("c.name", "v.name", "v.is_published"), ) + if err != nil { + return nil, err + } for rows.Next() { brsb := models.BlobsRawSizeBytes{}