From f8cb673510fa92a615748674b681ba25897b37a7 Mon Sep 17 00:00:00 2001 From: Riccardo Montagnin Date: Tue, 20 Sep 2022 11:47:10 +0200 Subject: [PATCH] build: use golangci-lint CLI to lint files (#80) This PR updates the linting process to use the `golangci-lint` CLI. This should guarantee major forward compatibility as the golangci-lint version is now tracked within the codebase along with other dependencies Depends-On: #79 - [x] Targeted PR against correct branch. - [ ] Linked to Github issue with discussion and accepted design OR link to spec that describes this work. - [ ] Wrote unit tests. - [x] Re-reviewed `Files changed` in the Github PR explorer. --- .github/workflows/test.yml | 7 +++---- database/postgresql/postgresql.go | 11 ++++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d0c44fb7..8a4cef77 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -14,7 +14,7 @@ jobs: - uses: rokroskar/workflow-run-cleanup-action@master env: GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" - if: "!startsWith(github.ref, 'refs/tags/') && github.ref != 'refs/heads/main'" + if: "!startsWith(github.ref, 'refs/tags/') && !startsWith(github.ref, 'refs/tags/cosmos')" Unit-tests: runs-on: ubuntu-latest @@ -39,11 +39,10 @@ jobs: - name: Build ๐Ÿ”จ if: "env.GIT_DIFF != ''" - run: GOARCH=${{ matrix.go-arch }} LEDGER_ENABLED=false make build + run: make build - name: Test & Coverage report creation ๐Ÿงช - run: | - make install test-unit stop-docker-test + run: make test-unit stop-docker-test - name: Upload coverage ๐Ÿ“ค if: "env.GIT_DIFF != ''" diff --git a/database/postgresql/postgresql.go b/database/postgresql/postgresql.go index 0244dbe4..77d2c2ad 100644 --- a/database/postgresql/postgresql.go +++ b/database/postgresql/postgresql.go @@ -101,14 +101,15 @@ func (db *Database) GetLastBlockHeight() (int64, error) { stmt := `SELECT height FROM block ORDER BY height DESC LIMIT 1;` var height int64 - if err := db.SQL.QueryRow(stmt).Scan(&height); err != nil { + err := db.SQL.QueryRow(stmt).Scan(&height) + if err != nil { + if strings.Contains(err.Error(), "no rows in result set") { + // If no rows stored in block table, return 0 as height + return 0, nil + } return 0, fmt.Errorf("error while getting last block height, error: %s", err) } - if height == 0 { - return 0, fmt.Errorf("cannot get block height, no blocks saved") - } - return height, nil }