|
| 1 | +name: C ABI Compatibility Check |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_call: |
| 5 | + |
| 6 | +jobs: |
| 7 | + # Check PRs for breaking ABI changes |
| 8 | + check-pr: |
| 9 | + runs-on: ubuntu-latest |
| 10 | + steps: |
| 11 | + - name: Checkout PR branch |
| 12 | + uses: actions/checkout@v4 |
| 13 | + with: |
| 14 | + fetch-depth: 0 |
| 15 | + |
| 16 | + - name: Set up Python |
| 17 | + uses: actions/setup-python@v5 |
| 18 | + with: |
| 19 | + python-version: '3.11' |
| 20 | + |
| 21 | + - name: Install Python dependencies |
| 22 | + run: | |
| 23 | + pip install --upgrade pip |
| 24 | + pip install ci/check_c_abi |
| 25 | +
|
| 26 | + - name: Get dlpack dependency |
| 27 | + run: | |
| 28 | + git clone https://github.com/dmlc/dlpack |
| 29 | +
|
| 30 | + - name: Find merge base commit |
| 31 | + id: merge-base |
| 32 | + run: | |
| 33 | + git fetch origin main |
| 34 | + MERGE_BASE=$(git merge-base HEAD origin/main) |
| 35 | + echo "merge_base_sha=${MERGE_BASE}" >> $GITHUB_OUTPUT |
| 36 | + echo "Merge base commit: ${MERGE_BASE}" |
| 37 | +
|
| 38 | + - name: Try to download baseline for merge-base commit (most accurate) |
| 39 | + id: download-merge-base |
| 40 | + continue-on-error: true |
| 41 | + uses: dawidd6/action-download-artifact@8a338493df3d275e4a7a63bcff3b8fe97e51a927 # v19 |
| 42 | + with: |
| 43 | + name: c-abi-baseline-${{ steps.merge-base.outputs.merge_base_sha }} |
| 44 | + workflow: check-c-abi.yaml |
| 45 | + commit: ${{ steps.merge-base.outputs.merge_base_sha }} |
| 46 | + path: baseline/ |
| 47 | + |
| 48 | + - name: Try to download latest main baseline (fallback 1) |
| 49 | + id: download-main |
| 50 | + if: steps.download-merge-base.outcome == 'failure' |
| 51 | + continue-on-error: true |
| 52 | + uses: dawidd6/action-download-artifact@8a338493df3d275e4a7a63bcff3b8fe97e51a927 # v19 |
| 53 | + with: |
| 54 | + name: c-abi-baseline-main |
| 55 | + workflow: check-c-abi.yaml |
| 56 | + branch: main |
| 57 | + path: baseline/ |
| 58 | + |
| 59 | + - name: Extract baseline ABI from main branch (fallback 2) |
| 60 | + if: steps.download-merge-base.outcome == 'failure' && steps.download-main.outcome == 'failure' |
| 61 | + run: | |
| 62 | + echo "⚠️ No baseline artifacts found, extracting from main branch..." |
| 63 | + echo "This is slower but ensures we always have a baseline for comparison." |
| 64 | + git worktree add ../cuvs-main main |
| 65 | + mkdir -p baseline |
| 66 | + check-c-abi extract \ |
| 67 | + --header-path ../cuvs-main/c/include \ |
| 68 | + --include-file cuvs/core/all.h \ |
| 69 | + --output-file baseline/c_abi.json.gz \ |
| 70 | + --dlpack-include-path dlpack/include |
| 71 | +
|
| 72 | + echo "✓ Baseline ABI extracted from main branch" |
| 73 | +
|
| 74 | + - name: Report baseline source |
| 75 | + run: | |
| 76 | + if [ "$DOWNLOAD_MERGE_BASE_OUTCOME" == "success" ]; then |
| 77 | + echo "✓ Using baseline from merge-base commit: $MERGE_BASE_SHA" |
| 78 | + elif [ "$DOWNLOAD_MAIN_OUTCOME" == "success" ]; then |
| 79 | + echo "✓ Using latest main baseline (merge-base baseline not yet available)" |
| 80 | + else |
| 81 | + echo "✓ Using freshly extracted baseline from main branch" |
| 82 | + fi |
| 83 | + env: |
| 84 | + DOWNLOAD_MERGE_BASE_OUTCOME: ${{ steps.download-merge-base.outcome }} |
| 85 | + MERGE_BASE_SHA: ${[ steps.merge-base.outputs.merge_base_sha }} |
| 86 | + DOWNLOAD_MAIN_OUTCOME: ${{ steps.download-main.outcome }} |
| 87 | + |
| 88 | + - name: Analyze current branch for ABI breaking changes |
| 89 | + run: | |
| 90 | + check-c-abi analyze \ |
| 91 | + --abi-file baseline/c_abi.json.gz \ |
| 92 | + --header-path c/include \ |
| 93 | + --include-file cuvs/core/all.h \ |
| 94 | + --dlpack-include-path dlpack/include |
| 95 | +
|
| 96 | + - name: Comment on PR with results |
| 97 | + if: failure() |
| 98 | + uses: actions/github-script@v7 |
| 99 | + with: |
| 100 | + script: | |
| 101 | + github.rest.issues.createComment({ |
| 102 | + issue_number: context.issue.number, |
| 103 | + owner: context.repo.owner, |
| 104 | + repo: context.repo.repo, |
| 105 | + body: `## ⚠️ C ABI Breaking Changes Detected |
| 106 | + This PR introduces breaking changes to the C ABI. Please review the changes carefully. |
| 107 | +
|
| 108 | + Breaking ABI changes are only allowed in major releases. If this is intentional for a major release, |
| 109 | + the baseline ABI will need to be updated after merge. |
| 110 | +
|
| 111 | + See the job logs for details on what specific changes were detected. |
| 112 | +
|
| 113 | + ### What are breaking ABI changes? |
| 114 | +
|
| 115 | + Breaking ABI changes include: |
| 116 | + - Removing functions from the public API |
| 117 | + - Changing function signatures (parameters or return types) |
| 118 | + - Removing struct members or changing their types |
| 119 | + - Removing or changing enum values |
| 120 | +
|
| 121 | + ### Next steps |
| 122 | +
|
| 123 | + 1. Review the changes flagged in the CI logs |
| 124 | + 2. If these changes are unintentional, update your PR to maintain ABI compatibility |
| 125 | + 3. If these changes are required, ensure: |
| 126 | + - This is part of a major version release |
| 127 | + - The changes are documented in the changelog |
| 128 | + - Migration guide is provided for users |
| 129 | +
|
| 130 | + For more information, see the [C ABI documentation](../docs/source/c_developer_guide.md).` |
| 131 | + }); |
0 commit comments