Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ common --enable_bzlmod
# Spawn strategy - if this is not set, bazel tries to reference files that don't exist
build --spawn_strategy=standalone

# Enable runfiles
common --enable_runfiles

# Set action envs for Mayhem
build --action_env=MAYHEM_URL
build --action_env=XDG_CONFIG_HOME
common --action_env=MAYHEM_URL
common --action_env=XDG_CONFIG_HOME
2 changes: 1 addition & 1 deletion .github/workflows/small-linux-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ jobs:

- name: Run bazel build
run: |
bazel build //examples:run_mayhemit
bazel run //examples:run_mayhemit
shell: bash
env:
MAYHEM_URL: ${{ env.MAYHEM_URL }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/small-win-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ jobs:

- name: Run bazel build
run: |
bazel build //examples:run_mayhemit
bazel run //examples:run_mayhemit
shell: cmd
env:
MAYHEM_URL: ${{ env.MAYHEM_URL }}
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2024 abrewer@forallsecure.com
Copyright (c) 2024-2026 abrewer@forallsecure.com

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
6 changes: 4 additions & 2 deletions MODULE.bazel
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
module(
name = "rules_mayhem",
version = "0.8.3",
version = "0.8.4",
)

bazel_dep(name = "bazel_skylib", version = "1.7.1")
bazel_dep(name = "bazel_skylib", version = "1.9.0")
bazel_dep(name = "platforms", version = "1.0.0")
bazel_dep(name = "rules_shell", version = "0.6.1")
bazel_dep(name = "rules_cc", version = "0.2.16")

rules_mayhem_extension = use_extension("@rules_mayhem//mayhem:extensions.bzl", "rules_mayhem_extension")
use_repo(rules_mayhem_extension, "mayhem_cli_linux", "mayhem_cli_windows", "yq_cli_linux", "yq_cli_windows")
2,871 changes: 257 additions & 2,614 deletions MODULE.bazel.lock

Large diffs are not rendered by default.

29 changes: 15 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ You can add the following snippet:

```
## MODULE.bazel
bazel_dep(name = "rules_mayhem", version = "0.8.3")
bazel_dep(name = "rules_mayhem", version = "0.8.4")

rules_mayhem_extension = use_extension("@rules_mayhem//mayhem:extensions.bzl", "rules_mayhem_extension")
use_repo(rules_mayhem_extension, "bazel_skylib", "mayhem_cli_linux", "mayhem_cli_windows", "platforms", "yq_cli_linux", "yq_cli_windows")
Expand All @@ -21,7 +21,7 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "rules_mayhem",
strip_prefix = "rules_mayhem",
urls = ["https://github.com/ForAllSecure/rules_mayhem/releases/download/0.8.3/rules_mayhem-0.8.3.tar.gz"],
urls = ["https://github.com/ForAllSecure/rules_mayhem/releases/download/0.8.4/rules_mayhem-0.8.4.tar.gz"],
sha256 = "44be6bea9c9462144542331531d18f848e89e6ed69561a52a4d761ffbe10d2e0",
)

Expand Down Expand Up @@ -88,21 +88,21 @@ set MAYHEM_URL=https://<your_mayhem_instance>
set XDG_CONFIG_HOME=%USERPROFILE%\.config
```

3. Run `bazel build` with the `--action_env` flags to specify the Mayhem URL and configuration file location:
3. Run `bazel run` with the `--action_env` flags to specify the Mayhem URL and configuration file location:

```bash
bazel build --action_env=MAYHEM_URL --action_env=XDG_CONFIG_HOME //examples:run_mayhemit
bazel run --action_env=MAYHEM_URL --action_env=XDG_CONFIG_HOME //examples:run_mayhemit
```

Instead of adding these flags to every `bazel build` command, you can also add them to your `.bazelrc` file:
Instead of adding these flags to every `bazel run` command, you can also add them to your `.bazelrc` file:

```
# .bazelrc
build --action_env=MAYHEM_URL
build --action_env=XDG_CONFIG_HOME
common --action_env=MAYHEM_URL
common --action_env=XDG_CONFIG_HOME
```

The remainder of this document assumes that you have set up your Mayhem configuration in your `.bazelrc`, and omits the `--action_env` flags from the `bazel build` commands for brevity.
The remainder of this document assumes that you have set up your Mayhem configuration in your `.bazelrc`, and omits the `--action_env` flags from the `bazel` commands for brevity.

## To build a Mayhemfile

Expand Down Expand Up @@ -194,10 +194,10 @@ mayhem_run(
)
```

Then build:
Then run:

```
bazel build //examples:run_factor
bazel run //examples:run_factor
INFO: Analyzed target //examples:run_factor (0 packages loaded, 0 targets configured).
INFO: From Starting Mayhem run from 'examples':
git version 2.46.0 found
Expand Down Expand Up @@ -264,7 +264,7 @@ INFO: 2 processes: 1 internal, 1 local.
INFO: Build completed successfully, 2 total actions


bazel build //examples:run_mayhemit
bazel run //examples:run_mayhemit
INFO: Analyzed target //examples:run_mayhemit (0 packages loaded, 1 target configured).
INFO: From Starting Mayhem run from 'bazel-out/k8-fastbuild/bin/examples/mayhemit-pkg':
git version 2.46.0 found
Expand Down Expand Up @@ -310,7 +310,7 @@ mayhem_run(
Then build and run:

```
bazel build //examples:run_mayhemit
bazel run //examples:run_mayhemit
INFO: Analyzed target //examples:run_mayhemit (56 packages loaded, 239 targets configured).
INFO: From Packaging target examples/mayhemit to 'bazel-out/k8-fastbuild/bin/examples/mayhemit-pkg'...:
Packaging target: examples/mayhemit
Expand Down Expand Up @@ -402,9 +402,10 @@ INFO: Build completed successfully, 2 total actions
- [x] `wait` parameter to `mayhem_run()`: Support waiting for Mayhem run to complete
- [x] `fail_on_defects` parameter to `mayhem_run()`: Return exit code 1 if Mayhem run finds defects
- [x] `mayhem_download` rule to grab testsuite and coverage info
- [x] Remove support for using `--action_env` to set Mayhem secrets (this is leaky); use a `mayhem_secrets.bzl` file instead
- [x] Remove support for using `--action_env` to set Mayhem secrets (this is leaky); use `XDG_CONFIG_HOME` instead
- [ ] Support MacOS (currently only Linux and Windows; MacOS requires binary signing and unpackaging)
- [ ] Run the `mayhem_run` targets with `bazel run` instead of `bazel build`
- [X] Run the `mayhem_run` targets with `bazel run` instead of `bazel build`
- [X] Support image data dependencies from `rules_oci` in `mayhem_run`
- [ ] Use output flag for `mayhem run` instead of custom wrapper script
- [ ] Tests are currently `sh_test` only and do not run on Windows

Expand Down
4 changes: 3 additions & 1 deletion examples/BUILD
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
load("@rules_mayhem//mayhem:mayhem.bzl", "mayhem_init", "mayhem_run", "mayhem_package", "mayhem_download")
load("@rules_cc//cc:cc_binary.bzl", "cc_binary")
load("@rules_shell//shell:sh_test.bzl", "sh_test")

# Generates a minimal Mayhemfile
mayhem_init(
Expand Down Expand Up @@ -153,4 +155,4 @@ sh_test(
"@rules_mayhem//mayhem:yq_cli",
":package_mayhemit"
],
)
)
Loading
Loading