Skip to content

Commit

Permalink
Merge pull request #48 from DefiantLabs/patch/golangci-lint-workflow-…
Browse files Browse the repository at this point in the history
…breakage

Remove golangcilint from precommit, setup separate github workflow fo…
  • Loading branch information
pharr117 authored Dec 27, 2023
2 parents a2fb016 + 5fa4861 commit 1006157
Show file tree
Hide file tree
Showing 8 changed files with 75 additions and 22 deletions.
55 changes: 55 additions & 0 deletions .github/workflows/golangci-lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: golangci-lint
on:
push:
branches:
- master
- main
pull_request:

permissions:
contents: read
# Optional: allow read access to pull request. Use with `only-new-issues` option.
# pull-requests: read

jobs:
golangci:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: '1.19'
cache: false
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
# Require: The version of golangci-lint to use.
# When `install-mode` is `binary` (default) the value can be v1.2 or v1.2.3 or `latest` to use the latest version.
# When `install-mode` is `goinstall` the value can be v1.2.3, `latest`, or the hash of a commit.
version: v1.55.2

# Optional: working directory, useful for monorepos
# working-directory: somedir

# Optional: golangci-lint command line arguments.
#
# Note: By default, the `.golangci.yml` file should be at the root of the repository.
# The location of the configuration file can be changed by using `--config=`
# args: --timeout=30m --config=/my/path/.golangci.yml --issues-exit-code=0

# Optional: show only new issues if it's a pull request. The default value is `false`.
# only-new-issues: true

# Optional: if set to true, then all caching functionality will be completely disabled,
# takes precedence over all other caching options.
# skip-cache: true

# Optional: if set to true, then the action won't cache or restore ~/go/pkg.
# skip-pkg-cache: true

# Optional: if set to true, then the action won't cache or restore ~/.cache/go-build.
# skip-build-cache: true

# Optional: The mode to install golangci-lint. It can be 'binary' or 'goinstall'.
# install-mode: "goinstall"
1 change: 0 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ run:
linters:
disable-all: true
enable:
- depguard
- dogsled
- exportloopref
- errcheck
Expand Down
2 changes: 0 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ repos:
# args: [-over=15]
- id: validate-toml
- id: no-go-testing
- id: golangci-lint
args: [--timeout,10m]
# - id: go-critic
# - id: go-unit-tests
- id: go-build
Expand Down
27 changes: 13 additions & 14 deletions core/block_enqueue.go
Original file line number Diff line number Diff line change
Expand Up @@ -310,24 +310,23 @@ func GenerateDefaultEnqueueFunction(db *gorm.DB, cfg config.IndexConfig, client
config.Log.Debugf("Block %d already indexed, skipping", currBlock)
currBlock++
continue
} else {
config.Log.Debugf("Block %d needs indexing, adding to queue", currBlock)
blockChan <- &EnqueueData{
Height: currBlock,
IndexBlockEvents: cfg.Base.BlockEventIndexingEnabled && !block.BlockEventsIndexed,
IndexTransactions: cfg.Base.TransactionIndexingEnabled && !block.TxIndexed,
}

delete(blocksInDB, currBlock)
}
config.Log.Debugf("Block %d needs indexing, adding to queue", currBlock)
blockChan <- &EnqueueData{
Height: currBlock,
IndexBlockEvents: cfg.Base.BlockEventIndexingEnabled && !block.BlockEventsIndexed,
IndexTransactions: cfg.Base.TransactionIndexingEnabled && !block.TxIndexed,
}

currBlock++
delete(blocksInDB, currBlock)

if cfg.Base.Throttling != 0 {
time.Sleep(time.Second * time.Duration(cfg.Base.Throttling))
}
currBlock++

continue
if cfg.Base.Throttling != 0 {
time.Sleep(time.Second * time.Duration(cfg.Base.Throttling))
}

continue
}

// Add the new block to the queue
Expand Down
2 changes: 1 addition & 1 deletion core/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ func ProcessTx(db *gorm.DB, tx txtypes.MergedTx) (txDBWapper dbTypes.TxDBWrapper
txTime, err = time.Parse(time.RFC3339, tx.TxResponse.TimeStamp)
if err != nil {
config.Log.Error("Error parsing tx timestamp.", err)
return
return txDBWapper, txTime, err
}

code := tx.TxResponse.Code
Expand Down
6 changes: 4 additions & 2 deletions db/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -528,15 +528,17 @@ func indexMessageEventAttributeKeys(db *gorm.DB, txs []TxDBWrapper) (map[string]

func UpsertDenoms(db *gorm.DB, denoms []DenomDBWrapper) error {
return db.Transaction(func(dbTransaction *gorm.DB) error {
for _, denom := range denoms {
for i := range denoms {
denom := denoms[i]
if err := dbTransaction.Clauses(clause.OnConflict{
Columns: []clause.Column{{Name: "base"}},
DoUpdates: clause.AssignmentColumns([]string{"symbol", "name"}),
}).Create(&denom.Denom).Error; err != nil {
return err
}

for _, denomUnit := range denom.DenomUnits {
for i := range denom.DenomUnits {
denomUnit := denom.DenomUnits[i]
denomUnit.DenomUnit.Denom = denom.Denom

if err := dbTransaction.Clauses(clause.OnConflict{
Expand Down
2 changes: 1 addition & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

The documentation found here is in-repo documentation intended for use in documenting and explaining workflows.

You may find more information in the [Cosmos Indexer Wiki](https://github.com/DefiantLabs/cosmos-indexer/wiki).
You may find more information in the [Cosmos Indexer Wiki](https://github.com/DefiantLabs/cosmos-indexer/wiki).
2 changes: 1 addition & 1 deletion docs/application-workflow/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ The parser worker is responsible for taking the raw, on-chain data from the RPC

## DB Worker

The database worker is responsible for inserting the parsed application types into the database. It is responsible for building up the data associations according to the data schema defined by the application.
The database worker is responsible for inserting the parsed application types into the database. It is responsible for building up the data associations according to the data schema defined by the application.

0 comments on commit 1006157

Please sign in to comment.