Skip to content

Commit 8006383

Browse files
dmitshurgopherbot
authored andcommitted
internal/relui: remove old signing path
Delete unused code. For golang/go#53632. Change-Id: Ie52e0e067bccb9d363f3b89600bd7fc8521ff332 Reviewed-on: https://go-review.googlesource.com/c/build/+/447276 TryBot-Result: Gopher Robot <[email protected]> Auto-Submit: Dmitri Shuralyov <[email protected]> Reviewed-by: Carlos Amedee <[email protected]> Run-TryBot: Dmitri Shuralyov <[email protected]> Reviewed-by: Dmitri Shuralyov <[email protected]>
1 parent 53a17d8 commit 8006383

File tree

3 files changed

+20
-491
lines changed

3 files changed

+20
-491
lines changed

internal/relui/buildrelease_test.go

+16-213
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,8 @@ import (
1717
"io/ioutil"
1818
"net/http"
1919
"net/http/httptest"
20-
"net/url"
2120
"os"
2221
"path/filepath"
23-
"regexp"
2422
"runtime"
2523
"strings"
2624
"sync"
@@ -68,7 +66,6 @@ type releaseTestDeps struct {
6866
buildTasks *BuildReleaseTasks
6967
milestoneTasks *task.MilestoneTasks
7068
publishedFiles map[string]*task.WebsiteFile
71-
outputListener func(taskName string, output interface{})
7269
}
7370

7471
func newReleaseTestDeps(t *testing.T, wantVersion string) *releaseTestDeps {
@@ -79,16 +76,11 @@ func newReleaseTestDeps(t *testing.T, wantVersion string) *releaseTestDeps {
7976
t.Cleanup(func() { task.AwaitDivisor, workflow.MaxRetries = 1, 3 })
8077
ctx, cancel := context.WithCancel(context.Background())
8178

82-
// Set up the fake signing process.
83-
var (
84-
signService sign.Service
85-
sysCmds map[string]string
86-
outputListener func(taskName string, output interface{})
87-
)
88-
if useSignService {
89-
signService = &fakeSignService{t: t, completedJobs: make(map[string][]string)}
90-
sysCmds = map[string]string{
91-
"pkgbuild": `#!/bin/bash -eu
79+
// Set up a server that will be used to serve inputs to the build.
80+
bootstrapServer := httptest.NewServer(http.HandlerFunc(serveBootstrap))
81+
t.Cleanup(bootstrapServer.Close)
82+
fakeBuildlets := task.NewFakeBuildlets(t, bootstrapServer.URL, map[string]string{
83+
"pkgbuild": `#!/bin/bash -eu
9284
case "$@" in
9385
"--identifier=org.golang.go --version ` + wantVersion + ` --scripts=pkg-scripts --root=pkg-root pkg-intermediate/org.golang.go.pkg")
9486
# We're doing an intermediate step in building a PKG.
@@ -101,7 +93,7 @@ case "$@" in
10193
;;
10294
esac
10395
`,
104-
"productbuild": `#!/bin/bash -eu
96+
"productbuild": `#!/bin/bash -eu
10597
case "$@" in
10698
"--distribution=pkg-distribution --resources=pkg-resources --package-path=pkg-intermediate pkg-out/` + wantVersion + `.pkg")
10799
# We're building a PKG.
@@ -114,7 +106,7 @@ case "$@" in
114106
;;
115107
esac
116108
`,
117-
"pkgutil": `#!/bin/bash -eu
109+
"pkgutil": `#!/bin/bash -eu
118110
case "$@" in
119111
"--expand-full go.pkg pkg-expanded")
120112
# We're expanding a PKG.
@@ -127,29 +119,7 @@ case "$@" in
127119
;;
128120
esac
129121
`,
130-
}
131-
} else {
132-
argRe := regexp.MustCompile(`--relui_staging="(.*?)"`)
133-
outputListener = func(taskName string, output interface{}) {
134-
if taskName != "Start signing command" {
135-
return
136-
}
137-
matches := argRe.FindStringSubmatch(output.(string))
138-
if matches == nil {
139-
return
140-
}
141-
u, err := url.Parse(matches[1])
142-
if err != nil {
143-
t.Fatal(err)
144-
}
145-
go fakeSign(ctx, t, u.Path)
146-
}
147-
}
148-
149-
// Set up a server that will be used to serve inputs to the build.
150-
bootstrapServer := httptest.NewServer(http.HandlerFunc(serveBootstrap))
151-
t.Cleanup(bootstrapServer.Close)
152-
fakeBuildlets := task.NewFakeBuildlets(t, bootstrapServer.URL, sysCmds)
122+
})
153123

154124
// Set up the fake CDN publishing process.
155125
servingDir := t.TempDir()
@@ -196,7 +166,7 @@ esac
196166
ScratchURL: "file://" + filepath.ToSlash(t.TempDir()),
197167
ServingURL: "file://" + filepath.ToSlash(servingDir),
198168
CreateBuildlet: fakeBuildlets.CreateBuildlet,
199-
SignService: signService,
169+
SignService: &fakeSignService{t: t, completedJobs: make(map[string][]string)},
200170
DownloadURL: dlServer.URL,
201171
PublishFile: publishFile,
202172
ApproveAction: func(ctx *workflow.TaskContext) error {
@@ -219,7 +189,6 @@ esac
219189
buildTasks: buildTasks,
220190
milestoneTasks: milestoneTasks,
221191
publishedFiles: files,
222-
outputListener: outputListener,
223192
}
224193
}
225194

@@ -238,7 +207,7 @@ func testRelease(t *testing.T, wantVersion string, kind task.ReleaseKind) {
238207
if err != nil {
239208
t.Fatal(err)
240209
}
241-
_, err = w.Run(deps.ctx, &verboseListener{t: t, outputListener: deps.outputListener, onStall: deps.cancel})
210+
_, err = w.Run(deps.ctx, &verboseListener{t: t, onStall: deps.cancel})
242211
if err != nil {
243212
t.Fatal(err)
244213
}
@@ -280,7 +249,7 @@ func testRelease(t *testing.T, wantVersion string, kind task.ReleaseKind) {
280249
if got, want := fmt.Sprintf("%x", sha256.Sum256(b)), string(fetch(t, dlURL+"/"+f.Filename+".sha256")); got != want {
281250
t.Errorf("%s sha256 mismatch with .sha256 file: %q != %q", f.Filename, got, want)
282251
}
283-
if useSignService && strings.HasSuffix(f.Filename, ".tar.gz") {
252+
if strings.HasSuffix(f.Filename, ".tar.gz") {
284253
if got, want := string(fetch(t, dlURL+"/"+f.Filename+".asc")), fmt.Sprintf("I'm a GPG signature for %x!", sha256.Sum256(b)); got != want {
285254
t.Errorf("%v doesn't have the expected GPG signature: got %s, want %s", f.Filename, got, want)
286255
}
@@ -396,12 +365,12 @@ func testSecurity(t *testing.T, mergeFixes bool) {
396365
}
397366

398367
if mergeFixes {
399-
_, err = w.Run(deps.ctx, &verboseListener{t: t, outputListener: deps.outputListener})
368+
_, err = w.Run(deps.ctx, &verboseListener{t: t})
400369
if err != nil {
401370
t.Fatal(err)
402371
}
403372
} else {
404-
runToFailure(t, deps.ctx, w, "Check branch state matches source archive", &verboseListener{t: t, outputListener: deps.outputListener})
373+
runToFailure(t, deps.ctx, w, "Check branch state matches source archive", &verboseListener{t: t})
405374
return
406375
}
407376
checkTGZ(t, deps.buildTasks.DownloadURL, deps.publishedFiles, "src.tar.gz", &task.WebsiteFile{
@@ -437,7 +406,7 @@ func TestAdvisoryTrybotFail(t *testing.T) {
437406
if err != nil {
438407
t.Fatal(err)
439408
}
440-
if _, err := w.Run(deps.ctx, &verboseListener{t: t, outputListener: deps.outputListener}); err != nil {
409+
if _, err := w.Run(deps.ctx, &verboseListener{t: t}); err != nil {
441410
t.Fatal(err)
442411
}
443412
if !approvedTrybots {
@@ -641,9 +610,8 @@ func (g *fakeGitHub) EditMilestone(ctx context.Context, owner string, repo strin
641610
}
642611

643612
type verboseListener struct {
644-
t *testing.T
645-
outputListener func(string, interface{})
646-
onStall func()
613+
t *testing.T
614+
onStall func()
647615
}
648616

649617
func (l *verboseListener) WorkflowStalled(workflowID uuid.UUID) error {
@@ -662,9 +630,6 @@ func (l *verboseListener) TaskStateChanged(_ uuid.UUID, _ string, st *workflow.T
662630
l.t.Logf("task %-10v: error: %v", st.Name, st.Error)
663631
default:
664632
l.t.Logf("task %-10v: done: %v", st.Name, st.Result)
665-
if l.outputListener != nil {
666-
l.outputListener(st.Name, st.Result)
667-
}
668633
}
669634
return nil
670635
}
@@ -785,168 +750,6 @@ func fakeGPGFile(f string) string {
785750
return f + ".asc"
786751
}
787752

788-
// fakeSign acts like a human running the signbinaries job periodically.
789-
func fakeSign(ctx context.Context, t *testing.T, dir string) {
790-
seen := map[string]bool{}
791-
periodicallyDo(ctx, t, 100*time.Millisecond, func() error {
792-
return fakeSignOnce(t, dir, seen)
793-
})
794-
}
795-
796-
func fakeSignOnce(t *testing.T, dir string, seen map[string]bool) error {
797-
dirFS := gcsfs.DirFS(dir)
798-
_, err := fs.Stat(dirFS, "ready")
799-
if os.IsNotExist(err) {
800-
return nil
801-
}
802-
if err != nil {
803-
return err
804-
}
805-
contents, err := fs.ReadDir(dirFS, ".")
806-
if err != nil {
807-
return err
808-
}
809-
for _, fi := range contents {
810-
fn := fi.Name()
811-
if fn == "signed" || seen[fn] {
812-
continue
813-
}
814-
var copy, gpgSign, makePkg bool
815-
hasSuffix := func(suffix string) bool { return strings.HasSuffix(fn, suffix) }
816-
switch {
817-
case strings.Contains(fn, "darwin") && hasSuffix(".tar.gz"):
818-
copy = true
819-
gpgSign = true
820-
makePkg = true
821-
case strings.Contains(fn, "darwin") && hasSuffix(".pkg"):
822-
copy = true
823-
case hasSuffix(".tar.gz"):
824-
gpgSign = true
825-
case hasSuffix("msi"):
826-
copy = true
827-
}
828-
829-
writeSignedWithHash := func(filename string, contents []byte) error {
830-
if err := gcsfs.WriteFile(dirFS, "signed/"+filename, contents); err != nil {
831-
return err
832-
}
833-
hash := fmt.Sprintf("%x", sha256.Sum256(contents))
834-
return gcsfs.WriteFile(dirFS, "signed/"+filename+".sha256", []byte(hash))
835-
}
836-
837-
if copy {
838-
bytes, err := fs.ReadFile(dirFS, fn)
839-
if err != nil {
840-
return err
841-
}
842-
if err := writeSignedWithHash(fn, bytes); err != nil {
843-
return err
844-
}
845-
}
846-
if makePkg {
847-
if err := writeSignedWithHash(strings.ReplaceAll(fn, ".tar.gz", ".pkg"), []byte("I'm a .pkg!\n")); err != nil {
848-
return err
849-
}
850-
}
851-
if gpgSign {
852-
if err := writeSignedWithHash(fn+".asc", []byte("gpg signature")); err != nil {
853-
return err
854-
}
855-
}
856-
seen[fn] = true
857-
}
858-
return nil
859-
}
860-
861-
func TestFakeSign(t *testing.T) {
862-
// These are the files created by the Go 1.18 release.
863-
const inputs = `
864-
go1.18.darwin-amd64.tar.gz
865-
go1.18.darwin-arm64.tar.gz
866-
go1.18.freebsd-386.tar.gz
867-
go1.18.freebsd-amd64.tar.gz
868-
go1.18.linux-386.tar.gz
869-
go1.18.linux-amd64.tar.gz
870-
go1.18.linux-arm64.tar.gz
871-
go1.18.linux-armv6l.tar.gz
872-
go1.18.linux-ppc64le.tar.gz
873-
go1.18.linux-s390x.tar.gz
874-
go1.18.src.tar.gz
875-
go1.18.windows-386.msi
876-
go1.18.windows-386.zip
877-
go1.18.windows-amd64.msi
878-
go1.18.windows-amd64.zip
879-
go1.18.windows-arm64.msi
880-
go1.18.windows-arm64.zip
881-
`
882-
883-
// These are the files created in the "signed" folder by the signing run for Go 1.18.
884-
const outputs = `
885-
go1.18.darwin-amd64.pkg
886-
go1.18.darwin-amd64.pkg.sha256
887-
go1.18.darwin-amd64.tar.gz
888-
go1.18.darwin-amd64.tar.gz.asc
889-
go1.18.darwin-amd64.tar.gz.asc.sha256
890-
go1.18.darwin-amd64.tar.gz.sha256
891-
go1.18.darwin-arm64.pkg
892-
go1.18.darwin-arm64.pkg.sha256
893-
go1.18.darwin-arm64.tar.gz
894-
go1.18.darwin-arm64.tar.gz.asc
895-
go1.18.darwin-arm64.tar.gz.asc.sha256
896-
go1.18.darwin-arm64.tar.gz.sha256
897-
go1.18.freebsd-386.tar.gz.asc
898-
go1.18.freebsd-386.tar.gz.asc.sha256
899-
go1.18.freebsd-amd64.tar.gz.asc
900-
go1.18.freebsd-amd64.tar.gz.asc.sha256
901-
go1.18.linux-386.tar.gz.asc
902-
go1.18.linux-386.tar.gz.asc.sha256
903-
go1.18.linux-amd64.tar.gz.asc
904-
go1.18.linux-amd64.tar.gz.asc.sha256
905-
go1.18.linux-arm64.tar.gz.asc
906-
go1.18.linux-arm64.tar.gz.asc.sha256
907-
go1.18.linux-armv6l.tar.gz.asc
908-
go1.18.linux-armv6l.tar.gz.asc.sha256
909-
go1.18.linux-ppc64le.tar.gz.asc
910-
go1.18.linux-ppc64le.tar.gz.asc.sha256
911-
go1.18.linux-s390x.tar.gz.asc
912-
go1.18.linux-s390x.tar.gz.asc.sha256
913-
go1.18.src.tar.gz.asc
914-
go1.18.src.tar.gz.asc.sha256
915-
go1.18.windows-386.msi
916-
go1.18.windows-386.msi.sha256
917-
go1.18.windows-amd64.msi
918-
go1.18.windows-amd64.msi.sha256
919-
go1.18.windows-arm64.msi
920-
go1.18.windows-arm64.msi.sha256
921-
`
922-
923-
dir := t.TempDir()
924-
for _, f := range strings.Split(strings.TrimSpace(inputs), "\n") {
925-
if err := ioutil.WriteFile(filepath.Join(dir, f), []byte("hi"), 0777); err != nil {
926-
t.Fatal(err)
927-
}
928-
}
929-
if err := ioutil.WriteFile(filepath.Join(dir, "ready"), nil, 0777); err != nil {
930-
t.Fatal(err)
931-
}
932-
fakeSignOnce(t, dir, map[string]bool{})
933-
want := map[string]bool{}
934-
for _, f := range strings.Split(strings.TrimSpace(outputs), "\n") {
935-
want[f] = true
936-
}
937-
got := map[string]bool{}
938-
files, err := ioutil.ReadDir(filepath.Join(dir, "signed"))
939-
if err != nil {
940-
t.Fatal(err)
941-
}
942-
for _, f := range files {
943-
got[f.Name()] = true
944-
}
945-
if diff := cmp.Diff(want, got); diff != "" {
946-
t.Errorf("signed outputs mismatch (-want +got):\n%v", diff)
947-
}
948-
}
949-
950753
func fakeCDNLoad(ctx context.Context, t *testing.T, from, to string) {
951754
fromFS, toFS := gcsfs.DirFS(from), gcsfs.DirFS(to)
952755
seen := map[string]bool{}

internal/relui/templates/task_list.html

-8
Original file line numberDiff line numberDiff line change
@@ -170,14 +170,6 @@
170170
<dd class="TaskList-itemResultDefinition">
171171
{{.Artifact.ScratchPath}}
172172
</dd>
173-
<dt class="TaskList-itemResultTerm">
174-
<div class="TaskList-itemResultTermContent">
175-
StagingPath
176-
</div>
177-
</dt>
178-
<dd class="TaskList-itemResultDefinition">
179-
{{.Artifact.StagingPath}}
180-
</dd>
181173
</dl>
182174
{{else if eq .Kind "Outputs"}}
183175
{{range $key, $value := .Outputs}}

0 commit comments

Comments
 (0)