Skip to content

Commit 7dec856

Browse files
authored
feat: initialization of API backward compatibility verification (#2310)
Signed-off-by: Pablo Garay <[email protected]>
1 parent dc473f9 commit 7dec856

File tree

1 file changed

+30
-14
lines changed

1 file changed

+30
-14
lines changed

.github/workflows/check_api_backwards_compatibility_workflow.yml

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,28 @@ on:
1313
workflow_dispatch:
1414
inputs:
1515
baseline:
16-
description: 'Baseline git reference (tag/branch)'
16+
description: 'Baseline git reference (tag/branch/commit)'
1717
required: true
1818

1919
jobs:
2020
check-compatibility:
2121
name: Check API Backward Compatibility
2222
runs-on: ubuntu-latest
2323

24+
# ============================================================================
25+
# Configuration Parameters (modify here)
26+
# ============================================================================
27+
env:
28+
# Default baseline for automatic PR checks
29+
# Can be: branch name (e.g., 'main'), commit hash, or tag
30+
# Will be resolved to commit hash during execution
31+
DEFAULT_BASELINE: '712dff880cdf88e51289ad71e47d92f46d25a2d3'
32+
# Tag pattern for auto-detection (e.g., 'core_r*', 'core_v*')
33+
TAG_PATTERN: 'core_v*'
34+
# Tag regex filter (e.g., '^core_v[0-9]+\.[0-9]+\.[0-9]+$' for stable versions only)
35+
TAG_REGEX_FILTER: '^core_v[0-9]+\.[0-9]+\.[0-9]+$'
36+
# ============================================================================
37+
2438
steps:
2539
- name: Checkout code
2640
uses: actions/checkout@v4
@@ -44,21 +58,25 @@ jobs:
4458
id: baseline
4559
run: |
4660
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
47-
# Use manually specified baseline
48-
BASELINE="${{ github.event.inputs.baseline }}"
61+
# Use manually specified baseline (branch, tag, or commit hash)
62+
BASELINE_REF="${{ github.event.inputs.baseline }}"
4963
else
50-
# Auto-detect latest core release tag (stable versions only, no rc)
51-
BASELINE=$(git tag -l 'core_v*' | grep -E '^core_v[0-9]+\.[0-9]+\.[0-9]+$' | sort -V | tail -1)
64+
# Use the configured default baseline
65+
BASELINE_REF="${{ env.DEFAULT_BASELINE }}"
5266
53-
# Error out if no tags found
54-
if [ -z "$BASELINE" ]; then
55-
echo "Error: No core_v* release tags found. Cannot determine baseline." >&2
56-
exit 1
57-
fi
67+
# Uncomment below to auto-detect from tags instead:
68+
# BASELINE_REF=$(git tag -l '${{ env.TAG_PATTERN }}' | grep -E '${{ env.TAG_REGEX_FILTER }}' | sort -V | tail -1)
69+
# if [ -z "$BASELINE_REF" ]; then
70+
# echo "Warning: No tags matching pattern found. Using default: ${{ env.DEFAULT_BASELINE }}" >&2
71+
# BASELINE_REF="${{ env.DEFAULT_BASELINE }}"
72+
# fi
5873
fi
5974
60-
echo "baseline=$BASELINE" >> $GITHUB_OUTPUT
61-
echo "Using baseline: $BASELINE"
75+
# Resolve baseline to commit hash (works for branches, tags, or commit hashes)
76+
BASELINE_HASH=$(git rev-parse "$BASELINE_REF")
77+
78+
echo "baseline=$BASELINE_HASH" >> $GITHUB_OUTPUT
79+
echo "Using baseline: $BASELINE_REF (resolved to commit: $BASELINE_HASH)"
6280
6381
- name: Run compatibility check
6482
id: compat_check
@@ -77,7 +95,6 @@ jobs:
7795
- name: Fail job if breaking changes detected
7896
if: steps.compat_check.outcome == 'failure'
7997
run: |
80-
echo "::group::❌ API Backward Compatibility Check Failed"
8198
echo ""
8299
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
83100
echo "🔍 WHAT IS THIS CHECK?"
@@ -143,7 +160,6 @@ jobs:
143160
echo "🔧 Checker script: scripts/check_api_backwards_compatibility.py"
144161
echo "❓ Questions? Check the docs or ask in #megatron-core"
145162
echo ""
146-
echo "::endgroup::"
147163
148164
echo "::error::Breaking API changes detected. Please review the output above and choose a resolution strategy."
149165
exit 1

0 commit comments

Comments
 (0)