Skip to content

Commit

Permalink
Modify code to depend on BSR
Browse files Browse the repository at this point in the history
  • Loading branch information
ProfMoo committed Apr 22, 2024
1 parent 19ae468 commit 2b70b03
Show file tree
Hide file tree
Showing 48 changed files with 398 additions and 12,322 deletions.
126 changes: 126 additions & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
# Options for analysis running.
run:
# Which dirs to skip: issues from them won't be reported.
# Can use regexp here: `generated.*`, regexp is applied on full path,
# including the path prefix if one is set.
# Default value is empty list,
# but default dirs are skipped independently of this option's value (see skip-dirs-use-default).
# "/" will be replaced by current OS file path separator to properly work on Windows.
skip-dirs:
- vendor
- gen

linters:
enable-all: true

# Disable specific linter
# https://golangci-lint.run/usage/linters/#disabled-by-default
disable:
- dupl
- lll
- interfacer
- exhaustivestruct
- nosnakecase
- scopelint
- ifshort
- golint
- deadcode
- varcheck
- structcheck
- maligned
- wrapcheck
- varnamelen
- funlen
- gomoddirectives
- gocognit
- testpackage
- paralleltest
- nestif
- cyclop
- maintidx
- gomnd
- gochecknoglobals
- gocritic
- godox
- forbidigo
- exhaustruct
- contextcheck
- ireturn
- goerr113
- depguard

linters-settings:
exhaustive:
# Program elements to check for exhaustiveness.
# Default: [ switch ]
check:
- switch
- map
godot:
# Comments to be checked: `declarations`, `toplevel`, or `all`.
# Default: declarations
scope: declarations
# Check that each sentence starts with a capital letter.
# Default: false
capital: true
misspell:
# Correct spellings using locale preferences for US or UK.
# Setting locale to US will correct the British spelling of 'colour' to 'color'.
# Default is to use a neutral variety of English.
locale: US
nolintlint:
# Enable to require an explanation of nonzero length after each nolint directive.
# Default: false
require-explanation: true
# Enable to require nolint directives to mention the specific linter being suppressed.
# Default: false
require-specific: true
predeclared:
# Include method names and field names (i.e., qualified names) in checks.
# Default: false
q: true
tagliatelle:
# Check the struct tag name case.
case:
# Use the struct field name to check the name of the struct tag.
# Default: false
use-field-name: true
# `camel` is used for `json` and `yaml`, and `header` is used for `header` (can be overridden)
# Default: {}
rules:
# Any struct tag type can be used.
# Support string case: `camel`, `pascal`, `kebab`, `snake`, `goCamel`, `goPascal`, `goKebab`, `goSnake`, `upper`, `lower`, `header`
json: camel
yaml: camel
xml: camel
bson: camel
avro: snake
mapstructure: kebab
gci:
# Section configuration to compare against.
# Section names are case-insensitive and may contain parameters in ().
# The default order of sections is `standard > default > custom > blank > dot`,
# If `custom-order` is `true`, it follows the order of `sections` option.
# Default: ["standard", "default"]
sections:
- standard # Standard section: captures all standard packages.
- default # Default section: contains all imports that could not be matched to another section type.
- prefix(go.mongodb.org)
- prefix(google.golang.org)
- prefix(gopkg.in)
- blank # Blank section: contains all blank imports. This section is not present unless explicitly enabled.
- dot # Dot section: contains all dot imports. This section is not present unless explicitly enabled.
# Skip generated files.
# Default: true
skip-generated: true
# Enable custom order of sections.
# If `true`, make the section order the same as the order of `sections`.
# Default: false
custom-order: true
gofumpt:
# Module path which contains the source code being formatted.
# Default: ""
module-path: github.com/coinbase/staking-client-library-go
# Choose whether to use the extra rules.
# Default: false
extra-rules: true
83 changes: 83 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
#
# Tool Prerequisites Check
# This ensures that you have the necessary executables installed to run this makefile.
#

BUILD_PREREQUISITES = git go buf protoc-gen-go protoc-gen-go-grpc protoc-gen-csf protoc-gen-grpc-gateway protoc-gen-go-aip mockery
VALIDATION_PREREQUISITES = golangci-lint

#
# Informational Targets
# These rarely change, and only serve to print out helpful details about this makefile.
#

.PHONY: usage
usage:
@ echo "Usage: make [`cat Makefile | grep "^[A-z\%\-]*:" | awk '{print $$1}' | sed "s/://g" | sed "s/%/[1-3]/g" | xargs`]"

#
# Functional Targets
# These serve specific purposes for the build/release of this client.
#

.PHONY: install_prerequisites
install_prerequisites: # Install build prerequisites
@ scripts/install-go-tools.sh
@ scripts/install-go-validation-tools.sh

.PHONY: clean
clean:
@ rm -rf gen/*
@ rm -rf docs/openapi/*

.PHONY: build_deps
build_deps:
@ printf $(foreach exec,$(BUILD_PREREQUISITES), \
$(if $(shell which $(exec)),"", \
$(error "No $(exec) in PATH. Prerequisites are: $(BUILD_PREREQUISITES)")))

.PHONY: validation_deps
validation_deps:
@ printf $(foreach exec,$(VALIDATION_PREREQUISITES), \
$(if $(shell which $(exec)),"", \
$(error "No $(exec) in PATH. Prerequisites are: $(VALIDATION_PREREQUISITES)")))

.PHONY: buf_gen
buf_gen:
# @ buf generate --template protos/buf.gen.orchestration.yaml buf.build/cdp/rewards --path coinbase/staking/orchestration/v1
@ buf generate --template protos/buf.gen.rewards.yaml buf.build/cdp/rewards --path coinbase/staking/rewards/v1

# We don't need internal snippets and test files generated by gapic plugin.
# w.r.t the internal/snippets folder, gapic provides an option to supply an option to omit generating them here:
# https://github.com/googleapis/gapic-generator-go?tab=readme-ov-file#invocation
# but unfortunately, the option doesn't work and is likely to be removed, per this issue:
# https://github.com/googleapis/gapic-generator-go/issues/1332
@ rm -rf gen/client/coinbase/staking/orchestration/v1/internal
@ rm -rf gen/client/coinbase/staking/rewards/v1/internal
@ rm -rf gen/client/coinbase/staking/orchestration/v1/*test.go
@ rm -rf gen/client/coinbase/staking/rewards/v1/*test.go

.PHONY: gen
gen: install_prerequisites build_deps clean buf_gen

.PHONY: build
build:
@ go build -o bin/cosmos_list_rewards examples/cosmos/list-rewards/main.go
@ go build -o bin/ethereum/create_and_process_workflow examples/ethereum/create-and-process-workflow/main.go
@ go build -o bin/ethereum/create_workflow examples/ethereum/create-workflow/main.go
@ go build -o bin/ethereum/list_rewards examples/ethereum/list-rewards/main.go
@ go build -o bin/ethereum/list_stakes examples/ethereum/list-stakes/main.go
@ go build -o bin/example examples/hello-world/main.go
@ go build -o bin/list_workflows examples/list-workflows/main.go
@ go build -o bin/solana/solana_list_rewards examples/solana/list-rewards/main.go
@ go build -o bin/solana/solana_create_workflow examples/solana/create-workflow/main.go

.PHONY: lint
lint: validation_deps
@ printf "\nLint App\n"
@ golangci-lint run --timeout 3m ./...

.PHONY: lintfix
lintfix: validation_deps
@ printf "\nFixing Lint Issues\n"
@ golangci-lint run --timeout 3m --fix ./...
Loading

0 comments on commit 2b70b03

Please sign in to comment.