mirror of
https://github.com/Instadapp/trustwallet-assets.git
synced 2024-07-29 22:37:31 +00:00
Add reporter logic (#16019)
This commit is contained in:
parent
f4676e8830
commit
539b810734
2
.github/workflows/pr-ci.yml
vendored
2
.github/workflows/pr-ci.yml
vendored
|
@ -21,4 +21,4 @@ jobs:
|
|||
uses: actions/checkout@v2
|
||||
|
||||
- name: Run check (sanity only)
|
||||
run: go run ./cmd/main.go -c ./.github/assets.config.yaml
|
||||
run: go run ./cmd/main.go --config=./.github/assets.config.yaml --script=sanity-check
|
35
cmd/main.go
35
cmd/main.go
|
@ -2,18 +2,18 @@ package main
|
|||
|
||||
import (
|
||||
"flag"
|
||||
"os"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
|
||||
"github.com/trustwallet/assets-go-libs/pkg/file"
|
||||
"github.com/trustwallet/assets-go-libs/src/config"
|
||||
"github.com/trustwallet/assets-go-libs/src/processor"
|
||||
"github.com/trustwallet/assets-go-libs/src/reporter"
|
||||
"github.com/trustwallet/assets-go-libs/src/validator"
|
||||
)
|
||||
|
||||
var (
|
||||
configPath, root string
|
||||
configPath, root, script string
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
@ -24,23 +24,43 @@ func main() {
|
|||
log.WithError(err).Fatal("failed to load file structure")
|
||||
}
|
||||
|
||||
fileStorage := file.NewFileProvider()
|
||||
fileStorage := file.NewFileService()
|
||||
|
||||
validatorsService, err := validator.NewService(fileStorage)
|
||||
if err != nil {
|
||||
log.WithError(err).Fatal("failed to init validator service")
|
||||
}
|
||||
|
||||
assetfsProcessor := processor.NewService(fileStorage, validatorsService)
|
||||
err = assetfsProcessor.RunSanityCheck(paths)
|
||||
reportService := reporter.NewReportService()
|
||||
|
||||
assetfsProcessor := processor.NewService(fileStorage, validatorsService, reportService)
|
||||
|
||||
switch script {
|
||||
case "sanity-check":
|
||||
err = assetfsProcessor.RunSanityCheck(paths)
|
||||
default:
|
||||
log.Error("Nothing to launch. Use --script flag to choose a script to run.")
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
log.WithError(err).Error()
|
||||
}
|
||||
|
||||
reports := reportService.GetReports()
|
||||
for key, report := range reports {
|
||||
log.WithFields(log.Fields{
|
||||
"total_files": report.TotalFiles,
|
||||
"errors": report.Errors,
|
||||
"warnings": report.Warnings,
|
||||
"fixed": report.Fixed,
|
||||
}).Info(key)
|
||||
}
|
||||
}
|
||||
|
||||
func setup() {
|
||||
flag.StringVar(&configPath, "c", "", "path to config file")
|
||||
flag.StringVar(&root, "r", "./", "path to the root of the dir")
|
||||
flag.StringVar(&configPath, "config", "", "path to config file")
|
||||
flag.StringVar(&root, "root", "./", "path to the root of the dir")
|
||||
flag.StringVar(&script, "script", "", "script type to run")
|
||||
flag.Parse()
|
||||
|
||||
if err := config.SetConfig(configPath); err != nil {
|
||||
|
@ -53,5 +73,4 @@ func setup() {
|
|||
}
|
||||
|
||||
log.SetLevel(logLevel)
|
||||
log.SetOutput(os.Stdin)
|
||||
}
|
||||
|
|
4
go.mod
4
go.mod
|
@ -4,7 +4,7 @@ go 1.17
|
|||
|
||||
require (
|
||||
github.com/sirupsen/logrus v1.8.1
|
||||
github.com/trustwallet/assets-go-libs v0.0.3
|
||||
github.com/trustwallet/assets-go-libs v0.0.4
|
||||
)
|
||||
|
||||
require (
|
||||
|
@ -13,7 +13,6 @@ require (
|
|||
github.com/hashicorp/hcl v1.0.0 // indirect
|
||||
github.com/magiconair/properties v1.8.5 // indirect
|
||||
github.com/mitchellh/mapstructure v1.4.1 // indirect
|
||||
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646 // indirect
|
||||
github.com/pelletier/go-toml v1.9.3 // indirect
|
||||
github.com/spf13/afero v1.6.0 // indirect
|
||||
github.com/spf13/cast v1.3.1 // indirect
|
||||
|
@ -24,7 +23,6 @@ require (
|
|||
github.com/trustwallet/go-libs v0.2.17 // indirect
|
||||
github.com/trustwallet/go-primitives v0.0.11 // indirect
|
||||
golang.org/x/crypto v0.0.0-20210817164053-32db794688a5 // indirect
|
||||
golang.org/x/image v0.0.0-20190802002840-cff245a6509b // indirect
|
||||
golang.org/x/sys v0.0.0-20210816183151-1e6c022a8912 // indirect
|
||||
golang.org/x/text v0.3.5 // indirect
|
||||
gopkg.in/ini.v1 v1.62.0 // indirect
|
||||
|
|
31
go.sum
31
go.sum
|
@ -218,8 +218,6 @@ github.com/mitchellh/mapstructure v1.4.1/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RR
|
|||
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
|
||||
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
|
||||
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646 h1:zYyBkD/k9seD2A7fsi6Oo2LfFZAehjjQMERAvZLEDnQ=
|
||||
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646/go.mod h1:jpp1/29i3P1S/RLdc7JQKbRpFeM1dOBd8T9ki5s+AY8=
|
||||
github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A=
|
||||
github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU=
|
||||
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
||||
|
@ -272,30 +270,14 @@ github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5Cc
|
|||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s=
|
||||
github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw=
|
||||
github.com/trustwallet/assets-go-libs v0.0.0-20211122144736-3715146de5f7 h1:F7xbo8+s7dUtgxcS8fCZwXHKFSwiccy0jPexFIByEW4=
|
||||
github.com/trustwallet/assets-go-libs v0.0.0-20211122144736-3715146de5f7/go.mod h1:OmlsaD15wFyp9f5FFp3Imx157/0aU235xh37M5RwfFU=
|
||||
github.com/trustwallet/assets-go-libs v0.0.0-20211122151912-d9944954af5d h1:5Ckf6C8muRmDltbJICzU0rM+GLb892qDJAKgEjKRREY=
|
||||
github.com/trustwallet/assets-go-libs v0.0.0-20211122151912-d9944954af5d/go.mod h1:OmlsaD15wFyp9f5FFp3Imx157/0aU235xh37M5RwfFU=
|
||||
github.com/trustwallet/assets-go-libs v0.0.0-20211122152531-2021a6ba5581 h1:/5zl35+b3eCOJtgiPyraFm5PCTouqvj2G11PPTZD4Is=
|
||||
github.com/trustwallet/assets-go-libs v0.0.0-20211122152531-2021a6ba5581/go.mod h1:OmlsaD15wFyp9f5FFp3Imx157/0aU235xh37M5RwfFU=
|
||||
github.com/trustwallet/assets-go-libs v0.0.0-20211122153236-ce3ff3eb39c6 h1:t83hjMw/QMwGVeKb2vp+4WcZDVbM7Vi70hkXKBxf5pg=
|
||||
github.com/trustwallet/assets-go-libs v0.0.0-20211122153236-ce3ff3eb39c6/go.mod h1:OmlsaD15wFyp9f5FFp3Imx157/0aU235xh37M5RwfFU=
|
||||
github.com/trustwallet/assets-go-libs v0.0.0-20211122153729-08732cd91252 h1:umTNyyRoMSy9a86rG/xbMYggL0HgaG2ytRvvftb2f9c=
|
||||
github.com/trustwallet/assets-go-libs v0.0.0-20211122153729-08732cd91252/go.mod h1:OmlsaD15wFyp9f5FFp3Imx157/0aU235xh37M5RwfFU=
|
||||
github.com/trustwallet/assets-go-libs v0.0.0-20211122154202-c0c086123f50 h1:NMTvxpqZlmv4OFPz8ts756WthN13gXSzFtP1LaofqkA=
|
||||
github.com/trustwallet/assets-go-libs v0.0.0-20211122154202-c0c086123f50/go.mod h1:OmlsaD15wFyp9f5FFp3Imx157/0aU235xh37M5RwfFU=
|
||||
github.com/trustwallet/assets-go-libs v0.0.0-20211122154502-b3265ad61bb9 h1:FtfLuPyWLKYLyy6gQx/ZuuzvmkjWea2osqDUCYWrAQU=
|
||||
github.com/trustwallet/assets-go-libs v0.0.0-20211122154502-b3265ad61bb9/go.mod h1:OmlsaD15wFyp9f5FFp3Imx157/0aU235xh37M5RwfFU=
|
||||
github.com/trustwallet/assets-go-libs v0.0.0-20211122160126-065dc30b0b04 h1:BUD1I7upFOAQHw72wDH1KlU3trgoqVtQbBd73ArDZKI=
|
||||
github.com/trustwallet/assets-go-libs v0.0.0-20211122160126-065dc30b0b04/go.mod h1:OmlsaD15wFyp9f5FFp3Imx157/0aU235xh37M5RwfFU=
|
||||
github.com/trustwallet/assets-go-libs v0.0.0-20211122172214-198d5a6b394d h1:DRoVcAx1WKOdUQLU8n0Al7OkGpquyFLpwIOBHvP0x1g=
|
||||
github.com/trustwallet/assets-go-libs v0.0.0-20211122172214-198d5a6b394d/go.mod h1:OmlsaD15wFyp9f5FFp3Imx157/0aU235xh37M5RwfFU=
|
||||
github.com/trustwallet/assets-go-libs v0.0.0-20211122175542-6788742787d6 h1:qGQvqFKfMhUSMdCkAe1zEfBZ74cCwFhtTP37x+ZPAbI=
|
||||
github.com/trustwallet/assets-go-libs v0.0.0-20211122175542-6788742787d6/go.mod h1:OmlsaD15wFyp9f5FFp3Imx157/0aU235xh37M5RwfFU=
|
||||
github.com/trustwallet/assets-go-libs v0.0.0-20211122191504-cd8b2ad15652 h1:wHQTE+8snRGq6jHBwVTou0r+xv1YVAeExzeZ6Dq8cHE=
|
||||
github.com/trustwallet/assets-go-libs v0.0.0-20211122191504-cd8b2ad15652/go.mod h1:OmlsaD15wFyp9f5FFp3Imx157/0aU235xh37M5RwfFU=
|
||||
github.com/trustwallet/assets-go-libs v0.0.3 h1:cWldvxbxqma3Jel5eddx06UwLVrbA+pDcT5rSBV8faA=
|
||||
github.com/trustwallet/assets-go-libs v0.0.3/go.mod h1:0nQmM5unJu0GuWSFJrWgSyOi2uUGnYmjQ53SkKe7/qI=
|
||||
github.com/trustwallet/assets-go-libs v0.0.4-0.20211123131336-7a728bd0a73b h1:ONRJPDAbYBtYRuMk+g4cHWylS2PaATi4BQLQz6vkhN0=
|
||||
github.com/trustwallet/assets-go-libs v0.0.4-0.20211123131336-7a728bd0a73b/go.mod h1:0nQmM5unJu0GuWSFJrWgSyOi2uUGnYmjQ53SkKe7/qI=
|
||||
github.com/trustwallet/assets-go-libs v0.0.4-0.20211123131913-19f758c9d03d h1:jKbJVfGIV6p1jBV6XQT6WKOF0tQPJAMddaUVQnp2xLM=
|
||||
github.com/trustwallet/assets-go-libs v0.0.4-0.20211123131913-19f758c9d03d/go.mod h1:0nQmM5unJu0GuWSFJrWgSyOi2uUGnYmjQ53SkKe7/qI=
|
||||
github.com/trustwallet/assets-go-libs v0.0.4 h1:ElrlzLnB7n14463C65txV9ulQE3UWHnJtRoXRDQzDZU=
|
||||
github.com/trustwallet/assets-go-libs v0.0.4/go.mod h1:0nQmM5unJu0GuWSFJrWgSyOi2uUGnYmjQ53SkKe7/qI=
|
||||
github.com/trustwallet/go-libs v0.2.17 h1:l2zr5Ow19GTPnoWbhjExAhTbz7xLcYPXBa10EIgItjI=
|
||||
github.com/trustwallet/go-libs v0.2.17/go.mod h1:gBDrDkN5wOY+8kwlU6pnv3l/seGJy2qH1OpTKe7NnXA=
|
||||
github.com/trustwallet/go-primitives v0.0.11 h1:uVjm1IssSrur5MjnSbl+LerljnaU8pvgoBxq7krjNvI=
|
||||
|
@ -346,7 +328,6 @@ golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u0
|
|||
golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM=
|
||||
golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU=
|
||||
golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
|
||||
golang.org/x/image v0.0.0-20190802002840-cff245a6509b h1:+qEpEAPhDZ1o0x3tHzZTQDArnOixOzGD9HUJfcg0mb4=
|
||||
golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
|
||||
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
|
||||
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
|
||||
|
|
Loading…
Reference in New Issue
Block a user