@@ -449,10 +449,13 @@ type moduleArtifact struct {
449
449
func (tasks * BuildReleaseTasks ) addBuildTasks (wd * wf.Definition , major int , version wf.Value [string ], timestamp wf.Value [time.Time ], source wf.Value [artifact ]) (wf.Value [[]artifact ], wf.Value [[]moduleArtifact ]) {
450
450
targets := releasetargets .TargetsForGo1Point (major )
451
451
skipTests := wf .Param (wd , wf.ParamDef [[]string ]{Name : "Targets to skip testing (or 'all') (optional)" , ParamType : wf .SliceShort })
452
+
452
453
artifacts := []wf.Value [artifact ]{source }
454
+ var reproducibilityCheckDistpack wf.Value [artifact ]
453
455
var mods []wf.Value [moduleArtifact ]
456
+ var blockers []wf.Dependency
457
+
454
458
// Build, test and sign binary artifacts for all targets.
455
- var testsPassed []wf.Dependency
456
459
for _ , target := range targets {
457
460
targetVal := wf .Const (target )
458
461
wd := wd .Sub (target .Name )
@@ -463,7 +466,10 @@ func (tasks *BuildReleaseTasks) addBuildTasks(wd *wf.Definition, major int, vers
463
466
var tar , zip wf.Value [artifact ]
464
467
var mod wf.Value [moduleArtifact ]
465
468
if enableDistpack (major ) {
466
- distpack := wf .Task2 (wd , "Build distpack" , tasks .buildDistpack , targetVal , source )
469
+ distpack := wf .Task3 (wd , "Build distpack" , tasks .buildDistpack , wf .Const ("linux-amd64" ), wf .Const (target ), source )
470
+ if target .Name == "linux-amd64" {
471
+ reproducibilityCheckDistpack = distpack
472
+ }
467
473
if target .GOOS == "windows" {
468
474
zip = wf .Task1 (wd , "Get binary from distpack" , tasks .binaryArchiveFromDistpack , distpack )
469
475
tar = wf .Task2 (wd , "Convert to .tgz" , tasks .convertZipToTGZ , targetVal , zip )
@@ -501,12 +507,16 @@ func (tasks *BuildReleaseTasks) addBuildTasks(wd *wf.Definition, major int, vers
501
507
continue
502
508
}
503
509
short := wf .Action4 (wd , "Run short tests" , tasks .runTests , targetVal , wf .Const (dashboard .Builders [target .Builder ]), skipTests , tar )
504
- testsPassed = append (testsPassed , short )
510
+ blockers = append (blockers , short )
505
511
if target .LongTestBuilder != "" {
506
512
long := wf .Action4 (wd , "Run long tests" , tasks .runTests , targetVal , wf .Const (dashboard .Builders [target .Builder ]), skipTests , tar )
507
- testsPassed = append (testsPassed , long )
513
+ blockers = append (blockers , long )
508
514
}
509
515
}
516
+ if enableDistpack (major ) {
517
+ reproducer := wf .Task3 (wd , "Reproduce distpack on Windows" , tasks .buildDistpack , wf .Const ("windows-amd64-2016" ), wf .Const (targets ["linux-amd64" ]), source )
518
+ blockers = append (blockers , wf .Action2 (wd , "Check distpacks match" , tasks .checkDistpacksMatch , reproducibilityCheckDistpack , reproducer ))
519
+ }
510
520
signedArtifacts := wf .Task1 (wd , "Compute GPG signature for artifacts" , tasks .computeGPG , wf .Slice (artifacts ... ))
511
521
512
522
// Run advisory trybots.
@@ -516,6 +526,7 @@ func (tasks *BuildReleaseTasks) addBuildTasks(wd *wf.Definition, major int, vers
516
526
advisoryResults = append (advisoryResults , result )
517
527
}
518
528
tryBotsApproved := wf .Action1 (wd , "Wait for advisory TryBots" , tasks .checkAdvisoryTrybots , wf .Slice (advisoryResults ... ))
529
+ blockers = append (blockers , tryBotsApproved )
519
530
520
531
signedAndTested := wf .Task2 (wd , "Wait for signing and tests" , func (ctx * wf.TaskContext , artifacts []artifact , version string ) ([]artifact , error ) {
521
532
// Note: Note this needs to happen somewhere, doesn't matter where. Maybe move it to a nicer place later.
@@ -528,7 +539,7 @@ func (tasks *BuildReleaseTasks) addBuildTasks(wd *wf.Definition, major int, vers
528
539
}
529
540
530
541
return artifacts , nil
531
- }, signedArtifacts , version , wf .After (testsPassed ... ), wf . After ( tryBotsApproved ), wf .After (wf .Slice (mods ... )))
542
+ }, signedArtifacts , version , wf .After (blockers ... ), wf .After (wf .Slice (mods ... )))
532
543
return signedAndTested , wf .Slice (mods ... )
533
544
}
534
545
@@ -589,35 +600,40 @@ func (b *BuildReleaseTasks) checkSourceMatch(ctx *wf.TaskContext, distpack bool,
589
600
if err != nil {
590
601
return "" , err
591
602
}
592
- var bc * dashboard. BuildConfig
593
- if distpack {
594
- bc = dashboard . Builders [ "linux-amd64" ]
603
+ branchArchive , err := b . buildSource ( ctx , distpack , head , "" , versionFile )
604
+ if err != nil {
605
+ return "" , err
595
606
}
596
- _ , err = b .runBuildStep (ctx , nil , bc , source , "" , func (bs * task.BuildletStep , r io.Reader , _ io.Writer ) error {
597
- branchArchive := & bytes.Buffer {}
598
- if distpack {
599
- if err := bs .BuildSourceDistpack (ctx , b .GerritHTTPClient , b .GerritURL , head , versionFile , branchArchive ); err != nil {
600
- return err
601
- }
602
- } else {
603
- if err := task .WriteSourceArchive (ctx , b .GerritHTTPClient , b .GerritURL , head , versionFile , branchArchive ); err != nil {
604
- return err
605
- }
606
- }
607
- branchHashes , err := tarballHashes (branchArchive )
608
- if err != nil {
609
- return fmt .Errorf ("hashing branch tarball: %v" , err )
610
- }
611
- archiveHashes , err := tarballHashes (r )
612
- if err != nil {
613
- return fmt .Errorf ("hashing archive tarball: %v" , err )
614
- }
615
- if diff := cmp .Diff (branchHashes , archiveHashes ); diff != "" {
616
- return fmt .Errorf ("branch state doesn't match source archive (-branch, +archive):\n %v" , diff )
617
- }
618
- return nil
607
+ diff , err := b .diffArtifacts (ctx , branchArchive , source )
608
+ if err != nil {
609
+ return "" , err
610
+ }
611
+ if diff != "" {
612
+ return "" , fmt .Errorf ("branch state doesn't match source archive (-branch, +archive):\n %v" , diff )
613
+ }
614
+ return head , nil
615
+ }
616
+
617
+ func (b * BuildReleaseTasks ) diffArtifacts (ctx * wf.TaskContext , a1 , a2 artifact ) (string , error ) {
618
+ h1 , err := b .hashArtifact (ctx , a1 )
619
+ if err != nil {
620
+ return "" , fmt .Errorf ("hashing first tarball: %v" , err )
621
+ }
622
+ h2 , err := b .hashArtifact (ctx , a2 )
623
+ if err != nil {
624
+ return "" , fmt .Errorf ("hashing second tarball: %v" , err )
625
+ }
626
+ return cmp .Diff (h1 , h2 ), nil
627
+ }
628
+
629
+ func (b * BuildReleaseTasks ) hashArtifact (ctx * wf.TaskContext , a artifact ) (map [string ]string , error ) {
630
+ var hashes map [string ]string
631
+ _ , err := b .runBuildStep (ctx , nil , nil , a , "" , func (_ * task.BuildletStep , r io.Reader , _ io.Writer ) error {
632
+ var err error
633
+ hashes , err = tarballHashes (r )
634
+ return err
619
635
})
620
- return head , err
636
+ return hashes , err
621
637
}
622
638
623
639
func tarballHashes (r io.Reader ) (map [string ]string , error ) {
@@ -644,14 +660,24 @@ func tarballHashes(r io.Reader) (map[string]string, error) {
644
660
return hashes , nil
645
661
}
646
662
647
- func (b * BuildReleaseTasks ) buildDistpack (ctx * wf.TaskContext , target * releasetargets.Target , source artifact ) (artifact , error ) {
648
- // Always run distpack builds on Linux.
649
- bc := dashboard .Builders ["linux-amd64" ]
650
- return b .runBuildStep (ctx , target , bc , source , ".tar.gz" , func (bs * task.BuildletStep , r io.Reader , w io.Writer ) error {
663
+ func (b * BuildReleaseTasks ) buildDistpack (ctx * wf.TaskContext , builder string , target * releasetargets.Target , source artifact ) (artifact , error ) {
664
+ bc := dashboard .Builders [builder ]
665
+ return b .runBuildStep (ctx , target , bc , source , "tar.gz" , func (bs * task.BuildletStep , r io.Reader , w io.Writer ) error {
651
666
return bs .BuildDistpack (ctx , r , w )
652
667
})
653
668
}
654
669
670
+ func (b * BuildReleaseTasks ) checkDistpacksMatch (ctx * wf.TaskContext , linux , windows artifact ) error {
671
+ diff , err := b .diffArtifacts (ctx , linux , windows )
672
+ if err != nil {
673
+ return err
674
+ }
675
+ if diff != "" {
676
+ return fmt .Errorf ("distpacks don't match (-linux, +windows): %v" , diff )
677
+ }
678
+ return nil
679
+ }
680
+
655
681
func (b * BuildReleaseTasks ) binaryArchiveFromDistpack (ctx * wf.TaskContext , distpack artifact ) (artifact , error ) {
656
682
// This must not match the module files, which currently start with v0.0.1.
657
683
glob := fmt .Sprintf ("go*%v-%v.*" , distpack .Target .GOOS , distpack .Target .GOARCH )
0 commit comments