@@ -1376,14 +1376,26 @@ func newTrySet(work *apipb.GerritTryWorkItem) *trySet {
1376
1376
// For the Go project on the "master" branch,
1377
1377
// use the TRY= syntax to test against x repos.
1378
1378
if branch := key .Branch ; key .Project == "go" && branch == "master" {
1379
- // linuxBuilder is the standard builder as it is the fastest and least expensive.
1380
- linuxBuilder := dashboard .Builders ["linux-amd64" ]
1379
+ // customBuilder optionally specifies the builder to use for the build
1380
+ // (empty string means to use the default builder).
1381
+ addXrepo := func (project , customBuilder string ) * buildStatus {
1382
+ // linux-amd64 is the default builder as it is the fastest and least
1383
+ // expensive.
1384
+ builder := dashboard .Builders ["linux-amd64" ]
1385
+ if customBuilder != "" {
1386
+ b , ok := dashboard .Builders [customBuilder ]
1387
+ if ! ok {
1388
+ log .Printf ("can't resolve requested builder %q" , customBuilder )
1389
+ return nil
1390
+ }
1391
+ builder = b
1392
+ }
1381
1393
1382
- addXrepo := func (project string ) * buildStatus {
1383
1394
if testingKnobSkipBuilds {
1384
1395
return nil
1385
1396
}
1386
- if ! linuxBuilder .BuildsRepoTryBot (project , branch , branch ) {
1397
+ if ! builder .BuildsRepoTryBot (project , branch , branch ) {
1398
+ log .Printf ("builder %q isn't configured to build %q@%q as a trybot" , builder .Name , project , branch )
1387
1399
return nil
1388
1400
}
1389
1401
rev , err := getRepoHead (project )
@@ -1392,7 +1404,7 @@ func newTrySet(work *apipb.GerritTryWorkItem) *trySet {
1392
1404
return nil
1393
1405
}
1394
1406
brev := buildgo.BuilderRev {
1395
- Name : linuxBuilder .Name ,
1407
+ Name : builder .Name ,
1396
1408
Rev : work .Commit ,
1397
1409
SubName : project ,
1398
1410
SubRev : rev ,
@@ -1407,17 +1419,17 @@ func newTrySet(work *apipb.GerritTryWorkItem) *trySet {
1407
1419
}
1408
1420
1409
1421
// First, add the opt-in x repos.
1410
- xrepos := xReposFromComments (work )
1411
- for project := range xrepos {
1412
- if bs := addXrepo (project ); bs != nil {
1422
+ repoBuilders := xReposFromComments (work )
1423
+ for rb := range repoBuilders {
1424
+ if bs := addXrepo (rb . Project , rb . Builder ); bs != nil {
1413
1425
ts .xrepos = append (ts .xrepos , bs )
1414
1426
}
1415
1427
}
1416
1428
1417
- // Always include x/tools. See golang.org/issue/34348.
1429
+ // Always include the default x/tools builder . See golang.org/issue/34348.
1418
1430
// Do not add it to the trySet's list of opt-in x repos, however.
1419
- if ! xrepos [ "tools" ] {
1420
- addXrepo ("tools" )
1431
+ if haveDefaultToolsBuild := repoBuilders [ xRepoAndBuilder { Project : "tools" }]; ! haveDefaultToolsBuild {
1432
+ addXrepo ("tools" , "" )
1421
1433
}
1422
1434
}
1423
1435
@@ -4193,18 +4205,39 @@ func slowBotsFromComments(work *apipb.GerritTryWorkItem) (builders []*dashboard.
4193
4205
return builders
4194
4206
}
4195
4207
4196
- // xReposFromComments looks at the TRY= comments from Gerrit (in
4197
- // work) and returns any additional subrepos that should be tested.
4198
- // The TRY= comments are expected to be of the format TRY=x/foo,
4199
- // where foo is the name of the subrepo.
4200
- func xReposFromComments (work * apipb.GerritTryWorkItem ) map [string ]bool {
4201
- xrepos := map [string ]bool {}
4208
+ type xRepoAndBuilder struct {
4209
+ Project string // "net", "tools", etc.
4210
+ Builder string // Builder to use. Empty string means default builder.
4211
+ }
4212
+
4213
+ func (rb xRepoAndBuilder ) String () string {
4214
+ if rb .Builder == "" {
4215
+ return rb .Project
4216
+ }
4217
+ return rb .Project + "@" + rb .Builder
4218
+ }
4219
+
4220
+ // xReposFromComments looks at the TRY= comments from Gerrit (in work) and
4221
+ // returns any additional subrepos that should be tested. The TRY= comments
4222
+ // are expected to be of the format TRY=x/foo or TRY=x/foo@builder where foo is
4223
+ // the name of the subrepo and builder is a builder name. If no builder is
4224
+ // provided, a default builder is used.
4225
+ func xReposFromComments (work * apipb.GerritTryWorkItem ) map [xRepoAndBuilder ]bool {
4226
+ xrepos := make (map [xRepoAndBuilder ]bool )
4202
4227
for _ , term := range latestTryTerms (work ) {
4203
4228
if len (term ) < len ("x/_" ) || term [:2 ] != "x/" {
4204
4229
continue
4205
4230
}
4206
- xrepo := term [2 :]
4207
- xrepos [xrepo ] = true
4231
+ parts := strings .SplitN (term , "@" , 2 )
4232
+ xrepo := parts [0 ][2 :]
4233
+ builder := "" // By convention, this means the default builder.
4234
+ if len (parts ) > 1 {
4235
+ builder = parts [1 ]
4236
+ }
4237
+ xrepos [xRepoAndBuilder {
4238
+ Project : xrepo ,
4239
+ Builder : builder ,
4240
+ }] = true
4208
4241
}
4209
4242
return xrepos
4210
4243
}
@@ -4219,7 +4252,7 @@ func latestTryTerms(work *apipb.GerritTryWorkItem) []string {
4219
4252
return nil
4220
4253
}
4221
4254
return strings .FieldsFunc (tryMsg , func (c rune ) bool {
4222
- return ! unicode .IsLetter (c ) && ! unicode .IsNumber (c ) && c != '-' && c != '_' && c != '/'
4255
+ return ! unicode .IsLetter (c ) && ! unicode .IsNumber (c ) && c != '-' && c != '_' && c != '/' && c != '@'
4223
4256
})
4224
4257
}
4225
4258
0 commit comments