Skip to content

Commit

Permalink
Add 17: open_bug_template to config.proto
Browse files Browse the repository at this point in the history
Used to identify the source repository when linking bugs to issues
  • Loading branch information
chases2 committed Aug 22, 2019
1 parent aee5919 commit 69e3923
Show file tree
Hide file tree
Showing 6 changed files with 88 additions and 34 deletions.
4 changes: 3 additions & 1 deletion config/testgrids/default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,11 @@ default_dashboard_tab:
value: 'E2E: <test-name>'
- key: body
value: <test-url>
attach_bug_template: # The URL template to visit when attaching a bug
attach_bug_template: # The URL template to visit when attaching to an existing bug
url: # empty
options: #empty
open_bug_template: # The URL template to visit when visiting an associated bug
url: https://github.com/kubernetes/kubernetes/issues/
results_text: See these results on Prow # Text to show in the about menu as a link to another view of the results
results_url_template: # The URL template to visit after clicking
url: https://prow.k8s.io/job-history/<gcs_prefix>
Expand Down
10 changes: 7 additions & 3 deletions testgrid/cmd/configurator/prow.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,17 +138,21 @@ func applySingleProwjobAnnotations(c *Config, pc *prowConfig.Config, j prowConfi
repo = fmt.Sprintf("%s/%s", j.ExtraRefs[0].Org, j.ExtraRefs[0].Repo)
}
}
var linkTemplate *config.LinkTemplate
var codeSearchLinkTemplate, openBugLinkTemplate *config.LinkTemplate
if repo != "" {
linkTemplate = &config.LinkTemplate{
codeSearchLinkTemplate = &config.LinkTemplate{
Url: fmt.Sprintf("https://github.com/%s/compare/<start-custom-0>...<end-custom-0>", repo),
}
openBugLinkTemplate = &config.LinkTemplate{
Url: fmt.Sprintf("https://github.com/%s/issues/", repo),
}
}
dt := &config.DashboardTab{
Name: tabName,
TestGroupName: testGroupName,
Description: description,
CodeSearchUrlTemplate: linkTemplate,
CodeSearchUrlTemplate: codeSearchLinkTemplate,
OpenBugTemplate: openBugLinkTemplate,
}
if firstDashboard {
firstDashboard = false
Expand Down
39 changes: 35 additions & 4 deletions testgrid/cmd/configurator/prow_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (

const ProwDefaultGCSPath = "pathPrefix/"
const ProwJobName = "TestJob"
const ExampleRepository = "test/repo"

func Test_applySingleProwjobAnnotations(t *testing.T) {
tests := []struct {
Expand Down Expand Up @@ -134,6 +135,9 @@ func Test_applySingleProwjobAnnotations(t *testing.T) {
CodeSearchUrlTemplate: &config.LinkTemplate{
Url: "https://github.com/test/repo/compare/<start-custom-0>...<end-custom-0>",
},
OpenBugTemplate: &config.LinkTemplate{
Url: "https://github.com/test/repo/issues/",
},
},
},
},
Expand Down Expand Up @@ -178,6 +182,9 @@ func Test_applySingleProwjobAnnotations(t *testing.T) {
CodeSearchUrlTemplate: &config.LinkTemplate{
Url: "https://github.com/test/repo/compare/<start-custom-0>...<end-custom-0>",
},
OpenBugTemplate: &config.LinkTemplate{
Url: "https://github.com/test/repo/issues/",
},
AlertOptions: &config.DashboardTabAlertOptions{
AlertMailToAddresses: "[email protected]",
},
Expand All @@ -194,6 +201,9 @@ func Test_applySingleProwjobAnnotations(t *testing.T) {
CodeSearchUrlTemplate: &config.LinkTemplate{
Url: "https://github.com/test/repo/compare/<start-custom-0>...<end-custom-0>",
},
OpenBugTemplate: &config.LinkTemplate{
Url: "https://github.com/test/repo/issues/",
},
},
},
},
Expand Down Expand Up @@ -249,6 +259,9 @@ func Test_applySingleProwjobAnnotations(t *testing.T) {
CodeSearchUrlTemplate: &config.LinkTemplate{
Url: "https://github.com/test/repo/compare/<start-custom-0>...<end-custom-0>",
},
OpenBugTemplate: &config.LinkTemplate{
Url: "https://github.com/test/repo/issues/",
},
},
},
},
Expand Down Expand Up @@ -296,6 +309,9 @@ func Test_applySingleProwjobAnnotations(t *testing.T) {
CodeSearchUrlTemplate: &config.LinkTemplate{
Url: "https://github.com/test/repo/compare/<start-custom-0>...<end-custom-0>",
},
OpenBugTemplate: &config.LinkTemplate{
Url: "https://github.com/test/repo/issues/",
},
},
},
},
Expand All @@ -320,7 +336,7 @@ func Test_applySingleProwjobAnnotations(t *testing.T) {
Annotations: test.annotations,
}

