aboutsummaryrefslogtreecommitdiffstats
path: root/syz-cluster/workflow/build-step
diff options
context:
space:
mode:
authorAleksandr Nogikh <nogikh@google.com>2025-02-17 18:15:34 +0100
committerAleksandr Nogikh <nogikh@google.com>2025-02-18 14:23:32 +0000
commitd20955ead8fad68c995174fadc471c56147a69a5 (patch)
tree1a38d6929fe89a03232a1923a56b36f4adb153a6 /syz-cluster/workflow/build-step
parentec05e4c30271d38daa3a17bae6cafe5a7477c943 (diff)
syz-cluster: build latest revisions of base kernels
Once a new kernel revision becomes available, build it to figure out whether it's buildable. This information will be used in the triage step to figure out the right base kernel revision.
Diffstat (limited to 'syz-cluster/workflow/build-step')
-rw-r--r--syz-cluster/workflow/build-step/main.go43
-rw-r--r--syz-cluster/workflow/build-step/workflow-template.yaml13
2 files changed, 48 insertions, 8 deletions
diff --git a/syz-cluster/workflow/build-step/main.go b/syz-cluster/workflow/build-step/main.go
index aac78de00..ad84cd380 100644
--- a/syz-cluster/workflow/build-step/main.go
+++ b/syz-cluster/workflow/build-step/main.go
@@ -31,15 +31,20 @@ var (
flagTestName = flag.String("test_name", "", "test name")
flagSession = flag.String("session", "", "session ID")
flagFindings = flag.Bool("findings", false, "report build failures as findings")
+ flagSmokeBuild = flag.Bool("smoke_build", false, "build only if new, don't report findings")
)
func main() {
flag.Parse()
ensureFlags(*flagRequest, "--request",
*flagRepository, "--repository",
- *flagOutput, "--output",
- *flagSession, "--session",
- *flagTestName, "--test_name")
+ *flagOutput, "--output")
+ if !*flagSmokeBuild {
+ ensureFlags(
+ *flagTestName, "--test_name",
+ *flagSession, "--session",
+ )
+ }
req := readRequest()
ctx := context.Background()
@@ -55,23 +60,32 @@ func main() {
}
uploadReq := &api.UploadBuildReq{
Build: api.Build{
+ Arch: req.Arch,
+ ConfigName: req.ConfigName,
TreeName: req.TreeName,
- CommitHash: req.CommitHash,
SeriesID: req.SeriesID,
},
}
-
output := new(bytes.Buffer)
tracer := &debugtracer.GenericTracer{
WithTime: false,
TraceWriter: output,
OutDir: "",
}
-
commit, err := checkoutKernel(tracer, req, series)
if commit != nil {
+ uploadReq.CommitHash = commit.Hash
uploadReq.CommitDate = commit.CommitDate
}
+ if *flagSmokeBuild {
+ skip, err := alreadyBuilt(ctx, client, uploadReq)
+ if err != nil {
+ app.Fatalf("failed to query known builds: %v", err)
+ } else if skip {
+ log.Printf("%s already built, skipping", uploadReq.CommitHash)
+ return
+ }
+ }
var finding *api.NewFinding
if err != nil {
log.Printf("failed to checkout: %v", err)
@@ -107,6 +121,9 @@ func reportResults(ctx context.Context, client *api.Client, patched bool,
BuildID: buildInfo.ID,
Success: uploadReq.BuildSuccess,
})
+ if *flagSmokeBuild {
+ return
+ }
testResult := &api.TestResult{
SessionID: *flagSession,
TestName: *flagTestName,
@@ -133,6 +150,20 @@ func reportResults(ctx context.Context, client *api.Client, patched bool,
}
}
+func alreadyBuilt(ctx context.Context, client *api.Client,
+ req *api.UploadBuildReq) (bool, error) {
+ build, err := client.LastBuild(ctx, &api.LastBuildReq{
+ Arch: req.Build.Arch,
+ ConfigName: req.Build.ConfigName,
+ TreeName: req.Build.TreeName,
+ Commit: req.CommitHash,
+ })
+ if err != nil {
+ return false, err
+ }
+ return build != nil, nil
+}
+
func readRequest() *api.BuildRequest {
raw, err := os.ReadFile(*flagRequest)
if err != nil {
diff --git a/syz-cluster/workflow/build-step/workflow-template.yaml b/syz-cluster/workflow/build-step/workflow-template.yaml
index 9b45ae55e..0a3282ae8 100644
--- a/syz-cluster/workflow/build-step/workflow-template.yaml
+++ b/syz-cluster/workflow/build-step/workflow-template.yaml
@@ -13,6 +13,12 @@ spec:
- name: findings
value: "false"
- name: test-name
+ value: ""
+ - name: smoke-build
+ value: "false"
+ # For some reason, "{{=workflow.parameters.session-id ?? ''}}" didn't work here.
+ - name: session-id
+ value: ""
artifacts:
- name: request
path: /tmp/request.json
@@ -53,9 +59,10 @@ spec:
"--request", "/tmp/request.json",
"--repository", "/workdir",
"--output", "/output",
- "--session", "{{workflow.parameters.session-id}}",
+ "--session", "{{inputs.parameters.session-id}}",
"--test_name", "{{inputs.parameters.test-name}}",
- "-findings={{inputs.parameters.findings}}"
+ "-findings={{inputs.parameters.findings}}",
+ "-smoke_build={{inputs.parameters.smoke-build}}"
]
resources:
requests:
@@ -103,6 +110,8 @@ spec:
- name: result
valueFrom:
path: /output/result.json
+ default: ""
artifacts:
- name: kernel
path: /output
+ optional: true