Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat : add github actions lint workflow #35

Merged
merged 14 commits into from
Sep 17, 2024
36 changes: 36 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Lint
# Lint runs golangci-lint over the entire repository
# This workflow is run on every pull request and push to main
# The `golangci` will pass without running if no *.{go, mod, sum} files have been changed.

on:
pull_request:
push:
branches:
- main

permissions:
contents: read

concurrency:
group: ci-${{ github.ref }}-lint
cancel-in-progress: true

jobs:
golangci:
name: golangci-lint
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install Go
uses: actions/setup-go@v5
with:
go-version: "1.22"

- name: Run golangci-lint
uses: golangci/golangci-lint-action@v6
with:
version: v1.61.0
args: --timeout 20m0s
79 changes: 79 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
run:
tests: true
# timeout for analysis, e.g. 30s, 5m, default is 1m
timeout: 5m
sort-results: true
allow-parallel-runners: true

linters:
disable-all: true
enable:
# - depguard
- dogsled
# - copyloopvar
- goconst
- gocritic
- gci
- gofumpt
# - gosec
- gosimple
- govet
- ineffassign
- misspell
- nakedret
- nolintlint
- staticcheck
- revive
- stylecheck
- typecheck
- unconvert
- unused

issues:
exclude-rules:
- text: "Use of weak random number generator"
linters:
- gosec
- text: "ST1003:"
linters:
- stylecheck
# FIXME: Disabled until golangci-lint updates stylecheck with this fix:
# https://github.com/dominikh/go-tools/issues/389
- text: "ST1016:"
linters:
- stylecheck
- path: "migrations"
text: "SA1019:"
linters:
- staticcheck
- text: "previous case"
linters:
- typecheck
- text: "previous case"
linters:
- typecheck

max-issues-per-linter: 10000
max-same-issues: 10000

linters-settings:
misspell:
locale: US
gofumpt:
extra-rules: true
dogsled:
max-blank-identifiers: 3
maligned:
# print struct with more effective memory layout or not, false by default
suggest-new: true
nolintlint:
allow-unused: false
allow-leading-space: true
require-explanation: false
require-specific: false
gosimple:
checks: ["all"]

gocritic:
disabled-checks:
- regexpMust
24 changes: 14 additions & 10 deletions chainclient/broadcast_tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,15 @@ import (
"fmt"
"log"
"os"
"path/filepath"

cometrpc "github.com/cometbft/cometbft/rpc/client/http"
clitx "github.com/cosmos/cosmos-sdk/client/tx"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/vitwit/avail-da-module/types"

"path/filepath"

"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/crypto/keyring"
sdk "github.com/cosmos/cosmos-sdk/types"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
"github.com/vitwit/avail-da-module/types"
)

