From 3f86dfedab01e62e34121865cebb1ce1efcfea0d Mon Sep 17 00:00:00 2001 From: Taras Madan Date: Thu, 25 Jul 2024 15:20:28 +0200 Subject: dashboard/app: add init scripts for batch processing --- dashboard/app/config.go | 2 ++ dashboard/app/coverage_batch.go | 20 +++++++++++++------- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/dashboard/app/config.go b/dashboard/app/config.go index 36e06fc98..5f4461f91 100644 --- a/dashboard/app/config.go +++ b/dashboard/app/config.go @@ -129,6 +129,8 @@ type CoverageConfig struct { BatchProject string BatchServiceAccount string BatchScopes []string + JobInitScript string + SyzEnvInitScript string } // DiscussionEmailConfig defines the correspondence between an email and a DiscussionSource. diff --git a/dashboard/app/coverage_batch.go b/dashboard/app/coverage_batch.go index 1e87ef127..8a88efa80 100644 --- a/dashboard/app/coverage_batch.go +++ b/dashboard/app/coverage_batch.go @@ -50,22 +50,28 @@ func handleBatchCoverage(w http.ResponseWriter, r *http.Request) { log.Infof(ctx, "there is no new coverage for merging available in %s", ns) continue } + nsCovConfig := nsConfig.Coverage if err := createScriptJob( ctx, - nsConfig.Coverage.BatchProject, - nsConfig.Coverage.BatchServiceAccount, - batchScript(ns, repo, branch, 7, dates), - nsConfig.Coverage.BatchScopes); err != nil { - log.Errorf(ctx, "failed to batchScript(): %s", err.Error()) + nsCovConfig.BatchProject, + nsCovConfig.BatchServiceAccount, + batchScript(ns, repo, branch, 7, dates, nsCovConfig.JobInitScript, nsCovConfig.SyzEnvInitScript), + nsCovConfig.BatchScopes); err != nil { + log.Errorf(ctx, "failed to batchScript: %s", err.Error()) } } } -func batchScript(ns, repo, branch string, days int, datesTo []civil.Date) string { - script := "git clone --depth 1 --branch master --single-branch https://github.com/google/syzkaller\n" + +func batchScript(ns, repo, branch string, days int, datesTo []civil.Date, + jobInitScript, syzEnvInitScript string) string { + script := jobInitScript + "\n" + script += "git clone --depth 1 --branch master --single-branch https://github.com/google/syzkaller\n" + "cd syzkaller\n" + "export CI=1\n" + "./tools/syz-env \"" + if syzEnvInitScript != "" { + script += syzEnvInitScript + "; " + } for _, dateTo := range datesTo { script += "./tools/syz-bq.sh" + " -w ../workdir-cover-aggregation/" + -- cgit mrf-deployment