Skip to content

Commit c87ed8b

Browse files
committed
🎨 Simplify things; no command field
1 parent e4e8b3c commit c87ed8b

5 files changed

Lines changed: 8 additions & 75 deletions

File tree

README.md

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ A Buildkite plugin that creates rich annotations from Bazel Event Protocol (BEP)
1010
- ✅ Displays build status with success/failure counts
1111
- ⏱️ Shows test durations and highlights slow tests
1212
- ❌ Provides detailed failure information with error logs
13-
- 🔄 Automatically detects BEP files based on Bazel commands
13+
- 🔄 Automatically detects BEP files at common locations
1414
- 💡 Includes random developer wisdom quotes for inspiration
1515

1616
## Prerequisites
@@ -24,13 +24,7 @@ This plugin requires:
2424

2525
### `bep_file` (optional)
2626

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)
30-
31-
### `bazel_command` (optional)
32-
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.
27+
Path to the Bazel Event Protocol JSON file to parse. If not provided, the plugin will look for files at common locations (bazel-events.json, bazel-bep.json, bep.json).
3428

3529
### `skip_if_no_bep` (optional, boolean)
3630

@@ -51,17 +45,6 @@ steps:
5145
bep_file: bazel-events.json
5246
```
5347
54-
### Automatic BEP detection from Bazel command
55-
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-
```
6548
6649
### Skip annotations if no BEP file found
6750

hooks/post-command

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,28 +10,10 @@ DIR="$(cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd)"
1010

1111
# Get plugin configuration
1212
BEP_FILE=$(plugin_read_config BEP_FILE "")
13-
BAZEL_COMMAND=$(plugin_read_config BAZEL_COMMAND "")
1413

1514
# Check if we should skip if no BEP file found
1615
SKIP_IF_NO_BEP=$(plugin_read_config SKIP_IF_NO_BEP "false")
1716

18-
# Check for automatic BEP file detection based on Bazel command
19-
if [[ -z "${BEP_FILE}" && -n "${BAZEL_COMMAND}" ]]; then
20-
# Try to extract the BEP file from the command if it was specified
21-
if [[ "${BAZEL_COMMAND}" =~ --build_event_json_file=([^ ]+) ]]; then
22-
BEP_FILE="${BASH_REMATCH[1]}"
23-
echo "Detected BEP file from Bazel command: ${BEP_FILE}"
24-
else
25-
# No BEP file specified in command, check if skip is enabled
26-
if [[ "${SKIP_IF_NO_BEP}" == "true" ]]; then
27-
echo "No BEP file found in command and skip_if_no_bep is true, skipping annotation"
28-
exit 0
29-
fi
30-
echo "Error: No BEP file found in command"
31-
exit 1
32-
fi
33-
fi
34-
3517
# If we still don't have a BEP file, check if it exists at common locations
3618
if [[ -z "${BEP_FILE}" ]]; then
3719
# Try some common locations
@@ -73,7 +55,7 @@ if [[ ! -f "${BEP_FILE}" ]]; then
7355
fi
7456

