Skip to content

Commit 1380f86

Browse files
committed
app/appengine: delete more dead code
This is part of a series of CLs to clean up the build.golang.org App Engine app in prep for it to be modernized, refactored, and replaced, starting with deleting dead code. Updates golang/go#34744 Change-Id: I6cddbb44a63597a308f1d4399d21e5b70a8d83bf Reviewed-on: https://go-review.googlesource.com/c/build/+/208324 Reviewed-by: Andrew Gerrand <adg@golang.org>
1 parent f2aa121 commit 1380f86

File tree

10 files changed

+12
-865
lines changed

10 files changed

+12
-865
lines changed

app/appengine/app.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ handlers:
55
- url: /static
66
static_dir: app/appengine/static
77
secure: always
8-
- url: /(init|buildtest)
8+
- url: /init
99
script: auto
1010
login: admin
1111
secure: always

app/appengine/build.go

Lines changed: 0 additions & 137 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import (
1212
"fmt"
1313
"io"
1414
"io/ioutil"
15-
"strconv"
1615
"strings"
1716
"time"
1817

@@ -23,7 +22,6 @@ import (
2322

2423
const (
2524
maxDatastoreStringLen = 500
26-
PerfRunLength = 1024
2725
)
2826

2927
// A Package describes a package that is listed on the dashboard.
@@ -101,12 +99,6 @@ type Commit struct {
10199
// The complete data set is stored in Result entities.
102100
ResultData []string `datastore:",noindex"`
103101

104-
// PerfResults holds a set of “builder|benchmark” tuples denoting
105-
// what benchmarks have been executed on the commit.
106-
PerfResults []string `datastore:",noindex"`
107-
108-
FailNotificationSent bool
109-
110102
buildingURLs map[builderAndGoHash]string
111103
}
112104

@@ -183,25 +175,6 @@ func (com *Commit) RemoveResult(r *Result) {
183175
com.ResultData = rd
184176
}
185177

186-
// AddPerfResult remembers that the builder has run the benchmark on the commit.
187-
// It must be called from inside a datastore transaction.
188-
func (com *Commit) AddPerfResult(c context.Context, builder, benchmark string) error {
189-
if err := datastore.Get(c, com.Key(c), com); err != nil {
190-
return fmt.Errorf("getting Commit: %v", err)
191-
}
192-
if !com.NeedsBenchmarking {
193-
return fmt.Errorf("trying to add perf result to Commit(%v) that does not require benchmarking", com.Hash)
194-
}
195-
s := builder + "|" + benchmark
196-
for _, v := range com.PerfResults {
197-
if v == s {
198-
return nil
199-
}
200-
}
201-
com.PerfResults = append(com.PerfResults, s)
202-
return putCommit(c, com)
203-
}
204-
205178
func trim(s []string, n int) []string {
206179
l := min(len(s), n)
207180
return s[len(s)-l:]
@@ -314,116 +287,6 @@ func reverse(s []string) {
314287
}
315288
}
316289

317-
// A CommitRun provides summary information for commits [StartCommitNum, StartCommitNum + PerfRunLength).
318-
// Descendant of Package.
319-
type CommitRun struct {
320-
PackagePath string // (empty for main repo commits)
321-
StartCommitNum int
322-
Hash []string `datastore:",noindex"`
323-
User []string `datastore:",noindex"`
324-
Desc []string `datastore:",noindex"` // Only first line.
325-
Time []time.Time `datastore:",noindex"`
326-
NeedsBenchmarking []bool `datastore:",noindex"`
327-
}
328-
329-
func (cr *CommitRun) Key(c context.Context) *datastore.Key {
330-
p := Package{Path: cr.PackagePath}
331-
key := strconv.Itoa(cr.StartCommitNum)
332-
return datastore.NewKey(c, "CommitRun", key, 0, p.Key(c))
333-
}
334-
335-
// GetCommitRun loads and returns CommitRun that contains information
336-
// for commit commitNum.
337-
func GetCommitRun(c context.Context, commitNum int) (*CommitRun, error) {
338-
cr := &CommitRun{StartCommitNum: commitNum / PerfRunLength * PerfRunLength}
339-
err := datastore.Get(c, cr.Key(c), cr)
340-
if err != nil && err != datastore.ErrNoSuchEntity {
341-
return nil, fmt.Errorf("getting CommitRun: %v", err)
342-
}
343-
if len(cr.Hash) != PerfRunLength {
344-
cr.Hash = make([]string, PerfRunLength)
345-
cr.User = make([]string, PerfRunLength)
346-
cr.Desc = make([]string, PerfRunLength)
347-
cr.Time = make([]time.Time, PerfRunLength)
348-
cr.NeedsBenchmarking = make([]bool, PerfRunLength)
349-
}
350-
return cr, nil
351-
}
352-
353-
func (cr *CommitRun) AddCommit(c context.Context, com *Commit) error {
354-
if com.Num < cr.StartCommitNum || com.Num >= cr.StartCommitNum+PerfRunLength {
355-
return fmt.Errorf("AddCommit: commit num %v out of range [%v, %v)",
356-
com.Num, cr.StartCommitNum, cr.StartCommitNum+PerfRunLength)
357-
}
358-
i := com.Num - cr.StartCommitNum
359-
// Be careful with string lengths,
360-
// we need to fit 1024 commits into 1 MB.
361-
cr.Hash[i] = com.Hash
362-
cr.User[i] = shortDesc(com.User)
363-
cr.Desc[i] = shortDesc(com.Desc)
364-
cr.Time[i] = com.Time
365-
cr.NeedsBenchmarking[i] = com.NeedsBenchmarking
366-
if _, err := datastore.Put(c, cr.Key(c), cr); err != nil {
367-
return fmt.Errorf("putting CommitRun: %v", err)
368-
}
369-
return nil
370-
}
371-
372-
// GetCommits returns [startCommitNum, startCommitNum+n) commits.
373-
// Commits information is partial (obtained from CommitRun),
374-
// do not store them back into datastore.
375-
func GetCommits(c context.Context, startCommitNum, n int) ([]*Commit, error) {
376-
if startCommitNum < 0 || n <= 0 {
377-
return nil, fmt.Errorf("GetCommits: invalid args (%v, %v)", startCommitNum, n)
378-
}
379-
380-
p := &Package{}
381-
t := datastore.NewQuery("CommitRun").
382-
Ancestor(p.Key(c)).
383-
Filter("StartCommitNum >=", startCommitNum/PerfRunLength*PerfRunLength).
384-
Order("StartCommitNum").
385-
Limit(100).
386-
Run(c)
387-
388-
res := make([]*Commit, n)
389-
for {
390-
cr := new(CommitRun)
391-
_, err := t.Next(cr)
392-
if err == datastore.Done {
393-
break
394-
}
395-
if err != nil {
396-
return nil, err
397-
}
398-
if cr.StartCommitNum >= startCommitNum+n {
399-
break
400-
}
401-
// Calculate start index for copying.
402-
i := 0
403-
if cr.StartCommitNum < startCommitNum {
404-
i = startCommitNum - cr.StartCommitNum
405-
}
406-
// Calculate end index for copying.
407-
e := PerfRunLength
408-
if cr.StartCommitNum+e > startCommitNum+n {
409-
e = startCommitNum + n - cr.StartCommitNum
410-
}
411-
for ; i < e; i++ {
412-
com := new(Commit)
413-
com.Hash = cr.Hash[i]
414-
com.User = cr.User[i]
415-
com.Desc = cr.Desc[i]
416-
com.Time = cr.Time[i]
417-
com.NeedsBenchmarking = cr.NeedsBenchmarking[i]
418-
res[cr.StartCommitNum-startCommitNum+i] = com
419-
}
420-
if e != PerfRunLength {
421-
break
422-
}
423-
}
424-
return res, nil
425-
}
426-
427290
// partsToResult converts a Commit and ResultData substrings to a Result.
428291
func partsToResult(c *Commit, p []string) *Result {
429292
return &Result{

app/appengine/config.go

Lines changed: 0 additions & 93 deletions
This file was deleted.

app/appengine/dash.go

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,10 @@ func main() {
2424
handleFunc("/packages", AuthHandler(packagesHandler))
2525
handleFunc("/result", AuthHandler(resultHandler))
2626
handleFunc("/tag", AuthHandler(tagHandler))
27-
handleFunc("/todo", AuthHandler(todoHandler))
2827

2928
// public handlers
3029
handleFunc("/", uiHandler)
3130
handleFunc("/log/", logHandler)
32-
handleFunc("/updatebenchmark", updateBenchmark)
33-
handleFunc("/buildtest", testHandler)
3431

3532
appengine.Main()
3633
}
@@ -48,10 +45,12 @@ func hstsHandler(fn http.HandlerFunc) http.Handler {
4845
}
4946

5047
// Dashboard describes a unique build dashboard.
48+
//
49+
// (There used to be more than one dashboard, so this is now somewhat
50+
// less important than it once was.)
5151
type Dashboard struct {
52-
Name string // This dashboard's name (eg, "Go")
53-
Namespace string // This dashboard's namespace (eg, "" (default), "Git")
54-
Prefix string // The path prefix (no trailing /)
52+
Name string // This dashboard's name (always "Go" nowadays)
53+
Namespace string // This dashboard's namespace (always "Git" nowadays)
5554
Packages []*Package // The project's packages to build
5655
}
5756

@@ -72,7 +71,6 @@ func (d *Dashboard) Context(ctx context.Context) context.Context {
7271
var goDash = &Dashboard{
7372
Name: "Go",
7473
Namespace: "Git",
75-
Prefix: "",
7674
Packages: goPackages,
7775
}
7876

0 commit comments

Comments
 (0)