Skip to content

Commit 8bd8259

Browse files
committed
Add execute-command-before BuildMutator
- BuildMutator allows commands to be executed prior to the SCENARIO or BUILD phase. Enabled for all types of builds, Gradle, Bazel, Buck, and Maven. Signed-off-by: Alex Beggs <[email protected]>
1 parent 394d202 commit 8bd8259

File tree

6 files changed

+483
-63
lines changed

6 files changed

+483
-63
lines changed

README.md

+41
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,7 @@ A scenario can define changes that should be applied to the source before each b
270270
- `clear-project-cache-before`: Deletes the contents of the `.gradle` and `buildSrc/.gradle` project cache directories before the scenario is executed (`SCENARIO`), before cleanup (`CLEANUP`) or before the build is executed (`BUILD`).
271271
- `clear-transform-cache-before`: Deletes the contents of the transform cache before the scenario is executed (`SCENARIO`), before cleanup (`CLEANUP`) or before the build is executed (`BUILD`).
272272
- `clear-jars-cache-before`: Deletes the contents of the instrumented jars cache before the scenario is executed (`SCENARIO`), before cleanup (`CLEANUP`) or before the build is executed (`BUILD`).
273+
- `execute-command-before`: Execute a command before the scenario is executed (SCENARIO) or before the build is executed (BUILD). This can be applied to Gradle, Bazel, Buck, or Maven builds.
273274
- `git-checkout`: Checks out a specific commit for the build step, and a different one for the cleanup step.
274275
- `git-revert`: Reverts a given set of commits before the build and resets it afterward.
275276
- `iterations`: Number of builds to actually measure
@@ -325,11 +326,43 @@ You can compare Gradle against Bazel, Buck, and Maven by specifying their equiva
325326

326327
build_some_target {
327328
tasks = ["assemble"]
329+
execute-command-before = [
330+
# Gradle specific executions
331+
# Execute a command in the bash shell
332+
{
333+
schedule = BUILD
334+
commands = ["/bin/bash","-c","echo helloworld"]
335+
},
336+
}
328337

329338
bazel {
330339
# If empty, it will be infered from BAZEL_HOME environment variable
331340
home = "/path/to/bazel/home"
332341
targets = ["build" "//some/target"]
342+
execute-command-before = [
343+
# Bazel specific executions
344+
# execute a command prior to the scenario running.
345+
{
346+
schedule = SCENARIO
347+
# Note: Ensure that this is calling the same Bazel that is used in the benchmarks
348+
commands = ["bazel","clean","--expunge"]
349+
},
350+
# Execute a command in the bash shell
351+
{
352+
schedule = BUILD
353+
commands = ["/bin/bash","-c","echo helloworld"]
354+
},
355+
# Remove the contents of the remote cache Bazel bucket
356+
{
357+
schedule = BUILD
358+
commands = ["gsutil","-o","Credentials:gs_service_key_file=bazel-benchmark-bucket.json","-m","rm","gs://bazel-benchmark-bucket/**"]
359+
},
360+
# Display the total size of the bucket
361+
{
362+
schedule = BUILD
363+
commands = ["gsutil","-o","Credentials:gs_service_key_file=bazel-benchmark-bucket.json","du","-sh","gs://bazel-benchmark-bucket"]
364+
},
365+
]
333366
}
334367
}
335368

@@ -344,6 +377,14 @@ You can compare Gradle against Bazel, Buck, and Maven by specifying their equiva
344377
# If empty, it will be infered from BUCK_HOME environment variable
345378
home = "/path/to/buck/home"
346379
type = "android_binary" // can be a Buck build rule type or "all"
380+
execute-command-before = [
381+
# Buck specific executions
382+
# Execute a command in the bash shell
383+
{
384+
schedule = BUILD
385+
commands = ["/bin/bash","-c","echo helloworld"]
386+
},
387+
}
347388
}
348389
}
349390
build_resources {

0 commit comments

Comments
 (0)