Files
Simon ScattonandMrunal Patel 5698c4f746 fix(ci): qualify protobuf compatibility by release train (#4049)
* feat(ci): detect breaking protobuf changes

Compare the proto module against the PR or merge-group base and report Buf violations in Branch Checks. Add local reproduction and fixture coverage.

Closes #3794

Signed-off-by: Mrunal Patel <mrunalp@gmail.com>

* fix(ci): pin protobuf check container image

Signed-off-by: Mrunal Patel <mrunalp@gmail.com>

* fix(ci): qualify protobuf compatibility by release train

Signed-off-by: Simon Scatton <sscatton@nvidia.com>

* refactor(ci): reuse protobuf compatibility action

Signed-off-by: Simon Scatton <sscatton@nvidia.com>

* refactor(ci): run protobuf checks as a Nix app with one ref

Signed-off-by: Simon Scatton <sscatton@nvidia.com>

---------

Signed-off-by: Mrunal Patel <mrunalp@gmail.com>
Signed-off-by: Simon Scatton <sscatton@nvidia.com>
Co-authored-by: Mrunal Patel <mrunalp@gmail.com>
2026-10-01 14:00:45 +00:00

77 lines
2.8 KiB
YAML

name: PR Gate
description: >
Resolve PR metadata for a `pull-request/<N>` push from copy-pr-bot and decide
whether the workflow should run. Sets `should-run=true` only when the pushed
SHA still matches the PR head SHA. If `required_label` is provided, the PR
must also carry that label. For non-`push` events (e.g. `workflow_dispatch`
and `merge_group`), always sets `should-run=true`.
inputs:
required_label:
description: Optional PR label required to enable the run (e.g. "test:e2e").
required: false
default: ""
outputs:
should_run:
description: "true if the workflow should proceed, false otherwise"
value: ${{ steps.gate.outputs.should_run }}
base_sha:
description: "Target branch commit SHA for a mirrored pull request, or empty for other events"
value: ${{ steps.gate.outputs.base_sha }}
labels_json:
description: "JSON array of PR label names for push-triggered mirror runs, or [] otherwise"
value: ${{ steps.gate.outputs.labels_json }}
runs:
using: composite
steps:
- id: get_pr_info
if: github.event_name == 'push'
continue-on-error: true
uses: nv-gha-runners/get-pr-info@090577647b8ddc4e06e809e264f7881650ecdccf # main
- id: gate
shell: bash
env:
EVENT_NAME: ${{ github.event_name }}
GITHUB_SHA_VALUE: ${{ github.sha }}
GET_PR_INFO_OUTCOME: ${{ steps.get_pr_info.outcome }}
PR_INFO: ${{ steps.get_pr_info.outputs.pr-info }}
REQUIRED_LABEL: ${{ inputs.required_label }}
run: |
if [ "$EVENT_NAME" != "push" ]; then
echo "labels_json=[]" >> "$GITHUB_OUTPUT"
echo "should_run=true" >> "$GITHUB_OUTPUT"
echo "base_sha=" >> "$GITHUB_OUTPUT"
exit 0
fi
if [ "$GET_PR_INFO_OUTCOME" != "success" ]; then
echo "labels_json=[]" >> "$GITHUB_OUTPUT"
echo "should_run=false" >> "$GITHUB_OUTPUT"
echo "base_sha=" >> "$GITHUB_OUTPUT"
exit 0
fi
head_sha="$(jq -r '.head.sha' <<< "$PR_INFO")"
base_sha="$(jq -r '.base.sha // empty' <<< "$PR_INFO")"
labels_json="$(jq -c '[.labels[].name]' <<< "$PR_INFO")"
if [ -z "$REQUIRED_LABEL" ]; then
has_label=true
else
has_label="$(jq -r --arg L "$REQUIRED_LABEL" 'index($L) != null' <<< "$labels_json")"
fi
# Only trust copied pull-request/* pushes that still match the PR head
# SHA and, when configured, carry the required label.
if [ "$head_sha" = "$GITHUB_SHA_VALUE" ] && [ "$has_label" = "true" ]; then
should_run=true
else
should_run=false
fi
echo "labels_json=$labels_json" >> "$GITHUB_OUTPUT"
echo "should_run=$should_run" >> "$GITHUB_OUTPUT"
echo "base_sha=$base_sha" >> "$GITHUB_OUTPUT"