Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7881)

Unified Diff: ct/go/worker_scripts/build_repo/main.go

Issue 1991043005: Add support for parallel runs (Closed) Base URL: https://skia.googlesource.com/buildbot@ct-8-chromium_analysis
Patch Set: Rebase Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ct/go/util/util.go ('k') | ct/go/worker_scripts/capture_skps_from_pdfs/main.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ct/go/worker_scripts/build_repo/main.go
diff --git a/ct/go/worker_scripts/build_repo/main.go b/ct/go/worker_scripts/build_repo/main.go
new file mode 100644
index 0000000000000000000000000000000000000000..d798e92b15569de9372d04189974599f55fc5908
--- /dev/null
+++ b/ct/go/worker_scripts/build_repo/main.go
@@ -0,0 +1,127 @@
+// Application that builds the specified repo and stores output to Google Storage.
+package main
+
+import (
+ "bytes"
+ "flag"
+ "fmt"
+ "io/ioutil"
+ "os"
+ "path"
+ "path/filepath"
+ "strings"
+ "time"
+
+ "github.com/skia-dev/glog"
+
+ "go.skia.org/infra/ct/go/util"
+ "go.skia.org/infra/ct/go/worker_scripts/worker_common"
+ "go.skia.org/infra/go/common"
+ skutil "go.skia.org/infra/go/util"
+)
+
+var (
+ runID = flag.String("run_id", "", "The unique run id (typically requester + timestamp).")
+ repoName = flag.String("repo", "chromium", "The name of the repo this script should build and store in Google Storage.")
+ hashes = flag.String("hashes", "", "Comma separated list of hashes to checkout the specified repos to. Optional.")
+ patches = flag.String("patches", "", "Comma separated names of patches to apply to the specified repo. Optional.")
+ uploadSingleBuild = flag.Bool("single_build", true, "Whether only a single build should be created and uploaded to Google Storage.")
+ targetPlatform = flag.String("target_platform", util.PLATFORM_LINUX, "The platform we want to build the specified repo for.")
+ outDir = flag.String("out", "", "The out directory where hashes will be stored.")
+)
+
+func main() {
+ defer common.LogPanic()
+ worker_common.Init()
+ defer util.TimeTrack(time.Now(), "Building Repo")
+ defer glog.Flush()
+
+ if *runID == "" {
+ glog.Error("Must specify --run_id")
+ return
+ }
+ if *outDir == "" {
+ glog.Error("Must specify --out")
+ return
+ }
+
+ // Instantiate GsUtil object.
+ gs, err := util.NewGsUtil(nil)
+ if err != nil {
+ glog.Error(err)
+ return
+ }
+
+ var remoteDirs []string
+ if *repoName == "chromium" {
+ if *patches != "" {
+ for _, patch := range strings.Split(*patches, ",") {
+ patchName := path.Base(patch)
+ patchLocalPath := filepath.Join(os.TempDir(), patchName)
+ fmt.Println(patchLocalPath)
+ respBody, err := gs.GetRemoteFileContents(patch)
+ if err != nil {
+ glog.Errorf("Could not fetch %s: %s", patch, err)
+ return
+ }
+ defer skutil.Close(respBody)
+ buf := new(bytes.Buffer)
+ if _, err := buf.ReadFrom(respBody); err != nil {
+ glog.Errorf("Could not read from %s: %s", patch, err)
+ return
+ }
+ if err := ioutil.WriteFile(patchLocalPath, buf.Bytes(), 0666); err != nil {
+ glog.Errorf("Unable to create file %s: %s", patchLocalPath, err)
+ return
+ }
+ }
+ }
+ pathToPyFiles := util.GetPathToPyFiles(!*worker_common.Local)
+ chromiumHash, skiaHash, err := util.CreateChromiumBuildOnSwarming(*runID, *targetPlatform, "", "", pathToPyFiles, true, *uploadSingleBuild)
+ if err != nil {
+ glog.Errorf("Could not create chromium build: %s", err)
+ return
+ }
+
+ if !*uploadSingleBuild {
+ remoteDirs = append(remoteDirs, fmt.Sprintf("try-%s-%s-%s-nopatch", chromiumHash, skiaHash, *runID))
+ }
+ remoteDirs = append(remoteDirs, fmt.Sprintf("try-%s-%s-%s-withpatch", chromiumHash, skiaHash, *runID))
+ } else if *repoName == "pdfium" {
+ // Sync PDFium and build pdfium_test binary.
+ if err := util.SyncDir(util.PDFiumTreeDir); err != nil {
+ glog.Errorf("Could not sync PDFium: %s", err)
+ return
+ }
+ if err := util.BuildPDFium(); err != nil {
+ glog.Errorf("Could not build PDFium: %s", err)
+ return
+ }
+ // Copy pdfium_test to Google Storage.
+ pdfiumLocalDir := path.Join(util.PDFiumTreeDir, "out", "Debug")
+ pdfiumRemoteDir := path.Join(util.BINARIES_DIR_NAME, *runID)
+ // Instantiate GsUtil object.
+ gs, err := util.NewGsUtil(nil)
+ if err != nil {
+ glog.Error(err)
+ return
+ }
+ if err := gs.UploadFile(util.BINARY_PDFIUM_TEST, pdfiumLocalDir, pdfiumRemoteDir); err != nil {
+ glog.Errorf("Could not upload %s to %s: %s", util.BINARY_PDFIUM_TEST, pdfiumRemoteDir, err)
+ return
+ }
+ remoteDirs = append(remoteDirs, *runID)
+ }
+
+ // Record the remote dirs in the output file.
+ buildDirsOutputFile := filepath.Join(*outDir, util.BUILD_OUTPUT_FILENAME)
+ f, err := os.Create(buildDirsOutputFile)
+ if err != nil {
+ glog.Errorf("Could not create %s: %s", buildDirsOutputFile, err)
+ return
+ }
+ defer f.Close()
+ if _, err := f.WriteString(strings.Join(remoteDirs, ",")); err != nil {
+ glog.Errorf("Could not write to %s: %s", buildDirsOutputFile, err)
+ }
+}
« no previous file with comments | « ct/go/util/util.go ('k') | ct/go/worker_scripts/capture_skps_from_pdfs/main.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698