Skip to content

Commit

Permalink
Merge branch 'main' into chain-config-per-node
Browse files Browse the repository at this point in the history
  • Loading branch information
felipemadero committed Dec 20, 2022
2 parents f387b9c + a6fa34a commit d986e5c
Show file tree
Hide file tree
Showing 24 changed files with 511 additions and 346 deletions.
16 changes: 10 additions & 6 deletions .github/workflows/build-test-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,17 @@ jobs:
env:
GITHUB_ACCESS_TOKEN: ${{ secrets.SNOWBOT_PAT }}
run: git config --global url."https://${GITHUB_ACCESS_TOKEN}@github.com/ava-labs/avalanchego-operator".insteadOf "https://github.com/ava-labs/avalanchego-operator"
- uses: actions/checkout@v2
- name: golangci-lint
uses: golangci/golangci-lint-action@v2
- name: Checkout
uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v3
with:
version: "v1.47.0"
working-directory: .
args: --timeout 3m
go-version: '1.18'
check-latest: true
- name: Run static analysis tests
shell: bash
run: scripts/lint.sh

unit_test:
name: Unit tests
runs-on: ubuntu-latest
Expand Down
120 changes: 110 additions & 10 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,113 @@
# ref. https://golangci-lint.run/usage/configuration/
# https://golangci-lint.run/usage/configuration/
run:
timeout: 5m
tests: false
skip-dirs:
- api/mocks
- local/mocks
- rpcpb
go: "1.18"
timeout: 10m
# skip auto-generated files.
skip-files:
- ".*\\.pb\\.go$"
- ".*mock.*"

issues:
# Maximum count of issues with the same text. Set to 0 to disable. Default is 3.
max-same-issues: 0

linters:
disable:
- typecheck
# please, do not use `enable-all`: it's deprecated and will be removed soon.
# inverted configuration with `enable-all` and `disable` is not scalable during updates of golangci-lint
disable-all: true
enable:
- asciicheck
- depguard
- errcheck
- errorlint
- exportloopref
- goconst
- gocritic
- gofmt
- gofumpt
- goimports
- revive
- gosec
- gosimple
- govet
- ineffassign
- misspell
- nakedret
- nolintlint
- prealloc
- stylecheck
- unconvert
- unparam
- unused
- unconvert
- whitespace
- staticcheck
# - bodyclose
# - structcheck
# - lll
# - gomnd
# - goprintffuncname
# - interfacer
# - typecheck
# - goerr113
# - noctx

linters-settings:
errorlint:
# Check for plain type assertions and type switches.
asserts: false
# Check for plain error comparisons.
comparison: false
revive:
rules:
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#bool-literal-in-expr
- name: bool-literal-in-expr
disabled: false
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#early-return
- name: early-return
disabled: false
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#empty-lines
- name: empty-lines
disabled: false
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#struct-tag
- name: struct-tag
disabled: false
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#unexported-naming
- name: unexported-naming
disabled: false
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#unhandled-error
- name: unhandled-error
disabled: false
arguments:
- "fmt.Fprint"
- "fmt.Fprintf"
- "fmt.Print"
- "fmt.Printf"
- "fmt.Println"
- "rand.Read"
- "sb.WriteString"
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#unused-parameter
- name: unused-parameter
disabled: false
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#unused-receiver
- name: unused-receiver
disabled: false
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#useless-break
- name: useless-break
disabled: false
staticcheck:
go: "1.18"
# https://staticcheck.io/docs/options#checks
checks:
- "all"
- "-SA6002" # argument should be pointer-like to avoid allocation, for sync.Pool
- "-SA1019" # deprecated packages e.g., golang.org/x/crypto/ripemd160
# https://golangci-lint.run/usage/linters#gosec
gosec:
excludes:
- G107 # https://securego.io/docs/rules/g107.html
depguard:
list-type: blacklist
packages-with-error-message:
- io/ioutil: 'io/ioutil is deprecated. Use package io or os instead.'
- github.com/stretchr/testify/assert: 'github.com/stretchr/testify/require should be used instead.'
include-go-root: true
2 changes: 1 addition & 1 deletion api/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
)

