@@ -58,7 +58,6 @@ import (
58
58
"strings"
59
59
"time"
60
60
61
- "github.com/ethereum/go-ethereum/common/hexutil"
62
61
"github.com/ethereum/go-ethereum/internal/build"
63
62
"github.com/ethereum/go-ethereum/params"
64
63
)
@@ -331,7 +330,7 @@ func doTest(cmdline []string) {
331
330
// Test a single package at a time. CI builders are slow
332
331
// and some tests run into timeouts under load.
333
332
gotest := goTool ("test" , buildFlags (env )... )
334
- gotest .Args = append (gotest .Args , "-p" , "1" , "-timeout" , "5m" , "--short" )
333
+ gotest .Args = append (gotest .Args , "-p" , "1" , "-timeout" , "5m" )
335
334
if * coverage {
336
335
gotest .Args = append (gotest .Args , "-covermode=atomic" , "-cover" )
337
336
}
@@ -340,39 +339,38 @@ func doTest(cmdline []string) {
340
339
build .MustRun (gotest )
341
340
}
342
341
343
- // runs gometalinter on requested packages
342
+ // doLint runs golangci-lint on requested packages.
344
343
func doLint (cmdline []string ) {
344
+ var (
345
+ cachedir = flag .String ("cachedir" , "./build/cache" , "directory for caching golangci-lint binary." )
346
+ )
345
347
flag .CommandLine .Parse (cmdline )
346
-
347
348
packages := []string {"./..." }
348
349
if len (flag .CommandLine .Args ()) > 0 {
349
350
packages = flag .CommandLine .Args ()
350
351
}
351
- // Get metalinter and install all supported linters
352
- build .MustRun (goTool ("get" , "gopkg.in/alecthomas/gometalinter.v2" ))
353
- build .MustRunCommand (filepath .Join (GOBIN , "gometalinter.v2" ), "--install" )
354
-
355
- // Run fast linters batched together
356
- configs := []string {
357
- "--vendor" ,
358
- "--tests" ,
359
- "--deadline=2m" ,
360
- "--disable-all" ,
361
- "--enable=goimports" ,
362
- "--enable=varcheck" ,
363
- "--enable=vet" ,
364
- "--enable=gofmt" ,
365
- "--enable=misspell" ,
366
- "--enable=goconst" ,
367
- "--min-occurrences=6" , // for goconst
368
- }
369
- build .MustRunCommand (filepath .Join (GOBIN , "gometalinter.v2" ), append (configs , packages ... )... )
370
-
371
- // Run slow linters one by one
372
- for _ , linter := range []string {"unconvert" , "gosimple" } {
373
- configs = []string {"--vendor" , "--tests" , "--deadline=10m" , "--disable-all" , "--enable=" + linter }
374
- build .MustRunCommand (filepath .Join (GOBIN , "gometalinter.v2" ), append (configs , packages ... )... )
352
+
353
+ linter := downloadLinter (* cachedir )
354
+ lflags := []string {"run" , "--config" , ".golangci.yml" }
355
+ build .MustRunCommand (linter , append (lflags , packages ... )... )
356
+ fmt .Println ("You have achieved perfection." )
357
+ }
358
+
359
+ // downloadLinter downloads and unpacks golangci-lint.
360
+ func downloadLinter (cachedir string ) string {
361
+ const version = "1.21.0"
362
+
363
+ csdb := build .MustLoadChecksums ("build/checksums.txt" )
364
+ base := fmt .Sprintf ("golangci-lint-%s-%s-%s" , version , runtime .GOOS , runtime .GOARCH )
365
+ url := fmt .Sprintf ("https://github.com/golangci/golangci-lint/releases/download/v%s/%s.tar.gz" , version , base )
366
+ archivePath := filepath .Join (cachedir , base + ".tar.gz" )
367
+ if err := csdb .DownloadFile (url , archivePath ); err != nil {
368
+ log .Fatal (err )
369
+ }
370
+ if err := build .ExtractTarballArchive (archivePath , cachedir ); err != nil {
371
+ log .Fatal (err )
375
372
}
373
+ return filepath .Join (cachedir , base , "golangci-lint" )
376
374
}
377
375
378
376
// Release Packaging
@@ -476,8 +474,7 @@ func maybeSkipArchive(env build.Environment) {
476
474
func doDebianSource (cmdline []string ) {
477
475
var (
478
476
goversion = flag .String ("goversion" , "" , `Go version to build with (will be included in the source package)` )
479
- gobundle = flag .String ("gobundle" , "/tmp/go.tar.gz" , `Filesystem path to cache the downloaded Go bundles at` )
480
- gohash = flag .String ("gohash" , "" , `SHA256 checksum of the Go sources requested to build with` )
477
+ cachedir = flag .String ("cachedir" , "./build/cache" , `Filesystem path to cache the downloaded Go bundles at` )
481
478
signer = flag .String ("signer" , "" , `Signing key name, also used as package author` )
482
479
upload = flag .String ("upload" , "" , `Where to upload the source package (usually "ethereum/ethereum")` )
483
480
sshUser = flag .String ("sftp-user" , "" , `Username for SFTP upload (usually "geth-ci")` )
@@ -495,24 +492,25 @@ func doDebianSource(cmdline []string) {
495
492
gpg .Stdin = bytes .NewReader (key )
496
493
build .MustRun (gpg )
497
494
}
498
- // Download and verify the Go source package
499
- if err := build . EnsureGoSources ( * goversion , hexutil . MustDecode ( "0x" + * gohash ), * gobundle ); err != nil {
500
- log . Fatalf ( "Failed to ensure Go source package: %v" , err )
501
- }
502
- // Create Debian packages and upload them
495
+
496
+ // Download and verify the Go source package.
497
+ gobundle := downloadGoSources ( * goversion , * cachedir )
498
+
499
+ // Create Debian packages and upload them.
503
500
for _ , pkg := range debPackages {
504
501
for distro , goboot := range debDistroGoBoots {
505
- // Prepare the debian package with the go-ethereum sources
502
+ // Prepare the debian package with the go-ethereum sources.
506
503
meta := newDebMetadata (distro , goboot , * signer , env , now , pkg .Name , pkg .Version , pkg .Executables )
507
504
pkgdir := stageDebianSource (* workdir , meta )
508
505
509
- // Ship the Go sources along so we have a proper thing to build with
510
- if err := build .ExtractTarballArchive (* gobundle , pkgdir ); err != nil {
506
+ // Add Go source code.
507
+ if err := build .ExtractTarballArchive (gobundle , pkgdir ); err != nil {
511
508
log .Fatalf ("Failed to extract Go sources: %v" , err )
512
509
}
513
510
if err := os .Rename (filepath .Join (pkgdir , "go" ), filepath .Join (pkgdir , ".go" )); err != nil {
514
511
log .Fatalf ("Failed to rename Go source folder: %v" , err )
515
512
}
513
+
516
514
// Run the packaging and upload to the PPA
517
515
debuild := exec .Command ("debuild" , "-S" , "-sa" , "-us" , "-uc" , "-d" , "-Zxz" )
518
516
debuild .Dir = pkgdir
@@ -534,6 +532,17 @@ func doDebianSource(cmdline []string) {
534
532
}
535
533
}
536
534
535
+ func downloadGoSources (version string , cachedir string ) string {
536
+ csdb := build .MustLoadChecksums ("build/checksums.txt" )
537
+ file := fmt .Sprintf ("go%s.src.tar.gz" , version )
538
+ url := "https://dl.google.com/go/" + file
539
+ dst := filepath .Join (cachedir , file )
540
+ if err := csdb .DownloadFile (url , dst ); err != nil {
541
+ log .Fatal (err )
542
+ }
543
+ return dst
544
+ }
545
+
537
546
func ppaUpload (workdir , ppa , sshUser string , files []string ) {
538
547
p := strings .Split (ppa , "/" )
539
548
if len (p ) != 2 {
0 commit comments