Skip to content

Commit

Permalink
Optimize checks & tests (#2056)
Browse files Browse the repository at this point in the history
  • Loading branch information
AstroProfundis authored Oct 13, 2022
1 parent 0d5530c commit d19f3a2
Show file tree
Hide file tree
Showing 107 changed files with 923 additions and 1,802 deletions.
1 change: 1 addition & 0 deletions .codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ coverage:
ignore:
- "pkg/cluster/api/dmpb"
- "pkg/cluster/api/typeutil"
- "pkg/telemetry/*.pb.go"

flags:
tiup:
Expand Down
5 changes: 2 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ check-static: tools/bin/golangci-lint
lint: tools/bin/revive
@# Target: run the lint checker revive
@echo "linting"
./tools/check/check-lint.sh
@tools/bin/revive -formatter friendly -config tools/check/revive.toml $(FILES)

vet:
Expand Down Expand Up @@ -159,5 +158,5 @@ tools/bin/revive: tools/check/go.mod
$(GO) build -o ../bin/revive github.com/mgechev/revive

tools/bin/golangci-lint:
@# Target: pull in specific version of golangci-lint (v1.42.1)
curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b ./tools/bin v1.49.0
@# Target: pull in specific version of golangci-lint (v1.50.0)
curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b ./tools/bin v1.50.0
5 changes: 2 additions & 3 deletions cmd/history.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,10 @@ func newHistoryCmd() *cobra.Command {
RunE: func(cmd *cobra.Command, args []string) error {
if len(args) > 0 {
r, err := strconv.Atoi(args[0])
if err == nil {
rows = r
} else {
if err != nil {
return fmt.Errorf("%s: numeric argument required", args[0])
}
rows = r
}

env := environment.GlobalEnv()
Expand Down
2 changes: 1 addition & 1 deletion cmd/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ func showComponentVersions(env *environment.Environment, component string, opt l
if opt.installedOnly {
comp, err = env.V1Repository().LocalComponentManifest(component, false)
} else {
comp, err = env.V1Repository().FetchComponentManifest(component, false)
comp, err = env.V1Repository().GetComponentManifest(component, false)
}
if err != nil {
return nil, errors.Annotate(err, "failed to fetch component")
Expand Down
22 changes: 10 additions & 12 deletions cmd/mirror.go
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ func newMirrorModifyCmd() *cobra.Command {
env := environment.GlobalEnv()

comp, ver := environment.ParseCompVersion(component)
m, err := env.V1Repository().FetchComponentManifest(comp, true)
m, err := env.V1Repository().GetComponentManifest(comp, true)
if err != nil {
return err
}
Expand Down Expand Up @@ -359,14 +359,13 @@ func newMirrorRenewCmd() *cobra.Command {
env := environment.GlobalEnv()

comp, _ := environment.ParseCompVersion(component)
m, err := env.V1Repository().FetchComponentManifest(comp, true)
m, err := env.V1Repository().GetComponentManifest(comp, true)
if err != nil {
// ignore manifest expiration error
if v1manifest.IsExpirationError(perrs.Cause(err)) {
fmt.Println(err)
} else {
if !v1manifest.IsExpirationError(perrs.Cause(err)) {
return err
}
fmt.Println(err)
}

if days > 0 {
Expand Down Expand Up @@ -417,7 +416,7 @@ func newTransferOwnerCmd() *cobra.Command {
return fmt.Errorf("new owner '%s' is not in the available owner list", newOwnerName)
}

m, err := env.V1Repository().FetchComponentManifest(component, true)
m, err := env.V1Repository().GetComponentManifest(component, true)
if err != nil {
return err
}
Expand Down Expand Up @@ -680,15 +679,14 @@ func doPublish(
) error {
env := environment.GlobalEnv()
env.V1Repository().PurgeTimestamp()
m, err := env.V1Repository().FetchComponentManifest(component, true)
m, err := env.V1Repository().GetComponentManifest(component, true)
if err != nil {
if perrs.Cause(err) == repository.ErrUnknownComponent {
fmt.Printf("Creating component %s\n", component)
publishInfo.Stand = &standalone
publishInfo.Hide = &hidden
} else {
if perrs.Cause(err) != repository.ErrUnknownComponent {
return err
}
fmt.Printf("Creating component %s\n", component)
publishInfo.Stand = &standalone
publishInfo.Hide = &hidden
} else if flagSet.Exist("standalone") || flagSet.Exist("hide") {
fmt.Println("This is not a new component, --standalone and --hide flag will be omitted")
}
Expand Down
1 change: 0 additions & 1 deletion components/client/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ check-static:
lint:
@# Target: run the lint checker revive
@echo "linting"
../../tools/check/check-lint.sh
@../../tools/bin/revive -formatter friendly -config ../../tools/check/revive.toml $(FILES)

vet:
Expand Down
26 changes: 24 additions & 2 deletions components/client/go.mod
Original file line number Diff line number Diff line change
@@ -1,12 +1,34 @@
module github.com/tiup/components/client

go 1.16
go 1.18

require (
github.com/gizak/termui/v3 v3.1.0
github.com/shirou/gopsutil v3.21.11+incompatible
github.com/spf13/cobra v1.3.0
github.com/tklauser/go-sysconf v0.3.9 // indirect
github.com/xo/usql v0.9.5
)

require (
github.com/alecthomas/chroma v0.9.4 // indirect
github.com/dlclark/regexp2 v1.4.0 // indirect
github.com/go-ole/go-ole v1.2.6 // indirect
github.com/go-sql-driver/mysql v1.6.0 // indirect
github.com/gohxs/readline v0.0.0-20171011095936-a780388e6e7c // indirect
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/mattn/go-isatty v0.0.14 // indirect
github.com/mattn/go-runewidth v0.0.13 // indirect
github.com/mitchellh/go-wordwrap v0.0.0-20150314170334-ad45545899c7 // indirect
github.com/nathan-fiscaletti/consolesize-go v0.0.0-20210105204122-a87d9f614b9d // indirect
github.com/nsf/termbox-go v0.0.0-20190121233118-02980233997d // indirect
github.com/rivo/uniseg v0.2.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/tklauser/go-sysconf v0.3.9 // indirect
github.com/tklauser/numcpus v0.3.0 // indirect
github.com/xo/dburl v0.9.0 // indirect
github.com/xo/tblfmt v0.8.0 // indirect
github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778 // indirect
github.com/yusufpapurcu/wmi v1.2.2 // indirect
github.com/zaf/temp v0.0.0-20170209143821-94e385923345 // indirect
golang.org/x/sys v0.0.0-20211205182925-97ca703d548d // indirect
)
Loading

0 comments on commit d19f3a2

Please sign in to comment.