|
|
@@ -58,7 +58,6 @@ import (
|
|
|
"strings"
|
|
|
"time"
|
|
|
|
|
|
- "github.com/ethereum/go-ethereum/common/hexutil"
|
|
|
"github.com/ethereum/go-ethereum/internal/build"
|
|
|
"github.com/ethereum/go-ethereum/params"
|
|
|
)
|
|
|
@@ -331,7 +330,7 @@ func doTest(cmdline []string) {
|
|
|
// Test a single package at a time. CI builders are slow
|
|
|
// and some tests run into timeouts under load.
|
|
|
gotest := goTool("test", buildFlags(env)...)
|
|
|
- gotest.Args = append(gotest.Args, "-p", "1", "-timeout", "5m", "--short")
|
|
|
+ gotest.Args = append(gotest.Args, "-p", "1", "-timeout", "5m")
|
|
|
if *coverage {
|
|
|
gotest.Args = append(gotest.Args, "-covermode=atomic", "-cover")
|
|
|
}
|
|
|
@@ -340,39 +339,38 @@ func doTest(cmdline []string) {
|
|
|
build.MustRun(gotest)
|
|
|
}
|
|
|
|
|
|
-// runs gometalinter on requested packages
|
|
|
+// doLint runs golangci-lint on requested packages.
|
|
|
func doLint(cmdline []string) {
|
|
|
+ var (
|
|
|
+ cachedir = flag.String("cachedir", "./build/cache", "directory for caching golangci-lint binary.")
|
|
|
+ )
|
|
|
flag.CommandLine.Parse(cmdline)
|
|
|
-
|
|
|
packages := []string{"./..."}
|
|
|
if len(flag.CommandLine.Args()) > 0 {
|
|
|
packages = flag.CommandLine.Args()
|
|
|
}
|
|
|
- // Get metalinter and install all supported linters
|
|
|
- build.MustRun(goTool("get", "gopkg.in/alecthomas/gometalinter.v2"))
|
|
|
- build.MustRunCommand(filepath.Join(GOBIN, "gometalinter.v2"), "--install")
|
|
|
-
|
|
|
- // Run fast linters batched together
|
|
|
- configs := []string{
|
|
|
- "--vendor",
|
|
|
- "--tests",
|
|
|
- "--deadline=2m",
|
|
|
- "--disable-all",
|
|
|
- "--enable=goimports",
|
|
|
- "--enable=varcheck",
|
|
|
- "--enable=vet",
|
|
|
- "--enable=gofmt",
|
|
|
- "--enable=misspell",
|
|
|
- "--enable=goconst",
|
|
|
- "--min-occurrences=6", // for goconst
|
|
|
- }
|
|
|
- build.MustRunCommand(filepath.Join(GOBIN, "gometalinter.v2"), append(configs, packages...)...)
|
|
|
-
|
|
|
- // Run slow linters one by one
|
|
|
- for _, linter := range []string{"unconvert", "gosimple"} {
|
|
|
- configs = []string{"--vendor", "--tests", "--deadline=10m", "--disable-all", "--enable=" + linter}
|
|
|
- build.MustRunCommand(filepath.Join(GOBIN, "gometalinter.v2"), append(configs, packages...)...)
|
|
|
+
|
|
|
+ linter := downloadLinter(*cachedir)
|
|
|
+ lflags := []string{"run", "--config", ".golangci.yml"}
|
|
|
+ build.MustRunCommand(linter, append(lflags, packages...)...)
|
|
|
+ fmt.Println("You have achieved perfection.")
|
|
|
+}
|
|
|
+
|
|
|
+// downloadLinter downloads and unpacks golangci-lint.
|
|
|
+func downloadLinter(cachedir string) string {
|
|
|
+ const version = "1.21.0"
|
|
|
+
|
|
|
+ csdb := build.MustLoadChecksums("build/checksums.txt")
|
|
|
+ base := fmt.Sprintf("golangci-lint-%s-%s-%s", version, runtime.GOOS, runtime.GOARCH)
|
|
|
+ url := fmt.Sprintf("https://github.com/golangci/golangci-lint/releases/download/v%s/%s.tar.gz", version, base)
|
|
|
+ archivePath := filepath.Join(cachedir, base+".tar.gz")
|
|
|
+ if err := csdb.DownloadFile(url, archivePath); err != nil {
|
|
|
+ log.Fatal(err)
|
|
|
+ }
|
|
|
+ if err := build.ExtractTarballArchive(archivePath, cachedir); err != nil {
|
|
|
+ log.Fatal(err)
|
|
|
}
|
|
|
+ return filepath.Join(cachedir, base, "golangci-lint")
|
|
|
}
|
|
|
|
|
|
// Release Packaging
|
|
|
@@ -476,8 +474,7 @@ func maybeSkipArchive(env build.Environment) {
|
|
|
func doDebianSource(cmdline []string) {
|
|
|
var (
|
|
|
goversion = flag.String("goversion", "", `Go version to build with (will be included in the source package)`)
|
|
|
- gobundle = flag.String("gobundle", "/tmp/go.tar.gz", `Filesystem path to cache the downloaded Go bundles at`)
|
|
|
- gohash = flag.String("gohash", "", `SHA256 checksum of the Go sources requested to build with`)
|
|
|
+ cachedir = flag.String("cachedir", "./build/cache", `Filesystem path to cache the downloaded Go bundles at`)
|
|
|
signer = flag.String("signer", "", `Signing key name, also used as package author`)
|
|
|
upload = flag.String("upload", "", `Where to upload the source package (usually "ethereum/ethereum")`)
|
|
|
sshUser = flag.String("sftp-user", "", `Username for SFTP upload (usually "geth-ci")`)
|
|
|
@@ -495,24 +492,25 @@ func doDebianSource(cmdline []string) {
|
|
|
gpg.Stdin = bytes.NewReader(key)
|
|
|
build.MustRun(gpg)
|
|
|
}
|
|
|
- // Download and verify the Go source package
|
|
|
- if err := build.EnsureGoSources(*goversion, hexutil.MustDecode("0x"+*gohash), *gobundle); err != nil {
|
|
|
- log.Fatalf("Failed to ensure Go source package: %v", err)
|
|
|
- }
|
|
|
- // Create Debian packages and upload them
|
|
|
+
|
|
|
+ // Download and verify the Go source package.
|
|
|
+ gobundle := downloadGoSources(*goversion, *cachedir)
|
|
|
+
|
|
|
+ // Create Debian packages and upload them.
|
|
|
for _, pkg := range debPackages {
|
|
|
for distro, goboot := range debDistroGoBoots {
|
|
|
- // Prepare the debian package with the go-ethereum sources
|
|
|
+ // Prepare the debian package with the go-ethereum sources.
|
|
|
meta := newDebMetadata(distro, goboot, *signer, env, now, pkg.Name, pkg.Version, pkg.Executables)
|
|
|
pkgdir := stageDebianSource(*workdir, meta)
|
|
|
|
|
|
- // Ship the Go sources along so we have a proper thing to build with
|
|
|
- if err := build.ExtractTarballArchive(*gobundle, pkgdir); err != nil {
|
|
|
+ // Add Go source code.
|
|
|
+ if err := build.ExtractTarballArchive(gobundle, pkgdir); err != nil {
|
|
|
log.Fatalf("Failed to extract Go sources: %v", err)
|
|
|
}
|
|
|
if err := os.Rename(filepath.Join(pkgdir, "go"), filepath.Join(pkgdir, ".go")); err != nil {
|
|
|
log.Fatalf("Failed to rename Go source folder: %v", err)
|
|
|
}
|
|
|
+
|
|
|
// Run the packaging and upload to the PPA
|
|
|
debuild := exec.Command("debuild", "-S", "-sa", "-us", "-uc", "-d", "-Zxz")
|
|
|
debuild.Dir = pkgdir
|
|
|
@@ -534,6 +532,17 @@ func doDebianSource(cmdline []string) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+func downloadGoSources(version string, cachedir string) string {
|
|
|
+ csdb := build.MustLoadChecksums("build/checksums.txt")
|
|
|
+ file := fmt.Sprintf("go%s.src.tar.gz", version)
|
|
|
+ url := "https://dl.google.com/go/" + file
|
|
|
+ dst := filepath.Join(cachedir, file)
|
|
|
+ if err := csdb.DownloadFile(url, dst); err != nil {
|
|
|
+ log.Fatal(err)
|
|
|
+ }
|
|
|
+ return dst
|
|
|
+}
|
|
|
+
|
|
|
func ppaUpload(workdir, ppa, sshUser string, files []string) {
|
|
|
p := strings.Split(ppa, "/")
|
|
|
if len(p) != 2 {
|