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

Update assets manager client path #111

Merged
merged 3 commits into from
May 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 23 additions & 21 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
@@ -1,30 +1,32 @@
name: Check
name: CI

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
branches:
- main

env:
CI_GITHUB_TOKEN: ${{ secrets.CI_GITHUB_TOKEN }}

jobs:
check:
name: Check
unit-test:
name: Unit Tests
runs-on: ubuntu-latest
steps:
- name: Set up Go
uses: actions/setup-go@v2
- uses: actions/setup-go@v4
with:
go-version: 1.17
id: go

- name: Check out code
uses: actions/checkout@v2

- name: Get dependencies
run: go get -v -t -d ./...

- name: Unit Test
run: make test
go-version: "1.21"
- uses: actions/checkout@v3
- run: git config --global url.https://ci:[email protected]/.insteadOf https://github.com/
- run: make unit-tests

- name: Lint
run: make lint
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: git config --global url.https://ci:[email protected]/.insteadOf https://github.com/
- uses: golangci/golangci-lint-action@v3
with:
version: v1.55.2
args: --timeout=5m
263 changes: 188 additions & 75 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,102 +1,215 @@
service:
golangci-lint-version: 1.38.x

run:
tests: false
modules-download-mode: readonly

linters-settings:
cyclop:
max-complexity: 20
# the maximal average package complexity. If it's higher than 0.0 (float) the check is enabled (default 0.0)
package-average: 0.0
skip-tests: false
dogsled:
# checks assignments with too many blank identifiers; default is 2
max-blank-identifiers: 2
dupl:
threshold: 100
errcheck:
check-type-assertions: true
check-blank: true
check-type-assertions: false
check-blank: false
errorlint:
errorf: false
asserts: true
comparison: true
forbidigo:
# Forbid the following identifiers (identifiers are written using regexp):
forbid:
- ^print.*$
- 'fmt\.Print.*'
exclude_godoc_examples: true
funlen:
lines: 100
statements: 75
lines: 60
statements: 60
gocognit:
min-complexity: 35
goconst:
min-len: 3
min-occurrences: 3
ignore-tests: true
match-constant: true
numbers: false
min: 3
max: 3
ignore-calls: true
gocritic:
# Which checks should be disabled; can't be combined with 'enabled-checks'
disabled-checks:
- regexpMust
gocyclo:
min-complexity: 20
godot:
# comments to be checked: `declarations`, `toplevel`, or `all`
scope: all
capital: false
gofmt:
# simplify code: gofmt with `-s` option
simplify: true
gofumpt:
extra-rules: true
# Select the Go version to target
lang-version: "1.21"
extra-rules: false
goimports:
# put imports beginning with prefix after 3rd-party packages;
# it's a comma-separated list of prefixes
local-prefixes: github.com/trustwallet
gomnd:
settings:
mnd:
# the list of enabled checks, see https://github.com/tommy-muehle/go-mnd/#checks for description.
checks:
- argument
- case
- condition
- operation
- return
- assign
ignored-numbers: 10,1000
gomoddirectives:
replace-local: false
gosec:
# To select a subset of rules to run.
# Available rules: https://github.com/securego/gosec#available-rules
includes:
- G401
- G306
- G101
gosimple:
# Select the Go version to target
go: "1.21"
# https://staticcheck.io/docs/options#checks
checks: [ "all" ]
govet:
check-shadowing: true
enable-all: true
disable:
- fieldalignment
composites: false
ifshort:
# Maximum length of variable declaration measured in number of lines, after which linter won't suggest using short syntax.
# Has higher priority than max-decl-chars.
max-decl-lines: 1
# Maximum length of variable declaration measured in number of characters, after which linter won't suggest using short syntax.
max-decl-chars: 30
importas:
golibsGin: github:com/trustwallet/go-common/gin

