Skip to content

refactor(ci): extract alert formatting into composite action and isolate Python tests#315

Open
geovannefduarte wants to merge 2 commits intoairbnb:mainfrom
geovannefduarte:gd--dedup-ci-composite-actions
Open

refactor(ci): extract alert formatting into composite action and isolate Python tests#315
geovannefduarte wants to merge 2 commits intoairbnb:mainfrom
geovannefduarte:gd--dedup-ci-composite-actions

Conversation

@geovannefduarte
Copy link
Copy Markdown
Collaborator

Description

Three workflows duplicated the same inline shell pattern for formatting CI failure alerts (build JSON with jq, pipe to format_alert.py, write to $GITHUB_OUTPUT).
This PR extracts that pattern into a reusable composite action and moves Python script tests into their own lightweight job so they run in seconds without waiting for the Gradle build pipeline.

Key Changes

  • .github/actions/collect-failure-info/action.yml — new composite action that accepts a jobs_json array and context inputs, constructs the alert payload, and calls format_alert.py. Follows the same caller-must-checkout pattern as setup-build.
  • .github/workflows/ci-manual-trigger.yml — split the monolithic format-alerts step into a job-filtering step and a composite action call, removing ~20 lines of inline shell.
  • .github/workflows/periodic-green-check.yml — replaced inline staleness alert formatting with the composite action.
  • .github/workflows/post-alerts.yml — replaced inline test alert formatting with the composite action.
  • .github/workflows/build-and-test.yml — added a standalone python-tests job (no JVM/Gradle, runs in parallel) and removed Python test steps from the Gradle test matrix job, eliminating 18 redundant step executions per CI run (3 steps x 6 matrix cells).

How was it tested? What documentation was provided?

CI and gradle build

  • actionlint passes on all modified and new workflow files
  • Python unit tests pass locally via python3 -m unittest discover -s .github/scripts/tests
  • Alert output format is unchanged (composite action produces identical JSON payloads to the inline shell it replaces)

@geovannefduarte geovannefduarte self-assigned this Apr 10, 2026
@geovannefduarte geovannefduarte force-pushed the gd--dedup-ci-composite-actions branch from e50f50c to 70e00a4 Compare April 10, 2026 10:53
Copy link
Copy Markdown
Collaborator

@rstata rstata left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review

Good refactoring overall — the composite action is well-structured, output references are preserved correctly across all callers, and isolating the Python tests into their own job (15s standalone vs duplicated across 6 matrix cells) is a nice efficiency win.

One bug and one nit.

Bug: multi-line jobs_json will break $GITHUB_OUTPUT in ci-manual-trigger.yml

Lines 72/75/78 call jq without -c, so the output is pretty-printed (multi-line). Line 80 then writes it as:

echo "jobs_json=$jobs_json" >> "$GITHUB_OUTPUT"

The echo "key=value" format only works for single-line values. When a CI job actually fails, the multi-line JSON will be truncated at the first newline, and the composite action will receive invalid JSON.

CI is green on this PR because the format-alerts job only runs on failure — this path was not exercised.

Fix: add -c (compact) to the jq calls:

jobs_json=$(echo "$jobs_json" | jq -c --arg name "Build and Test" --arg run_id "$BAT_RUN_ID" '. + [{"name": $name, "run_id": $run_id}]')

(Same for the SDT and BCV lines.)

Nit: display name change

"Standalone Tests" was renamed to "Demo App Tests" on line 75. Intentional? Fine either way, just flagging since it'll change the alert text.

@rstata
Copy link
Copy Markdown
Collaborator

rstata commented Apr 10, 2026

from claude:

Bug found: ci-manual-trigger.yml line 80 writes multi-line jq output (pretty-printed JSON) to $GITHUB_OUTPUT using the single-line echo "key=value" format. This will silently truncate the jobs_json value when a CI job actually fails, feeding invalid JSON to the composite action. The fix is adding -c to the three jq calls so they produce compact single-line JSON. This wasn't caught by CI because the format-alerts job only runs on failure.

If you confirm this is a bug is there a regression test you can add for it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants