forked from knative/test-infra
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpostsubmit_config.go
58 lines (48 loc) · 2.17 KB
/
postsubmit_config.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/*
Copyright 2019 The Knative Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package main
import (
"fmt"
"strings"
"gopkg.in/yaml.v2"
)
const (
// goCoveragePostsubmitJob is the template for the go postsubmit coverage job.
goCoveragePostsubmitJob = "prow_postsubmit_gocoverage_job.yaml"
// perfPostsubmitJob is the template for the performance operations
// postsubmit job.
perfPostsubmitJob = "prow_postsubmit_perf_job.yaml"
)
// postsubmitJobTemplateData contains data about a postsubmit Prow job.
type postsubmitJobTemplateData struct {
Base baseProwJobTemplateData
PostsubmitJobName string
PostsubmitCommand []string
}
// generateGoCoveragePostsubmit generates the go coverage postsubmit job config for the given repo.
func generateGoCoveragePostsubmit(title, repoName string, _ yaml.MapSlice) {
var data postsubmitJobTemplateData
data.Base = newbaseProwJobTemplateData(repoName)
data.PostsubmitJobName = fmt.Sprintf("post-%s-go-coverage", data.Base.RepoNameForJob)
addExtraEnvVarsToJob(extraEnvVars, &data.Base)
configureServiceAccountForJob(&data.Base)
jobName := data.PostsubmitJobName
executeJobTemplate("postsubmit go coverage", readTemplate(goCoveragePostsubmitJob), title, repoName, jobName, true, data)
// Generate config for post-knative-serving-go-coverage-dev right after post-knative-serving-go-coverage,
// this job is mainly for debugging purpose.
if data.PostsubmitJobName == "post-knative-serving-go-coverage" {
data.PostsubmitJobName += "-dev"
data.Base.Image = strings.ReplaceAll(data.Base.Image, ":stable", ":coverage-dev")
executeJobTemplate("postsubmit go coverage", readTemplate(goCoveragePostsubmitJob), title, repoName, data.PostsubmitJobName, false, data)
}
}