err := applySingleProwjobAnnotations(result, fakeProwConfig(), job, test.prowJobType, "test/repo")
err := applySingleProwjobAnnotations(result, fakeProwConfig(), job, test.prowJobType, ExampleRepository)

if test.expectedConfig == nil {
if err == nil {
Expand All @@ -343,8 +359,8 @@ func Test_applySingleProwjobAnnotation_WithDefaults(t *testing.T) {

defaultConfig := &config.DefaultConfiguration{
DefaultTestGroup: &config.TestGroup{
GcsPrefix: "originalConfigPrefix", //Overwritten
DaysOfResults: 5, //Kept
GcsPrefix: "originalConfigPrefix", //Default is Overwritten
DaysOfResults: 5, //Default is Kept
NumColumnsRecent: 10, //Sometimes Overwritten; see test
},
DefaultDashboardTab: &config.DashboardTab{
Expand All @@ -354,6 +370,12 @@ func Test_applySingleProwjobAnnotation_WithDefaults(t *testing.T) {
AlertOptions: &config.DashboardTabAlertOptions{
AlertMailToAddresses: "[email protected]", //Kept; see test
},
CodeSearchUrlTemplate: &config.LinkTemplate{ //Overwritten
Url: "https://example.com/code_search",
},
OpenBugTemplate: &config.LinkTemplate{ //Overwritten
Url: "https://example.com/open_bug",
},
},
}

Expand Down Expand Up @@ -438,6 +460,9 @@ func Test_applySingleProwjobAnnotation_WithDefaults(t *testing.T) {
CodeSearchUrlTemplate: &config.LinkTemplate{
Url: "https://github.com/test/repo/compare/<start-custom-0>...<end-custom-0>",
},
OpenBugTemplate: &config.LinkTemplate{
Url: "https://github.com/test/repo/issues/",
},
AlertOptions: &config.DashboardTabAlertOptions{
AlertMailToAddresses: "[email protected]",
},
Expand Down Expand Up @@ -483,6 +508,9 @@ func Test_applySingleProwjobAnnotation_WithDefaults(t *testing.T) {
CodeSearchUrlTemplate: &config.LinkTemplate{
Url: "https://github.com/test/repo/compare/<start-custom-0>...<end-custom-0>",
},
OpenBugTemplate: &config.LinkTemplate{
Url: "https://github.com/test/repo/issues/",
},
AlertOptions: &config.DashboardTabAlertOptions{
AlertMailToAddresses: "[email protected]",
},
Expand All @@ -500,6 +528,9 @@ func Test_applySingleProwjobAnnotation_WithDefaults(t *testing.T) {
CodeSearchUrlTemplate: &config.LinkTemplate{
Url: "https://github.com/test/repo/compare/<start-custom-0>...<end-custom-0>",
},
OpenBugTemplate: &config.LinkTemplate{
Url: "https://github.com/test/repo/issues/",
},
AlertOptions: &config.DashboardTabAlertOptions{
AlertMailToAddresses: "[email protected]",
},
Expand Down Expand Up @@ -528,7 +559,7 @@ func Test_applySingleProwjobAnnotation_WithDefaults(t *testing.T) {
Annotations: test.annotations,
}

err := applySingleProwjobAnnotations(result, fakeProwConfig(), job, test.prowJobType, "test/repo")
err := applySingleProwjobAnnotations(result, fakeProwConfig(), job, test.prowJobType, ExampleRepository)

if test.expectedConfig == nil {
if err == nil {
Expand Down
4 changes: 4 additions & 0 deletions testgrid/cmd/configurator/yaml2proto.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,10 @@ func ReconcileDashboardTab(currentTab *config.DashboardTab, defaultTab *config.D
if currentTab.AlertOptions == nil {
currentTab.AlertOptions = defaultTab.AlertOptions
}

if currentTab.OpenBugTemplate == nil {
currentTab.OpenBugTemplate = defaultTab.OpenBugTemplate
}
}

// UpdateDefaults reads any default configuration from yamlData and updates the
Expand Down
60 changes: 35 additions & 25 deletions testgrid/config/config.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion testgrid/config/config.proto
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ message LinkOptionsTemplate {

// A single tab on a dashboard.
message DashboardTab {
reserved 14;
reserved 14, 16;

// The name of the dashboard tab to display in the client.
string name = 1;
Expand Down Expand Up @@ -215,6 +215,9 @@ message DashboardTab {

// Configuration options for dashboard tab alerts.
DashboardTabAlertOptions alert_options = 15;

// The URL template to visit when viewing an associated bug.
LinkTemplate open_bug_template = 17;
}

// Configuration options for dashboard tab alerts.
Expand Down

0 comments on commit 69e3923

Please sign in to comment.