@@ -24,38 +24,36 @@ import (
24
24
"strings"
25
25
26
26
"github.com/golang/protobuf/proto"
27
+ "k8s.io/test-infra/prow/jobs"
27
28
config "k8s.io/test-infra/testgrid/config/pb"
28
29
"k8s.io/test-infra/testgrid/config/yaml2proto"
29
30
)
30
31
31
- //
32
- // usage: go run jenkins_validate.go <path/to/job_collection> <path/to/testgrid_config>
33
- //
34
-
35
32
func main () {
36
33
args := os .Args [1 :]
37
34
38
- if len (args ) != 2 {
39
- fmt .Println ("Missing args - usage: go run jenkins_validate.go <path/to/job_collection> <path/to/testgrid_config>" )
35
+ if len (args ) != 3 {
36
+ fmt .Println ("Missing args - usage: go run jenkins_validate.go <path/to/job_collection> <path/to/prow> <path/to/ testgrid_config>" )
40
37
os .Exit (1 )
41
38
}
42
39
43
- jobpath := args [0 ]
44
- configpath := args [1 ]
40
+ jobPath := args [0 ]
41
+ prowPath := args [1 ]
42
+ configPath := args [2 ]
45
43
46
44
jenkinsjobs := make (map [string ]bool )
47
- files , err := filepath .Glob (jobpath + "/*" )
45
+ files , err := filepath .Glob (jobPath + "/*" )
48
46
if err != nil {
49
47
fmt .Println ("Failed to collect outputs." )
50
48
os .Exit (1 )
51
49
}
52
50
53
51
for _ , file := range files {
54
- file = strings .TrimPrefix (file , jobpath + "/" )
52
+ file = strings .TrimPrefix (file , jobPath + "/" )
55
53
jenkinsjobs [file ] = false
56
54
}
57
55
58
- data , err := ioutil .ReadFile (configpath )
56
+ data , err := ioutil .ReadFile (configPath )
59
57
protobufData , err := yaml2proto .Yaml2Proto (data )
60
58
61
59
config := & config.Configuration {}
@@ -64,6 +62,12 @@ func main() {
64
62
os .Exit (1 )
65
63
}
66
64
65
+ ja := jobs.JobAgent {}
66
+ if err := ja .LoadOnce (prowPath + "/presubmit.yaml" , prowPath + "/postsubmit.yaml" ); err != nil {
67
+ fmt .Printf ("Could not load prow configs: %v\n " , err )
68
+ os .Exit (1 )
69
+ }
70
+
67
71
// For now anything outsite k8s-jenkins/logs are considered to be fine
68
72
testgroups := make (map [string ]bool )
69
73
for _ , testgroup := range config .TestGroups {
@@ -82,20 +86,29 @@ func main() {
82
86
}
83
87
}
84
88
89
+ // Also check prow jobs
90
+ // TODO(spxtr): Not just k/k
91
+ for _ , job := range ja .AllPostsubmits ("kubernetes/kubernetes" ) {
92
+ if _ , ok := testgroups [job .Name ]; ok {
93
+ testgroups [job .Name ] = true
94
+ jenkinsjobs [job .Name ] = true
95
+ }
96
+ }
97
+
85
98
// Conclusion
86
99
badjobs := []string {}
87
100
for jenkinsjob , valid := range jenkinsjobs {
88
101
if ! valid {
89
102
badjobs = append (badjobs , jenkinsjob )
90
- fmt .Printf ("Jenkins Job %v does not have a matching testgrid testgroup\n " , jenkinsjob )
103
+ fmt .Printf ("Job %v does not have a matching testgrid testgroup\n " , jenkinsjob )
91
104
}
92
105
}
93
106
94
107
badconfigs := []string {}
95
108
for testgroup , valid := range testgroups {
96
109
if ! valid {
97
110
badconfigs = append (badconfigs , testgroup )
98
- fmt .Printf ("Testgrid group %v does not have a matching jenkins job\n " , testgroup )
111
+ fmt .Printf ("Testgrid group %v does not have a matching jenkins or prow job\n " , testgroup )
99
112
}
100
113
}
101
114
0 commit comments