7557
# Process the BEP file and create the annotation
76-
process_bep "${BEP_FILE}" "${BAZEL_COMMAND}" || {
58+
process_bep "${BEP_FILE}" || {
7759
status=$?
7860
echo "Warning: BEP processing returned non-zero status ($status)"
7961
if [[ "${SKIP_IF_NO_BEP}" == "true" ]]; then

lib/bazel-bep.bash

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ create_annotation() {
4343
# Process the BEP file to extract useful information
4444
process_bep() {
4545
local BEP_FILE="$1"
46-
local BAZEL_COMMAND="${2:-}"
4746

4847
# Ensure the file exists
4948
if [[ ! -f "$BEP_FILE" ]]; then
@@ -225,9 +224,9 @@ process_bep() {
225224
# Clean header for the output
226225
local summary="## 🚀 Bazel Results\n\n"
227226

228-
# Add command used
229-
if [ -n "$BAZEL_COMMAND" ]; then
230-
summary+="**🏃 Command:** \`$BAZEL_COMMAND\`\n\n"
227+
# Add command used if running in Buildkite
228+
if [ -n "${BUILDKITE_COMMAND:-}" ]; then
229+
summary+="**🏃 Command:** \`${BUILDKITE_COMMAND}\`\n\n"
231230
fi
232231

233232
if [ $total_build_time -gt 0 ]; then

plugin.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ configuration:
99
properties:
1010
bep_file:
1111
type: string
12-
bazel_command:
13-
type: string
1412
skip_if_no_bep:
1513
type: boolean
1614
additionalProperties: false

tests/post-command.bats

Lines changed: 2 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ setup() {
1717
1818
process_bep() {
1919
local BEP_FILE="$1"
20-
local BAZEL_COMMAND="${2:-}"
2120
2221
echo "Mock processing BEP file: $BEP_FILE"
2322
if [[ -f "$BEP_FILE" ]]; then
@@ -60,28 +59,10 @@ LIB_DIR="$(cd "$DIR/../lib" && pwd)"
6059
6160
# Get plugin configuration
6261
BEP_FILE=$(plugin_read_config BEP_FILE "")
63-
BAZEL_COMMAND=$(plugin_read_config BAZEL_COMMAND "")
6462
6563
# Check if we should skip if no BEP file found
6664
SKIP_IF_NO_BEP=$(plugin_read_config SKIP_IF_NO_BEP "false")
6765
68-
# Check for automatic BEP file detection based on Bazel command
69-
if [[ -z "${BEP_FILE}" && -n "${BAZEL_COMMAND}" ]]; then
70-
# Try to extract the BEP file from the command if it was specified
71-
if [[ "${BAZEL_COMMAND}" =~ --build_event_json_file=([^ ]+) ]]; then
72-
BEP_FILE="${BASH_REMATCH[1]}"
73-
echo "Detected BEP file from Bazel command: ${BEP_FILE}"
74-
else
75-
# No BEP file specified in command, check if skip is enabled
76-
if [[ "${SKIP_IF_NO_BEP}" == "true" ]]; then
77-
echo "No BEP file found in command and skip_if_no_bep is true, skipping annotation"
78-
exit 0
79-
fi
80-
echo "Error: No BEP file found in command"
81-
exit 1
82-
fi
83-
fi
84-
8566
# If we still don't have a BEP file, check if it exists at common locations
8667
if [[ -z "${BEP_FILE}" ]]; then
8768
# Try some common locations
@@ -123,7 +104,7 @@ if [[ ! -f "${BEP_FILE}" ]]; then
123104
fi
124105
125106
# Process the BEP file and create the annotation
126-
process_bep "${BEP_FILE}" "${BAZEL_COMMAND}"
107+
process_bep "${BEP_FILE}"
127108
EOF
128109
chmod +x "$TEMP_DIR/hooks/post-command"
129110
}
@@ -173,17 +154,7 @@ teardown() {
173154
assert_output --partial "Mock processing BEP file: $TEMP_DIR/sample.bep"
174155
}
175156

176-
@test "Detect BEP file from Bazel command" {
177-
# Create a sample BEP file
178-
touch "$TEMP_DIR/detected.bep"
179-
export BUILDKITE_PLUGIN_BAZEL_BEP_ANNOTATE_BAZEL_COMMAND="bazel build //... --build_event_json_file=$TEMP_DIR/detected.bep"
180-
181-
run "$TEMP_DIR/hooks/post-command"
182-
183-
assert_success
184-
assert_output --partial "Detected BEP file from Bazel command: $TEMP_DIR/detected.bep"
185-
assert_output --partial "Mock processing BEP file: $TEMP_DIR/detected.bep"
186-
}
157+
# Removed test for bazel_command since we removed that functionality
187158

188159
@test "Find BEP file at common location" {
189160
# Create sample BEP file at a common location

0 commit comments

Comments
 (0)