lll:
# max line length
line-length: 120
tab-width: 1
misspell:
locale: US
nolintlint:
allow-unused: false
allow-leading-space: true
gci:
local-prefixes: github.com/trustwallet
unparam:
check-exported: true
# ignore-words:
revive:
# see https://github.com/mgechev/revive#available-rules for details.
ignore-generated-header: true
severity: warning
rules:
- name: indent-error-flow
severity: warning
- name: time-naming
severity: warn
- name: errorf
severity: warn
- name: blank-imports
sevetiry: warn
# The error return parameter should be last
- name: error-return
severity: error
# Redundant if when returning an error
- name: if-return
severity: warn
# Warns when there are heading or trailing newlines in a block
- name: empty-lines
severity: error
staticcheck:
# Select the Go version to target
go: "1.21"
# https://staticcheck.io/docs/options#checks
checks: [ "all" ]
stylecheck:
# Select the Go version to target
go: "1.21"
# https://staticcheck.io/docs/options#checks
checks: [ "all", "-ST1000", "-ST1003", "-ST1016", "-ST1020", "-ST1021", "-ST1022" ]
# https://staticcheck.io/docs/options#dot_import_whitelist
dot-import-whitelist:
- fmt
# https://staticcheck.io/docs/options#initialisms
initialisms: [ "ACL", "API", "ASCII", "CPU", "CSS", "DNS", "EOF", "GUID", "HTML", "HTTP", "HTTPS", "ID", "IP", "JSON", "QPS", "RAM", "RPC", "SLA", "SMTP", "SQL", "SSH", "TCP", "TLS", "TTL", "UDP", "UI", "GID", "UID", "UUID", "URI", "URL", "UTF8", "VM", "XML", "XMPP", "XSRF", "XSS" ]
# https://staticcheck.io/docs/options#http_status_code_whitelist
http-status-code-whitelist: [ "200", "400", "404", "500" ]
unused:
check-exported: true
errorlint:
errorf: true
gocyclo:
min-complexity: 25
wrapcheck:
ignorePackageGlobs:
- github.com/trustwallet/*
issues:
new: false
# Select the Go version to target
go: "1.21"
whitespace:
multi-if: true # Enforces newlines (or comments) after every multi-line if statement
multi-func: false # Enforces newlines (or comments) after every multi-line function signature
wsl:
# See https://github.com/bombsimon/wsl/blob/master/doc/configuration.md for
# documentation of available settings
allow-assign-and-anything: false
allow-assign-and-call: true
allow-cuddle-declarations: false
allow-multiline-assign: true
allow-separated-leading-comment: false
allow-trailing-comment: false
force-case-trailing-whitespace: 0
force-err-cuddling: false
force-short-decl-cuddling: false
strict-append: true

linters:
disable-all: true
enable:
- deadcode
- errcheck
- gosimple
- govet
- ineffassign
- staticcheck
- structcheck
- typecheck
- unused
- varcheck
- asciicheck
- bodyclose
# - deadcode
# - depguard
- dogsled
- dupl
- durationcheck
- errorlint
- exhaustive
- errcheck
- exportloopref
- forcetypeassert
- funlen
- gci
- gochecknoglobals
- gochecknoinits
- gocognit
- goconst
- gocritic
- gocyclo
# - goerr113
- gofmt
- gofumpt
- goimports
# - gomnd
- goprintffuncname
- gosec
- importas
- lll
- makezero
- gosimple
- ineffassign
- misspell
- nakedret
- nestif
- nilerr
- nlreturn
- nolintlint
- paralleltest
- prealloc
- predeclared
- revive
- noctx
- rowserrcheck
- sqlclosecheck
- stylecheck
- testpackage
- thelper
- tparallel
- staticcheck
# - structcheck
- typecheck
- unconvert
- unparam
- wastedassign
- unused
# - varcheck
- whitespace
# - wrapcheck
- asciicheck
- gocognit
- nestif
- testpackage

run:
timeout: 2m
issues-exit-code: 1
tests: false
skip-dirs:
- ide
- local
skip-dirs-use-default: true
modules-download-mode: readonly
allow-parallel-runners: false

output:
format: colored-line-number
print-issued-lines: true
print-linter-name: true
uniq-by-line: true
path-prefix: ""
sort-results: true
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ GOFMT_FILES?=$$(find . -name '*.go' | grep -v vendor)

all: fmt lint test

test:
unit-tests:
@echo " > Running unit tests"
GOBIN=$(GOBIN) go test -cover -race -coverprofile=coverage.txt -covermode=atomic -v ./...

Expand Down
11 changes: 9 additions & 2 deletions client/assets-manager/client.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package assetsmanager

import (
"context"
"time"

"github.com/trustwallet/go-common/client"

Check failure on line 7 in client/assets-manager/client.go

View workflow job for this annotation

GitHub Actions / Unit Tests

reading github.com/trustwallet/go-common/go.mod at revision v0.8.17: git ls-remote -q origin in /home/runner/go/pkg/mod/cache/vcs/8de4fa1822b94c62c5b139b04856a277a6fc932520c3540ba60d6c1d39e44dbb: exit status 128:
)

type Client struct {
Expand All @@ -17,13 +18,19 @@
}

func (c *Client) ValidateAssetInfo(req *AssetValidationReq) (result AssetValidationResp, err error) {
err = c.req.Post(&result, "/v1/validate/asset_info", req)
request := client.NewReqBuilder().
Method("POST").
PathStatic("/api/v1/validate/asset_info").
Body(req).
WriteTo(&result).Build()

_, err = c.req.Execute(context.Background(), request)

return result, err
}

func (c *Client) GetTagValues() (result TagValuesResp, err error) {
err = c.req.GetWithCache(&result, "/v1/values/tags", nil, time.Hour)
err = c.req.GetWithCache(&result, "/api/v1/values/tags", nil, time.Hour)

return result, err
}
2 changes: 1 addition & 1 deletion file/path.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ func (p Path) defineFileType(path string) (string, *regexp.Regexp) {
func ReadLocalFileStructure(root string, filesToSkip []string) ([]string, error) {
paths := []string{"./"}

err := filepath.Walk(root, func(path string, info os.FileInfo, err error) error {
err := filepath.Walk(root, func(path string, _ os.FileInfo, err error) error {
if err != nil {
return err
}
Expand Down
Loading
Loading