forked from cerc-io/laconicd-deprecated
5417b4bb54
* add travis file * update lint so it reports properly * disable circleci * separate test structure into Verify deps & Lint, Unit Tests, Race Tests, Integration Tests * fix path issue now evident on ci build err * fixed golangci version to latest stable * Upgrade ci lint to go script and avoid cache issues #268 * fix lint issues #268 * bump go version for travis build to match go.mod version recently updated with Cosmos SDK upgrade * add panic for err edge cases on os.Stat * increase timeout to 10m since its failing on jenkins * bump GOLANGCI_VERSION to 1.23.8 in order to try avoiding some weird errors on CI
74 lines
1.5 KiB
Go
Executable File
74 lines
1.5 KiB
Go
Executable File
// +build none
|
|
|
|
package main
|
|
|
|
import (
|
|
"flag"
|
|
"fmt"
|
|
"log"
|
|
"os"
|
|
"os/exec"
|
|
"path/filepath"
|
|
"runtime"
|
|
"strings"
|
|
)
|
|
|
|
const (
|
|
GOLANGCI_VERSION = "github.com/golangci/golangci-lint/cmd/golangci-lint@v1.23.8"
|
|
)
|
|
|
|
func main() {
|
|
|
|
log.SetFlags(log.Lshortfile)
|
|
|
|
if _, err := os.Stat(filepath.Join("scripts", "ci.go")); os.IsNotExist(err) {
|
|
log.Fatal("should run build from root dir")
|
|
} else if err != nil {
|
|
panic(err)
|
|
}
|
|
if len(os.Args) < 2 {
|
|
log.Fatal("cmd required, eg: install")
|
|
}
|
|
switch os.Args[1] {
|
|
case "lint":
|
|
lint()
|
|
default:
|
|
log.Fatal("cmd not found", os.Args[1])
|
|
}
|
|
}
|
|
|
|
func lint() {
|
|
|
|
verbose := flag.Bool("v", false, "Whether to log verbosely")
|
|
|
|
// Make sure golangci-lint is available
|
|
argsGet := append([]string{"get", GOLANGCI_VERSION})
|
|
cmd := exec.Command(filepath.Join(runtime.GOROOT(), "bin", "go"), argsGet...)
|
|
out, err := cmd.CombinedOutput()
|
|
if err != nil {
|
|
log.Fatalf("could not list packages: %v\n%s", err, string(out))
|
|
}
|
|
|
|
cmd = exec.Command(filepath.Join(GOBIN(), "golangci-lint"))
|
|
cmd.Args = append(cmd.Args, "run", "--config", ".golangci.yml")
|
|
|
|
if *verbose {
|
|
cmd.Args = append(cmd.Args, "-v")
|
|
}
|
|
|
|
fmt.Println("Lint Ethermint", strings.Join(cmd.Args, " \\\n"))
|
|
cmd.Stderr, cmd.Stdout = os.Stderr, os.Stdout
|
|
|
|
if err := cmd.Run(); err != nil {
|
|
log.Fatal("Error: Could not Lint Ethermint. ", "error: ", err, ", cmd: ", cmd)
|
|
}
|
|
}
|
|
|
|
// GOBIN returns the GOBIN environment variable
|
|
func GOBIN() string {
|
|
if os.Getenv("GOBIN") == "" {
|
|
log.Fatal("GOBIN is not set")
|
|
}
|
|
return os.Getenv("GOBIN")
|
|
}
|