Add API check #9
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: API Breaking Change Check | ||
on: | ||
pull_request: | ||
branches: | ||
- 'releases/**' | ||
- dev | ||
jobs: | ||
api-check: | ||
name: API Breaking Change Check | ||
runs-on: windows-latest # Use Windows for PowerShell script execution | ||
outputs: | ||
api_check_status: ${{ steps.api-check.outcome }} # Capture step outcome | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 # Ensure full history for diff comparison | ||
- uses: dorny/paths-filter@v2 | ||
id: filter | ||
with: | ||
filters: | | ||
src: | ||
- 'src/**' | ||
- 'eng/**' | ||
- 'api/**' | ||
- '**.props' | ||
- '**.csproj' | ||
- '**.targets' | ||
- '*.sln' | ||
- name: Update SubModules | ||
if: steps.filter.outputs.src == 'true' | ||
run: git submodule update --init --recursive | ||
- name: Setup .NET | ||
uses: actions/setup-dotnet@v3 | ||
with: | ||
dotnet-version: '8.0.x' # Adjust as needed | ||
- name: Restore dependencies | ||
run: dotnet restore | ||
- name: Run API Export PowerShell Script | ||
run: | | ||
powershell -ExecutionPolicy Bypass -File .\eng\Export-API.ps1 *> export-api.log | ||
# Upload the log file as an artifact | ||
- name: Upload Export API Log as Artifact | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: export-api-log | ||
path: ./export-api.log | ||
- name: Check for API Changes | ||
id: api-check | ||
run: | | ||
git status | ||
git diff --exit-code api/ | ||
shell: bash | ||
continue-on-error: true | ||
check-label: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check for special label | ||
id: check_label | ||
run: | | ||
LABELS="${{ toJson(github.event.pull_request.labels) }}" | ||
echo "PR Labels: $LABELS" | ||
if echo "$LABELS" | grep -q '"api-breaking-change-signoff"'; then | ||
echo "api-breaking-change-signoff label found ✅" | ||
echo "HAS_SPECIAL_LABEL=true" >> $GITHUB_ENV | ||
else | ||
echo "api-breaking-change-signoff label not found ❌" | ||
echo "HAS_SPECIAL_LABEL=false" >> $GITHUB_ENV | ||
fi | ||
finalize-status: | ||
needs: [api-check, check-label] | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Determine merge eligibility | ||
run: | | ||
if [[ "${{ needs.ci-check.outputs.api_check_status }}" == "success" ]]; then | ||
echo "API check passed, no breaking changes detected ✅" | ||
exit 0 | ||
elif [[ "${{ env.HAS_SPECIAL_LABEL }}" == "true" ]]; then | ||
echo "Label api-breaking-change-signoff found, merge allowed ✅" | ||
exit 0 | ||
else | ||
echo "API breaking change detected, please ask for api-breaking-change-signoff" | ||
exit 1 | ||
fi |