// Issues API calls to a node
// TODO: byzantine api. check if appropiate. improve implementation.
// TODO: byzantine api. check if appropriate. improve implementation.
type Client interface {
PChainAPI() platformvm.Client
XChainAPI() avm.Client
Expand Down
40 changes: 20 additions & 20 deletions cmd/control/control.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ func newStartCommand() *cobra.Command {
return cmd
}

func startFunc(cmd *cobra.Command, args []string) error {
func startFunc(*cobra.Command, []string) error {
cli, err := newClient()
if err != nil {
return err
Expand All @@ -218,7 +218,7 @@ func startFunc(cmd *cobra.Command, args []string) error {
// validate it's valid JSON
var js json.RawMessage
if err := json.Unmarshal([]byte(globalNodeConfig), &js); err != nil {
return fmt.Errorf("failed to validate JSON for provided config file: %s", err)
return fmt.Errorf("failed to validate JSON for provided config file: %w", err)
}
opts = append(opts, client.WithGlobalNodeConfig(globalNodeConfig))
}
Expand Down Expand Up @@ -286,7 +286,7 @@ func newCreateBlockchainsCommand() *cobra.Command {
return cmd
}

func createBlockchainsFunc(cmd *cobra.Command, args []string) error {
func createBlockchainsFunc(_ *cobra.Command, args []string) error {
cli, err := newClient()
if err != nil {
return err
Expand Down Expand Up @@ -330,7 +330,7 @@ func newCreateSubnetsCommand() *cobra.Command {
return cmd
}

func createSubnetsFunc(cmd *cobra.Command, args []string) error {
func createSubnetsFunc(*cobra.Command, []string) error {
cli, err := newClient()
if err != nil {
return err
Expand Down Expand Up @@ -365,7 +365,7 @@ func newHealthCommand() *cobra.Command {
return cmd
}

func healthFunc(cmd *cobra.Command, args []string) error {
func healthFunc(*cobra.Command, []string) error {
cli, err := newClient()
if err != nil {
return err
Expand Down Expand Up @@ -393,7 +393,7 @@ func newURIsCommand() *cobra.Command {
return cmd
}

func urisFunc(cmd *cobra.Command, args []string) error {
func urisFunc(*cobra.Command, []string) error {
cli, err := newClient()
if err != nil {
return err
Expand Down Expand Up @@ -421,7 +421,7 @@ func newStatusCommand() *cobra.Command {
return cmd
}

func statusFunc(cmd *cobra.Command, args []string) error {
func statusFunc(*cobra.Command, []string) error {
cli, err := newClient()
if err != nil {
return err
Expand Down Expand Up @@ -457,7 +457,7 @@ func newStreamStatusCommand() *cobra.Command {
return cmd
}

func streamStatusFunc(cmd *cobra.Command, args []string) error {
func streamStatusFunc(*cobra.Command, []string) error {
cli, err := newClient()
if err != nil {
return err
Expand Down Expand Up @@ -502,7 +502,7 @@ func newRemoveNodeCommand() *cobra.Command {
return cmd
}

func removeNodeFunc(cmd *cobra.Command, args []string) error {
func removeNodeFunc(_ *cobra.Command, args []string) error {
// no validation for empty string required, as covered by `cobra.ExactArgs`
nodeName := args[0]
cli, err := newClient()
Expand Down Expand Up @@ -562,7 +562,7 @@ func newAddNodeCommand() *cobra.Command {
return cmd
}

func addNodeFunc(cmd *cobra.Command, args []string) error {
func addNodeFunc(_ *cobra.Command, args []string) error {
// no validation for empty string required, as covered by `cobra.ExactArgs`
nodeName := args[0]
cli, err := newClient()
Expand All @@ -578,7 +578,7 @@ func addNodeFunc(cmd *cobra.Command, args []string) error {
// validate it's valid JSON
var js json.RawMessage
if err := json.Unmarshal([]byte(addNodeConfig), &js); err != nil {
return fmt.Errorf("failed to validate JSON for provided config file: %s", err)
return fmt.Errorf("failed to validate JSON for provided config file: %w", err)
}
opts = append(opts, client.WithGlobalNodeConfig(addNodeConfig))
}
Expand Down Expand Up @@ -661,7 +661,7 @@ func newRestartNodeCommand() *cobra.Command {
return cmd
}

func restartNodeFunc(cmd *cobra.Command, args []string) error {
func restartNodeFunc(_ *cobra.Command, args []string) error {
// no validation for empty string required, as covered by `cobra.ExactArgs`
nodeName := args[0]
cli, err := newClient()
Expand Down Expand Up @@ -722,7 +722,7 @@ func newAttachPeerCommand() *cobra.Command {
return cmd
}

func attachPeerFunc(cmd *cobra.Command, args []string) error {
func attachPeerFunc(_ *cobra.Command, args []string) error {
// no validation for empty string required, as covered by `cobra.ExactArgs`
nodeName := args[0]
cli, err := newClient()
Expand Down Expand Up @@ -786,7 +786,7 @@ func newSendOutboundMessageCommand() *cobra.Command {
return cmd
}

func sendOutboundMessageFunc(cmd *cobra.Command, args []string) error {
func sendOutboundMessageFunc(_ *cobra.Command, args []string) error {
// no validation for empty string required, as covered by `cobra.ExactArgs`
nodeName := args[0]
cli, err := newClient()
Expand Down Expand Up @@ -821,7 +821,7 @@ func newStopCommand() *cobra.Command {
return cmd
}

func stopFunc(cmd *cobra.Command, args []string) error {
func stopFunc(*cobra.Command, []string) error {
cli, err := newClient()
if err != nil {
return err
Expand Down Expand Up @@ -849,7 +849,7 @@ func newSaveSnapshotCommand() *cobra.Command {
return cmd
}

func saveSnapshotFunc(cmd *cobra.Command, args []string) error {
func saveSnapshotFunc(_ *cobra.Command, args []string) error {
cli, err := newClient()
if err != nil {
return err
Expand Down Expand Up @@ -925,7 +925,7 @@ func newLoadSnapshotCommand() *cobra.Command {
return cmd
}

func loadSnapshotFunc(cmd *cobra.Command, args []string) error {
func loadSnapshotFunc(_ *cobra.Command, args []string) error {
cli, err := newClient()
if err != nil {
return err
Expand Down Expand Up @@ -967,7 +967,7 @@ func loadSnapshotFunc(cmd *cobra.Command, args []string) error {
// validate it's valid JSON
var js json.RawMessage
if err := json.Unmarshal([]byte(globalNodeConfig), &js); err != nil {
return fmt.Errorf("failed to validate JSON for provided config file: %s", err)
return fmt.Errorf("failed to validate JSON for provided config file: %w", err)
}
opts = append(opts, client.WithGlobalNodeConfig(globalNodeConfig))
}
Expand All @@ -993,7 +993,7 @@ func newRemoveSnapshotCommand() *cobra.Command {
return cmd
}

func removeSnapshotFunc(cmd *cobra.Command, args []string) error {
func removeSnapshotFunc(_ *cobra.Command, args []string) error {
cli, err := newClient()
if err != nil {
return err
Expand All @@ -1020,7 +1020,7 @@ func newGetSnapshotNamesCommand() *cobra.Command {
}
}

func getSnapshotNamesFunc(cmd *cobra.Command, args []string) error {
func getSnapshotNamesFunc(*cobra.Command, []string) error {
cli, err := newClient()
if err != nil {
return err
Expand Down
2 changes: 1 addition & 1 deletion cmd/ping/ping.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func NewCommand() *cobra.Command {
return cmd
}

func pingFunc(cmd *cobra.Command, args []string) error {
func pingFunc(*cobra.Command, []string) error {
lvl, err := logging.ToLevel(logLevel)
if err != nil {
return err
Expand Down
2 changes: 1 addition & 1 deletion cmd/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func NewCommand() *cobra.Command {
return cmd
}

func serverFunc(cmd *cobra.Command, args []string) (err error) {
func serverFunc(*cobra.Command, []string) (err error) {
if logDir == "" {
logDir, err = os.MkdirTemp("", fmt.Sprintf("anr-server-logs-%d", time.Now().Unix()))
if err != nil {
Expand Down
Loading

0 comments on commit d986e5c

Please sign in to comment.