Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions src/notify/pr-validation-reporter/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,53 @@ Posts a single mergeability summary comment aggregating all PR validation check
| `size-result` | Result of PR size check | No | `skipped` |
| `label-result` | Result of auto-label step | No | `skipped` |
| `metadata-result` | Result of PR metadata check | No | `skipped` |
| `breaking-change-result` | Result of the blocking breaking change guard | No | `skipped` |
| `dry-run` | When `true`, skip posting the summary comment | No | `false` |

When `breaking-change-result` is `skipped` or omitted, the report omits the guard row and preserves existing mergeability behavior. This optional default exists only for backward compatibility with direct action consumers. The mandatory `pr-validation` integration always supplies the guard result and offers no guard opt-out. When supplied, only `success` is mergeable.

## Outputs

| Output | Description |
|--------|-------------|
| `has-breaking-change-guard` | Whether the breaking change guard result was reported, i.e. `breaking-change-result` was not `skipped` (`true`/`false`) |

## Usage as composite step

The `blocking-checks` job must define a `breaking-change-result` output normalized to `success`/`failure`/`cancelled`/`skipped`, derived from the [`breaking-change-guard`](../../validate/breaking-change-guard/README.md) step:

```yaml
jobs:
blocking-checks:
runs-on: blacksmith-4vcpu-ubuntu-2404
outputs:
# ...other check outputs...
breaking-change-result: ${{ steps.breaking-change-result.outputs.result }}
steps:
# ...other checks...
- name: Breaking Change Guard
id: breaking-change-guard
uses: LerianStudio/github-actions-shared-workflows/src/validate/breaking-change-guard@v1.x.x
with:
base-ref: ${{ github.base_ref }}
breaking-change-acknowledgement: 'BREAKING CHANGE APPROVED'
- name: Resolve breaking change result
id: breaking-change-result
if: always()
env:
GUARD_OUTCOME: ${{ steps.breaking-change-guard.outcome }}
HAS_BREAKING_CHANGES: ${{ steps.breaking-change-guard.outputs.has-breaking-changes }}
APPROVED: ${{ steps.breaking-change-guard.outputs.approved }}
run: |
set -euo pipefail
if [ "$GUARD_OUTCOME" != "success" ]; then
echo "result=$GUARD_OUTCOME" >> "$GITHUB_OUTPUT"
elif [ "$HAS_BREAKING_CHANGES" = "true" ] && [ "$APPROVED" != "true" ]; then
echo "result=failure" >> "$GITHUB_OUTPUT"
else
echo "result=success" >> "$GITHUB_OUTPUT"
fi

pr-validation-report:
runs-on: blacksmith-4vcpu-ubuntu-2404
needs: [blocking-checks, advisory-checks]
Expand All @@ -39,6 +80,7 @@ jobs:
size-result: ${{ needs.advisory-checks.outputs.size-result }}
label-result: ${{ needs.advisory-checks.outputs.label-result }}
metadata-result: ${{ needs.advisory-checks.outputs.metadata-result }}
breaking-change-result: ${{ needs.blocking-checks.outputs.breaking-change-result }}
```

## Required permissions
Expand Down
36 changes: 35 additions & 1 deletion src/notify/pr-validation-reporter/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,36 @@ inputs:
description: Result of PR metadata check (success/failure/skipped)
required: false
default: "skipped"
breaking-change-result:
description: Result of breaking change guard (success/failure/cancelled/skipped)
required: false
default: skipped
Comment thread
coderabbitai[bot] marked this conversation as resolved.
dry-run:
description: When true, skip posting the summary comment
required: false
default: "false"

outputs:
has-breaking-change-guard:
description: Whether the breaking change guard result was reported (true/false)
value: ${{ steps.guard-state.outputs.has-breaking-change-guard }}

runs:
using: composite
steps:
- name: Resolve breaking change guard state
id: guard-state
shell: bash
env:
BREAKING_CHANGE_RESULT: ${{ inputs.breaking-change-result }}
run: |
set -euo pipefail
if [ "$BREAKING_CHANGE_RESULT" != "skipped" ]; then
echo "has-breaking-change-guard=true" >> "$GITHUB_OUTPUT"
else
echo "has-breaking-change-guard=false" >> "$GITHUB_OUTPUT"
fi

- name: Post PR validation summary
if: inputs.dry-run != 'true'
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8
Expand All @@ -47,6 +69,7 @@ runs:
SIZE_RESULT: ${{ inputs.size-result }}
LABEL_RESULT: ${{ inputs.label-result }}
METADATA_RESULT: ${{ inputs.metadata-result }}
BREAKING_CHANGE_RESULT: ${{ inputs.breaking-change-result }}
with:
github-token: ${{ inputs.github-token }}
script: |
Expand All @@ -59,9 +82,20 @@ runs:
{ label: 'PR Metadata', result: process.env.METADATA_RESULT, blocking: false },
];

