Skip to content

Commit

Permalink
quick-verifier: Download bazel before running other commands
Browse files Browse the repository at this point in the history
Concurrent bazelisk invocations may race their bazel
downloads and fail. Run "bazel version" to ensure
bazel is downloaded before starting other bulid steps.

FIXED=b:370667153
TEST=check cop logs and verify bazel download is only attempted once

Change-Id: I43478118977d762b0b6e8e2cbcf4eec7185059ab
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/adhd/+/5899101
Reviewed-by: Hung-Hsien Chen <hunghsienchen@chromium.org>
Commit-Queue: Li-Yu Yu <aaronyu@google.com>
Tested-by: chromeos-cop-builder@chromeos-cop.iam.gserviceaccount.com <chromeos-cop-builder@chromeos-cop.iam.gserviceaccount.com>
Auto-Submit: Li-Yu Yu <aaronyu@google.com>
Tested-by: Li-Yu Yu <aaronyu@google.com>
Commit-Queue: Hung-Hsien Chen <hunghsienchen@chromium.org>
  • Loading branch information
afq984 authored and Chromeos LUCI committed Oct 1, 2024
1 parent 1ad06aa commit 4c1f967
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 20 deletions.
40 changes: 30 additions & 10 deletions .cop/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,26 @@
],
"entrypoint": "find"
},
{
"name": "gcr.io/${PROJECT_ID}/adhd-archlinux-builder",
"args": [
"version"
],
"id": "ensure-bazel:0",
"entrypoint": "bazel"
},
{
"name": "gcr.io/${PROJECT_ID}/adhd-archlinux-builder",
"args": [
"setup complete"
],
"id": "setup-complete:0",
"waitFor": [
"prepare-source:1",
"ensure-bazel:0"
],
"entrypoint": "echo"
},
{
"name": "gcr.io/${PROJECT_ID}/adhd-archlinux-builder",
"args": [
Expand All @@ -41,7 +61,7 @@
"dir": "/workspace-copgen-check",
"id": "copgen-check:0",
"waitFor": [
"prepare-source:1"
"setup-complete:0"
],
"entrypoint": "rsync",
"volumes": [
Expand Down Expand Up @@ -79,7 +99,7 @@
"dir": "/workspace-rust_generate",
"id": "rust_generate:0",
"waitFor": [
"prepare-source:1"
"setup-complete:0"
],
"entrypoint": "rsync",
"volumes": [
Expand Down Expand Up @@ -133,7 +153,7 @@
"dir": "/workspace-archlinux-clang",
"id": "archlinux-clang:0",
"waitFor": [
"prepare-source:1"
"setup-complete:0"
],
"entrypoint": "rsync",
"volumes": [
Expand Down Expand Up @@ -176,7 +196,7 @@
"dir": "/workspace-archlinux-clang-asan",
"id": "archlinux-clang-asan:0",
"waitFor": [
"prepare-source:1"
"setup-complete:0"
],
"entrypoint": "rsync",
"volumes": [
Expand Down Expand Up @@ -220,7 +240,7 @@
"dir": "/workspace-archlinux-clang-ubsan",
"id": "archlinux-clang-ubsan:0",
"waitFor": [
"prepare-source:1"
"setup-complete:0"
],
"entrypoint": "rsync",
"volumes": [
Expand Down Expand Up @@ -264,7 +284,7 @@
"dir": "/workspace-archlinux-gcc",
"id": "archlinux-gcc:0",
"waitFor": [
"prepare-source:1"
"setup-complete:0"
],
"entrypoint": "rsync",
"volumes": [
Expand Down Expand Up @@ -308,7 +328,7 @@
"dir": "/workspace-archlinux-system-cras-rust",
"id": "archlinux-system-cras-rust:0",
"waitFor": [
"prepare-source:1"
"setup-complete:0"
],
"entrypoint": "rsync",
"volumes": [
Expand Down Expand Up @@ -410,7 +430,7 @@
"dir": "/workspace-kythe",
"id": "kythe:0",
"waitFor": [
"prepare-source:1"
"setup-complete:0"
],
"entrypoint": "rsync",
"volumes": [
Expand Down Expand Up @@ -446,7 +466,7 @@
],
"id": "oss-fuzz-setup:0",
"waitFor": [
"prepare-source:1"
"setup-complete:0"
],
"entrypoint": "mkdir"
},
Expand Down Expand Up @@ -653,7 +673,7 @@
"dir": "/workspace-cppcheck",
"id": "cppcheck:0",
"waitFor": [
"prepare-source:1"
"setup-complete:0"
],
"entrypoint": "rsync",
"volumes": [
Expand Down
38 changes: 28 additions & 10 deletions devtools/quick-verifier/build/build_steps.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,20 @@ func (cl *gerritCL) makeQuickVerifierBuild(name string) *cloudbuildpb.Build {
func makeBuild(gitSteps *buildplan.Sequence, tags []string) *cloudbuildpb.Build {
var b buildplan.Build
git := b.Add(gitSteps)
ensureBazel := b.Add(ensureBazelSteps())
setup := b.Add(setupCompleteMarkerSteps().WithDep(git).WithDep(ensureBazel))

b.Add(copgenCheckSteps().WithDep(git))
b.Add(rustGenerateSteps().WithDep(git))
b.Add(copgenCheckSteps().WithDep(setup))
b.Add(rustGenerateSteps().WithDep(setup))

b.Add(archlinuxSteps("archlinux-clang", "--config=local-clang").WithDep(git))
b.Add(archlinuxSteps("archlinux-clang-asan", "--config=local-clang", "--config=asan").WithDep(git))
b.Add(archlinuxSteps("archlinux-clang-ubsan", "--config=local-clang", "--config=ubsan").WithDep(git))
b.Add(archlinuxSteps("archlinux-gcc", "--config=local-gcc", "--config=gcc-strict").WithDep(git))
b.Add(systemCrasRustSteps().WithDep(git))
b.Add(kytheSteps().WithDep(git))
b.Add(archlinuxSteps("archlinux-clang", "--config=local-clang").WithDep(setup))
b.Add(archlinuxSteps("archlinux-clang-asan", "--config=local-clang", "--config=asan").WithDep(setup))
b.Add(archlinuxSteps("archlinux-clang-ubsan", "--config=local-clang", "--config=ubsan").WithDep(setup))
b.Add(archlinuxSteps("archlinux-gcc", "--config=local-gcc", "--config=gcc-strict").WithDep(setup))
b.Add(systemCrasRustSteps().WithDep(setup))
b.Add(kytheSteps().WithDep(setup))

ossFuzzSetup := b.Add(ossFuzzSetupSteps().WithDep(git))
ossFuzzSetup := b.Add(ossFuzzSetupSteps().WithDep(setup))
b.Add(ossFuzzSteps("oss-fuzz-address", "address", "libfuzzer").WithDep(ossFuzzSetup))
b.Add(ossFuzzSteps("oss-fuzz-address-afl", "address", "afl").WithDep(ossFuzzSetup))
// MSan removed in https://github.com/google/oss-fuzz/pull/11938.
Expand All @@ -38,7 +40,7 @@ func makeBuild(gitSteps *buildplan.Sequence, tags []string) *cloudbuildpb.Build
// TODO(b/325995661): Figure out why it's broken.
// b.Add(ossFuzzSteps("oss-fuzz-coverage", "coverage", "libfuzzer").WithDep(ossFuzzSetup))

b.Add(cppcheckSteps().WithDep(git))
b.Add(cppcheckSteps().WithDep(setup))

return &cloudbuildpb.Build{
Steps: b.AsCloudBuild(),
Expand Down Expand Up @@ -100,6 +102,22 @@ func MakeCopBuild() *cloudbuildpb.Build {
)
}

func ensureBazelSteps() *buildplan.Sequence {
return buildplan.Commands(
"ensure-bazel",
// Run bazel once to ensure bazel is available and to avoid
// races between bazelisk downloading bazel from multiple invocations.
buildplan.Command(archlinuxBuilder, "bazel", "version"),
).WithManualIsolation()
}

func setupCompleteMarkerSteps() *buildplan.Sequence {
return buildplan.Commands(
"setup-complete",
buildplan.Command(archlinuxBuilder, "echo", "setup complete"),
).WithManualIsolation()
}

var prepareSourceStep = buildplan.Command(archlinuxBuilder, "rsync", "-ah", "/workspace/adhd/", "./")

func archlinuxSteps(id string, bazelArgs ...string) *buildplan.Sequence {
Expand Down

0 comments on commit 4c1f967

Please sign in to comment.