func GetBinPath() string {
Expand All @@ -33,11 +31,12 @@ func ExecuteTX(ctx sdk.Context, msg types.MsgUpdateBlobStatusRequest, cdc codec.
// homePath := "/home/vitwit/.availsdk"
homePath := GetBinPath()
key := os.Getenv("KEY")
fmt.Println("get key namee.........", key)
if key == "" { //TODO : remove this later
key = "alice"
}
keyName := key

if keyName == "" {
keyName = "alice"
}

rpcAddress := "http://localhost:26657"

// Create a keyring
Expand All @@ -47,8 +46,13 @@ func ExecuteTX(ctx sdk.Context, msg types.MsgUpdateBlobStatusRequest, cdc codec.
}

info, err := kr.Key(keyName)
if err != nil {
return err
}
valAddr, err := info.GetAddress()
fmt.Println("after address................", valAddr)
if err != nil {
return fmt.Errorf("error while getting account address : %w", err)
}

// Create an RPC client
rpcClient, err := cometrpc.NewWithTimeout(rpcAddress, "/websocket", 3)
Expand Down
10 changes: 0 additions & 10 deletions chainclient/client.go
Original file line number Diff line number Diff line change
@@ -1,21 +1,11 @@
package chainclient

import (
"bytes"

"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/tx"
)

const (
KeyringBackendTest = "test"
)

// ChainClient is client to interact with SPN.
type ChainClient struct {
factory tx.Factory
clientCtx client.Context
out *bytes.Buffer
Address string `json:"address"`
AddressPrefix string `json:"account_address_prefix"`
RPC string `json:"rpc"`
Expand Down
10 changes: 4 additions & 6 deletions chainclient/create_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,11 @@ import (
"github.com/cosmos/cosmos-sdk/crypto/keyring"
"github.com/cosmos/cosmos-sdk/std"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
"github.com/cosmos/cosmos-sdk/types/tx/signing"
authTx "github.com/cosmos/cosmos-sdk/x/auth/tx"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
"github.com/cosmos/go-bip39"

// "github.com/tendermint/starport/starport/pkg/xfilepath"

"github.com/cosmos/cosmos-sdk/types/module"
)

const (
Expand All @@ -31,7 +28,8 @@ const (
// var availdHomePath = xfilepath.JoinFromHome(xfilepath.Path("availsdk"))

func NewClientCtx(kr keyring.Keyring, c *cometrpc.HTTP, chainID string,
cdc codec.BinaryCodec, homepath string, fromAddress sdk.AccAddress) client.Context {
cdc codec.BinaryCodec, homepath string, fromAddress sdk.AccAddress,
) client.Context {
encodingConfig := MakeEncodingConfig()

broadcastMode := flags.BroadcastSync
Expand Down Expand Up @@ -106,7 +104,7 @@ func ImportMnemonic(keyName, mnemonic, hdPath string, c client.Context) (*keyrin
}

// AccountCreate creates an account by name and mnemonic (optional) in the keyring.
func AccountCreate(accountName, mnemonic, hdPath string, c client.Context) (*keyring.Record, error) {
func AccountCreate(accountName, mnemonic, _ string, c client.Context) (*keyring.Record, error) {
if mnemonic == "" {
entropySeed, err := bip39.NewEntropy(256)
if err != nil {
Expand Down
4 changes: 1 addition & 3 deletions client/cli/keys.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
package cli

import (
"github.com/spf13/cobra"

"github.com/cosmos/cosmos-sdk/client"

"github.com/spf13/cobra"
availblob "github.com/vitwit/avail-da-module"
)

Expand Down
6 changes: 3 additions & 3 deletions client/cli/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ func GetQueryCmd() *cobra.Command {
func GetLatestBlobStatusInfo() *cobra.Command {
cmd := &cobra.Command{
Use: "get-da-status",
Short: "Show what range of blocks are being submitted and thier status",
Long: `Show what range of blocks are being submitted and thier status,
Short: "Show what range of blocks are being submitted and their status",
Long: `Show what range of blocks are being submitted and their status,
`,
Example: "simd query cada get-da-status",
Args: cobra.ExactArgs(0),
RunE: func(cmd *cobra.Command, args []string) error {
RunE: func(cmd *cobra.Command, _ []string) error {
clientCtx, err := client.GetClientQueryContext(cmd)
if err != nil {
return err
Expand Down
6 changes: 2 additions & 4 deletions client/cli/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,17 @@ import (
"strconv"
"strings"

"github.com/spf13/cobra"

"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/client/tx"

"github.com/spf13/cobra"
availblob "github.com/vitwit/avail-da-module"
"github.com/vitwit/avail-da-module/keeper"
"github.com/vitwit/avail-da-module/types"
)

// NewTxCmd
func NewTxCmd(keeper *keeper.Keeper) *cobra.Command {
func NewTxCmd(_ *keeper.Keeper) *cobra.Command {
txCmd := &cobra.Command{
Use: availblob.ModuleName,
Short: availblob.ModuleName + " transaction subcommands",
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.22.5
replace (
cosmossdk.io/core => cosmossdk.io/core v0.11.0
// github.com/ChainSafe/go-schnorrkel => github.com/ChainSafe/go-schnorrkel v1.1.0
github.com/prometheus/common => github.com/prometheus/common v0.47.0
// github.com/prometheus/common => github.com/prometheus/common v0.47.0
github.com/spf13/viper => github.com/spf13/viper v1.17.0 // v1.18+ breaks app overrides
)

Expand Down Expand Up @@ -65,7 +65,7 @@ require (
github.com/cosmos/cosmos-db v1.0.2 // indirect
github.com/cosmos/go-bip39 v1.0.0
github.com/cosmos/gogogateway v1.2.0 // indirect
github.com/cosmos/iavl v1.1.2 // indirect
github.com/cosmos/iavl v1.1.4 // indirect
github.com/cosmos/ics23/go v0.10.0 // indirect
github.com/cosmos/ledger-cosmos-go v0.13.3 // indirect
github.com/danieljoos/wincred v1.1.2 // indirect
Expand Down
Loading
Loading