Skip to content

Commit e4e8b3c

Browse files
committed
📝 Add README. Change name a little
1 parent b23f50e commit e4e8b3c

4 files changed

Lines changed: 117 additions & 33 deletions

File tree

README.md

Lines changed: 108 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,145 @@
1-
# Template Buildkite Plugin [![Build status](https://badge.buildkite.com/d673030645c7f3e7e397affddd97cfe9f93a40547ed17b6dc5.svg)](https://buildkite.com/buildkite/plugins-template)
1+
# Bazel BEP Annotate Buildkite Plugin
22

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.
44

5-
## Options
5+
![Build status](https://badge.buildkite.com/d673030645c7f3e7e397affddd97cfe9f93a40547ed17b6dc5.svg)
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
615

7-
These are all the options available to configure this plugin's behaviour.
16+
## Prerequisites
817

9-
### Required
18+
This plugin requires:
19+
- Bash
20+
- jq (for JSON parsing)
21+
- bc (for floating point calculations)
22+
23+
## Options
1024

11-
#### `mandatory` (string)
25+
### `bep_file` (optional)
1226

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)
1430

15-
### Optional
31+
### `bazel_command` (optional)
1632

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.
1834

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`
2039

2140
## Examples
2241

23-
Show how your plugin is to be used
42+
### Basic usage with explicit BEP file
2443

2544
```yaml
2645
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
2949
plugins:
30-
- template#v1.0.0:
31-
mandatory: "value"
50+
- bazel-bep-annotate#v1.0.0:
51+
bep_file: bazel-events.json
3252
```
3353
34-
## And with other options as well
54+
### Automatic BEP detection from Bazel command
3555
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
3767
3868
```yaml
3969
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 //...
4274
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
46127
```
47128

48129
## ⚒ Developing
49130

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:
51132

52133
```bash
53134
bk local run
54135
```
55136

56137
## 👩‍💻 Contributing
57138

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
59143

60144
## 📜 License
61145

lib/plugin.bash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/bash
22
set -euo pipefail
33

4-
PLUGIN_PREFIX="BAZEL_BEP_ANNOTATOR"
4+
PLUGIN_PREFIX="BAZEL_BEP_ANNOTATE"
55

66
# Reads either a value or a list from the given env prefix
77
function prefix_read_list() {

plugin.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Bazel BEP Annotator
1+
name: Bazel BEP Annotate
22
description: Creates Buildkite annotations from Bazel Event Protocol output
33
author: https://github.com/buildkite-plugins
44
requirements:

tests/post-command.bats

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ setup() {
88

99
# Setup environment
1010
export BUILDKITE=true
11-
export BUILDKITE_PLUGIN_BAZEL_BEP_ANNOTATOR_SKIP_IF_NO_BEP=false
11+
export BUILDKITE_PLUGIN_BAZEL_BEP_ANNOTATE_SKIP_IF_NO_BEP=false
1212

1313
# Mock the process_bep function to avoid relying on external tools
1414
cat > "$TEMP_DIR/mock-bazel-bep.bash" << 'EOF'
@@ -134,7 +134,7 @@ teardown() {
134134

135135
@test "Skip when no BEP file and skip option is enabled" {
136136
# No BEP file, but we'll enable skip option
137-
export BUILDKITE_PLUGIN_BAZEL_BEP_ANNOTATOR_SKIP_IF_NO_BEP=true
137+
export BUILDKITE_PLUGIN_BAZEL_BEP_ANNOTATE_SKIP_IF_NO_BEP=true
138138

139139
# Ensure no common files exist
140140
rm -f "${BUILDKITE_BUILD_CHECKOUT_PATH:-$PWD}/bazel-events.json" || true
@@ -149,7 +149,7 @@ teardown() {
149149

150150
@test "Fail when no BEP file and skip option is disabled" {
151151
# No BEP file, skip option disabled
152-
export BUILDKITE_PLUGIN_BAZEL_BEP_ANNOTATOR_SKIP_IF_NO_BEP=false
152+
export BUILDKITE_PLUGIN_BAZEL_BEP_ANNOTATE_SKIP_IF_NO_BEP=false
153153

154154
# Ensure no common files exist
155155
rm -f "${BUILDKITE_BUILD_CHECKOUT_PATH:-$PWD}/bazel-events.json" || true
@@ -165,7 +165,7 @@ teardown() {
165165
@test "Process BEP file when explicitly provided" {
166166
# Create a sample BEP file
167167
touch "$TEMP_DIR/sample.bep"
168-
export BUILDKITE_PLUGIN_BAZEL_BEP_ANNOTATOR_BEP_FILE="$TEMP_DIR/sample.bep"
168+
export BUILDKITE_PLUGIN_BAZEL_BEP_ANNOTATE_BEP_FILE="$TEMP_DIR/sample.bep"
169169

170170
run "$TEMP_DIR/hooks/post-command"
171171

@@ -176,7 +176,7 @@ teardown() {
176176
@test "Detect BEP file from Bazel command" {
177177
# Create a sample BEP file
178178
touch "$TEMP_DIR/detected.bep"
179-
export BUILDKITE_PLUGIN_BAZEL_BEP_ANNOTATOR_BAZEL_COMMAND="bazel build //... --build_event_json_file=$TEMP_DIR/detected.bep"
179+
export BUILDKITE_PLUGIN_BAZEL_BEP_ANNOTATE_BAZEL_COMMAND="bazel build //... --build_event_json_file=$TEMP_DIR/detected.bep"
180180

181181
run "$TEMP_DIR/hooks/post-command"
182182

@@ -202,8 +202,8 @@ teardown() {
202202

203203
@test "Skip when BEP file doesn't exist and skip is enabled" {
204204
# Reference a non-existent BEP file with skip enabled
205-
export BUILDKITE_PLUGIN_BAZEL_BEP_ANNOTATOR_BEP_FILE="$TEMP_DIR/nonexistent.bep"
206-
export BUILDKITE_PLUGIN_BAZEL_BEP_ANNOTATOR_SKIP_IF_NO_BEP=true
205+
export BUILDKITE_PLUGIN_BAZEL_BEP_ANNOTATE_BEP_FILE="$TEMP_DIR/nonexistent.bep"
206+
export BUILDKITE_PLUGIN_BAZEL_BEP_ANNOTATE_SKIP_IF_NO_BEP=true
207207

208208
run "$TEMP_DIR/hooks/post-command"
209209

0 commit comments

Comments
 (0)