|
1 | | -# Template Buildkite Plugin [](https://buildkite.com/buildkite/plugins-template) |
| 1 | +# Bazel BEP Annotate Buildkite Plugin |
2 | 2 |
|
3 | | -A Buildkite plugin for something awesome |
| 3 | +A Buildkite plugin that creates rich annotations from Bazel Event Protocol (BEP) output files, providing at-a-glance build status, test results, and performance information. |
4 | 4 |
|
5 | | -## Options |
| 5 | + |
| 6 | + |
| 7 | +## Features |
| 8 | + |
| 9 | +- 📊 Parses Bazel Event Protocol (BEP) output files |
| 10 | +- ✅ Displays build status with success/failure counts |
| 11 | +- ⏱️ Shows test durations and highlights slow tests |
| 12 | +- ❌ Provides detailed failure information with error logs |
| 13 | +- 🔄 Automatically detects BEP files based on Bazel commands |
| 14 | +- 💡 Includes random developer wisdom quotes for inspiration |
6 | 15 |
|
7 | | -These are all the options available to configure this plugin's behaviour. |
| 16 | +## Prerequisites |
8 | 17 |
|
9 | | -### Required |
| 18 | +This plugin requires: |
| 19 | +- Bash |
| 20 | +- jq (for JSON parsing) |
| 21 | +- bc (for floating point calculations) |
| 22 | + |
| 23 | +## Options |
10 | 24 |
|
11 | | -#### `mandatory` (string) |
| 25 | +### `bep_file` (optional) |
12 | 26 |
|
13 | | -A great description of what this is supposed to do. |
| 27 | +Path to the Bazel Event Protocol JSON file to parse. If not provided, the plugin will attempt to: |
| 28 | +1. Extract it from the `bazel_command` if provided |
| 29 | +2. Look for files at common locations (bazel-events.json, bazel-bep.json, bep.json) |
14 | 30 |
|
15 | | -### Optional |
| 31 | +### `bazel_command` (optional) |
16 | 32 |
|
17 | | -#### `optional` (string) |
| 33 | +The original Bazel command that was run. This is used for display purposes and can also be used to extract the BEP file path if it contains a `--build_event_json_file` flag. |
18 | 34 |
|
19 | | -Describe how the plugin behaviour changes if this option is not specified, allowed values and its default. |
| 35 | +### `skip_if_no_bep` (optional, boolean) |
| 36 | + |
| 37 | +If set to `true`, the plugin will exit successfully if no BEP file is found, instead of failing the build. |
| 38 | +Default: `false` |
20 | 39 |
|
21 | 40 | ## Examples |
22 | 41 |
|
23 | | -Show how your plugin is to be used |
| 42 | +### Basic usage with explicit BEP file |
24 | 43 |
|
25 | 44 | ```yaml |
26 | 45 | steps: |
27 | | - - label: "🔨 Running plugin" |
28 | | - command: "echo template plugin" |
| 46 | + - label: "🔨 Build with Bazel" |
| 47 | + command: | |
| 48 | + bazel build //... --build_event_json_file=bazel-events.json |
29 | 49 | plugins: |
30 | | - - template#v1.0.0: |
31 | | - mandatory: "value" |
| 50 | + - bazel-bep-annotate#v1.0.0: |
| 51 | + bep_file: bazel-events.json |
32 | 52 | ``` |
33 | 53 |
|
34 | | -## And with other options as well |
| 54 | +### Automatic BEP detection from Bazel command |
35 | 55 |
|
36 | | -If you want to change the plugin behaviour: |
| 56 | +```yaml |
| 57 | +steps: |
| 58 | + - label: "🔨 Build with Bazel" |
| 59 | + command: | |
| 60 | + bazel build //... --build_event_json_file=bazel-events.json |
| 61 | + plugins: |
| 62 | + - bazel-bep-annotate#v1.0.0: |
| 63 | + bazel_command: "bazel build //... --build_event_json_file=bazel-events.json" |
| 64 | +``` |
| 65 | +
|
| 66 | +### Skip annotations if no BEP file found |
37 | 67 |
|
38 | 68 | ```yaml |
39 | 69 | steps: |
40 | | - - label: "🔨 Running plugin" |
41 | | - command: "echo template plugin with options" |
| 70 | + - label: "🔨 Build with Bazel" |
| 71 | + command: | |
| 72 | + # Command might not produce a BEP file |
| 73 | + bazel build //... |
42 | 74 | plugins: |
43 | | - - template#v1.0.0: |
44 | | - mandatory: "value" |
45 | | - optional: "example" |
| 75 | + - bazel-bep-annotate#v1.0.0: |
| 76 | + skip_if_no_bep: true |
| 77 | +``` |
| 78 | +
|
| 79 | +## Common Use Cases |
| 80 | +
|
| 81 | +### Running tests with annotations |
| 82 | +
|
| 83 | +```yaml |
| 84 | +steps: |
| 85 | + - label: "🧪 Run Bazel tests" |
| 86 | + command: | |
| 87 | + bazel test //... --build_event_json_file=bazel-test-events.json |
| 88 | + plugins: |
| 89 | + - bazel-bep-annotate#v1.0.0: |
| 90 | + bep_file: bazel-test-events.json |
| 91 | +``` |
| 92 | +
|
| 93 | +### Running builds with annotations in a custom Bazel workspace |
| 94 | +
|
| 95 | +```yaml |
| 96 | +steps: |
| 97 | + - label: "🔨 Build with Bazel (custom workspace)" |
| 98 | + command: | |
| 99 | + cd my-workspace |
| 100 | + bazel build //... --build_event_json_file=bazel-events.json |
| 101 | + plugins: |
| 102 | + - bazel-bep-annotate#v1.0.0: |
| 103 | + bep_file: my-workspace/bazel-events.json |
| 104 | +``` |
| 105 | +
|
| 106 | +## How It Works |
| 107 | +
|
| 108 | +1. After your Bazel command runs, the plugin looks for the BEP file |
| 109 | +2. It parses the BEP data to extract build status, test results, and performance metrics |
| 110 | +3. It creates a detailed Buildkite annotation with this information |
| 111 | +4. The annotation shows success/failure status, test performance, and detailed error logs |
| 112 | +
|
| 113 | +## Troubleshooting |
| 114 | +
|
| 115 | +### The plugin can't find the BEP file |
| 116 | +
|
| 117 | +Make sure: |
| 118 | +1. The Bazel command has completed successfully |
| 119 | +2. You've specified the `--build_event_json_file` flag in your Bazel command |
| 120 | +3. The path to the BEP file is correct and accessible to the build agent |
| 121 | + |
| 122 | +### The annotation doesn't show all targets |
| 123 | + |
| 124 | +The BEP file might not contain complete information. Try running Bazel with additional flags: |
| 125 | +``` |
| 126 | +--experimental_build_event_text_file_path_conversion=true |
46 | 127 | ``` |
47 | 128 |
|
48 | 129 | ## ⚒ Developing |
49 | 130 |
|
50 | | -You can use the [bk cli](https://github.com/buildkite/cli) to run the [pipeline](.buildkite/pipeline.yml) locally: |
| 131 | +You can use the [bk cli](https://github.com/buildkite/cli) to run the plugin locally: |
51 | 132 |
|
52 | 133 | ```bash |
53 | 134 | bk local run |
54 | 135 | ``` |
55 | 136 |
|
56 | 137 | ## 👩💻 Contributing |
57 | 138 |
|
58 | | -Your policy on how to contribute to the plugin! |
| 139 | +1. Fork the repository |
| 140 | +2. Create a feature branch |
| 141 | +3. Add your changes, including tests |
| 142 | +4. Submit a pull request |
59 | 143 |
|
60 | 144 | ## 📜 License |
61 | 145 |
|
|
0 commit comments