if (process.env.BREAKING_CHANGE_RESULT !== 'skipped') {
checks.splice(3, 0, {
label: 'Breaking Change Guard',
result: process.env.BREAKING_CHANGE_RESULT,
blocking: true,
strict: true,
});
}

const icon = (r) => ({ success: '✅', failure: '❌', skipped: '⏭️' }[r] ?? '⚠️');

const blockingFailures = checks.filter(c => c.blocking && c.result === 'failure');
const blockingFailures = checks.filter(c =>
c.blocking && (c.strict ? c.result !== 'success' : c.result === 'failure')
);
const verdictHeader = blockingFailures.length > 0
? `## 🚫 PR Blocked — ${blockingFailures.length} blocking failure${blockingFailures.length === 1 ? '' : 's'}\n\n`
: `## ✅ PR Mergeable — no blocking failures\n\n`;
Expand Down
10 changes: 10 additions & 0 deletions src/validate/pr-checks-summary/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,17 @@ Generates a summary table of all PR validation check results in the GitHub Actio
| `size-result` | Result of PR size check | No | `skipped` |
| `label-result` | Result of auto-label step | No | `skipped` |
| `metadata-result` | Result of PR metadata check | No | `skipped` |
| `breaking-change-result` | Result of the breaking change guard | No | `skipped` |
| `dry-run` | Whether this is a dry run | No | `false` |

When `breaking-change-result` is `skipped` or omitted, the summary omits the guard row and preserves existing behavior. This optional default exists only for backward compatibility with direct action consumers. The mandatory `pr-validation` integration always supplies the guard result and offers no guard opt-out.

Comment thread
coderabbitai[bot] marked this conversation as resolved.
## Outputs

| Output | Description |
|--------|-------------|
| `has-breaking-change-guard` | Whether the breaking change guard result was reported, i.e. `breaking-change-result` was not `skipped` (`true`/`false`) |

## Usage as composite step

```yaml
Expand All @@ -37,6 +46,7 @@ jobs:
size-result: ${{ needs.advisory-checks.outputs.size-result || 'skipped' }}
label-result: ${{ needs.advisory-checks.outputs.label-result || 'skipped' }}
metadata-result: ${{ needs.advisory-checks.outputs.metadata-result || 'skipped' }}
breaking-change-result: ${{ needs.blocking-checks.outputs.breaking-change-result }}
dry-run: "true"
```

Expand Down
31 changes: 29 additions & 2 deletions src/validate/pr-checks-summary/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,36 @@ inputs:
description: Result of PR metadata check
required: false
default: skipped
breaking-change-result:
description: Result of breaking change guard
required: false
default: skipped
dry-run:
description: Whether this is a dry run
required: false
default: "false"

outputs:
has-breaking-change-guard:
description: Whether the breaking change guard result was reported (true/false)
value: ${{ steps.guard-state.outputs.has-breaking-change-guard }}

runs:
using: composite
steps:
- name: Resolve breaking change guard state
id: guard-state
shell: bash
env:
BREAKING_CHANGE_RESULT: ${{ inputs.breaking-change-result }}
run: |
set -euo pipefail
if [ "$BREAKING_CHANGE_RESULT" != "skipped" ]; then
echo "has-breaking-change-guard=true" >> "$GITHUB_OUTPUT"
else
echo "has-breaking-change-guard=false" >> "$GITHUB_OUTPUT"
fi

- name: Summary
shell: bash
env:
Expand All @@ -43,13 +65,15 @@ runs:
DESCRIPTION_RESULT: ${{ inputs.description-result }}
LABEL_RESULT: ${{ inputs.label-result }}
METADATA_RESULT: ${{ inputs.metadata-result }}
BREAKING_CHANGE_RESULT: ${{ inputs.breaking-change-result }}
DRY_RUN: ${{ inputs.dry-run }}
run: |
icon() {
case "$1" in
success) echo "✅" ;;
failure) echo "❌" ;;
*) echo "⏭️" ;;
failure|cancelled) echo "❌" ;;
skipped) echo "⏭️" ;;
*) echo "⚠️" ;;
esac
}

Expand All @@ -67,6 +91,9 @@ runs:
echo "| Source Branch | $(icon "$SOURCE_BRANCH_RESULT") ${SOURCE_BRANCH_RESULT} |"
echo "| PR Title | $(icon "$TITLE_RESULT") ${TITLE_RESULT} |"
echo "| PR Description | $(icon "$DESCRIPTION_RESULT") ${DESCRIPTION_RESULT} |"
if [ "$BREAKING_CHANGE_RESULT" != "skipped" ]; then
echo "| Breaking Change Guard | $(icon "$BREAKING_CHANGE_RESULT") ${BREAKING_CHANGE_RESULT} |"
fi
echo ""
echo "### Advisory"
echo ""
Expand Down
Loading