This is an automated email from the ASF dual-hosted git repository. github-merge-queue[bot] pushed a commit to branch gh-readonly-queue/main/pr-11949-e57434dd358225790eb7d7508c4b2b5a5aa4c1b2 in repository https://gitbox.apache.org/repos/asf/arrow-rs.git
commit 8b5a96cc3dbb91f50fa1429314425deaac97c335 Author: Kosta Tarasov <[email protected]> AuthorDate: Wed Nov 4 17:51:12 2026 +0000 ci: automatically label breaking API changes (#11949) # Which issue does this PR close? Closes #5791. # What changes are included in this PR? Uses `cargo-semver-checks` to compare public APIs with the checked-out PR merge commit’s first parent, even when crate versions change. This uses the exact target revision included in the merge, avoiding stale event metadata. The existing `dev_pr` workflow adds `api-change` for detected breakage without failing the check or enforcing release phases. Build and tool errors still fail; labels are never automatically removed. Scans run on non-draft PRs touching Rust or build inputs, including when marked ready for review. The scan has read-only permissions; the labeling job never checks out PR code. Coverage includes all features on Linux except Parquet, which uses default features to avoid a reproduced sync/async false positive. # Are these changes tested? Validated through fork PRs because the behavior depends on GitHub events and token permissions. [Draft code PRs](https://github.com/sdf-jkl/arrow-rs/pull/12) skipped scanning until marked ready, and a [docs-only PR](https://github.com/sdf-jkl/arrow-rs/pull/13) launched no scan. Both code scans passed across 24 libraries; only the [deliberate API break](https://github.com/sdf-jkl/arrow-rs/pull/11) received `api-change` from `github-actions[bot]`. No repository tests were added. The [fork cache probe](https://github.com/sdf-jkl/arrow-rs/actions/runs/41517206293) reproduced the cache cleanup failure on root-owned generated manifests and verified that excluding `target/**` lets the cache save successfully. The baseline fix was tested locally against the original CI merge: the stale baseline reproduced the `VariantType` finding, the merge-parent baseline passed, and a deliberate API removal still produced `breaking=true`. The [updated API scan](https://github.com/apache/arrow-rs/actions/runs/41528294312) passed all 24 libraries with no breaking changes detected. # Are there any significant user-facing changes? No library API changes. Implementation and validation were prepared with Codex. --------- Co-authored-by: Claude Opus 5.5 <[email protected]> --- .github/actions/setup-builder/action.yaml | 3 +- .github/workflows/api_change.yml | 84 +++++++++++++++++++++++++++++++ .github/workflows/dev_pr.yml | 51 ++++++++++++++++--- CONTRIBUTING.md | 4 ++ 4 files changed, 135 insertions(+), 7 deletions(-) diff --git a/.github/actions/setup-builder/action.yaml b/.github/actions/setup-builder/action.yaml index 81d2b09ba8..2f0dff0621 100644 --- a/.github/actions/setup-builder/action.yaml +++ b/.github/actions/setup-builder/action.yaml @@ -32,7 +32,8 @@ runs: /usr/local/cargo/registry/index/ /usr/local/cargo/registry/cache/ /usr/local/cargo/git/db/ - key: cargo-cache3-${{ hashFiles('**/Cargo.toml') }} + # API scans create root-only baseline manifests under target in the container. + key: cargo-cache3-${{ hashFiles('**/Cargo.toml', '!target/**') }} restore-keys: cargo-cache3- - name: Setup Rust toolchain shell: bash diff --git a/.github/workflows/api_change.yml b/.github/workflows/api_change.yml new file mode 100644 index 0000000000..7995747c56 --- /dev/null +++ b/.github/workflows/api_change.yml @@ -0,0 +1,84 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +name: API changes + +on: + pull_request: + types: [opened, synchronize, reopened, ready_for_review] + paths: + - '**/*.rs' + - '**/Cargo.toml' + - '**/Cargo.lock' + - rust-toolchain.toml + - .cargo/** + - .github/workflows/api_change.yml + +permissions: + contents: read + +concurrency: + group: ${{ github.repository }}-${{ github.event.pull_request.number }}-${{ github.workflow }} + cancel-in-progress: true + +jobs: + check: + if: '!github.event.pull_request.draft' + name: Detect API changes + runs-on: ubuntu-latest + container: + image: amd64/rust + timeout-minutes: 60 + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + fetch-depth: 0 + persist-credentials: false + - name: Setup Rust toolchain + uses: ./.github/actions/setup-builder + - name: Install cargo-semver-checks + uses: taiki-e/install-action@a4d3f3f761dcd95cce1b72cb61cb6d1963438177 # v2.87.30 + with: + tool: cargo-semver-checks + - name: Compare public APIs with the target commit + id: compare + shell: bash + # The event's base SHA can lag behind the checked-out PR merge commit. + # Its first parent is the exact target commit used for this merge. + # Force detection even if the PR bumps Cargo versions. + run: | + base_sha=$(git rev-parse HEAD^1) + check_api() { + local status=0 + cargo semver-checks check-release --baseline-rev "$base_sha" \ + --release-type minor "$@" || status=$? + case "$status" in + 0) ;; + 100) echo 'breaking=true' >> "$GITHUB_OUTPUT" ;; + *) return "$status" ;; + esac + } + check_api --workspace --exclude parquet --all-features + # With async enabled, cargo-semver-checks confuses the sync (&self) and async + # (&mut self) get_row_group_column_bloom_filter methods on identical source. + # Scan parquet with the rest of the workspace once this is fixed: + # https://github.com/obi1kenobi/cargo-semver-checks/issues/1781 + check_api -p parquet --default-features + # dev_pr.yml reads this step's conclusion through the Actions API. + - name: API changes detected + if: steps.compare.outputs.breaking == 'true' + run: echo 'Breaking API changes detected; dev_pr will add api-change.' diff --git a/.github/workflows/dev_pr.yml b/.github/workflows/dev_pr.yml index 06bd87d923..9c67052305 100644 --- a/.github/workflows/dev_pr.yml +++ b/.github/workflows/dev_pr.yml @@ -18,19 +18,23 @@ name: dev_pr concurrency: - group: ${{ github.repository }}-${{ github.event.pull_request.number }}-${{ github.workflow }} + group: ${{ github.repository }}-${{ github.event_name }}-${{ github.event.pull_request.number || github.event.workflow_run.id }}-${{ github.workflow }} cancel-in-progress: true -# Trigger whenever a PR is changed (title as well as new / changed commits) +# Process PR changes and completed API scans. on: pull_request_target: types: - opened - edited - synchronize + workflow_run: + workflows: [API changes] + types: [completed] jobs: process: + if: github.event_name == 'pull_request_target' name: Process runs-on: ubuntu-slim permissions: @@ -40,10 +44,7 @@ jobs: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - name: Assign GitHub labels - if: | - github.event_name == 'pull_request_target' && - (github.event.action == 'opened' || - github.event.action == 'synchronize') + if: github.event.action == 'opened' || github.event.action == 'synchronize' uses: actions/labeler@bf12e9b00b37c5c0ca2b87b79b2daf7891dbda13 # v7.0.0 with: repo-token: ${{ secrets.GITHUB_TOKEN }} @@ -92,3 +93,41 @@ jobs: labels: labelsToCopy, }); } + + label-api-change: + name: Label API changes + if: >- + github.event_name == 'workflow_run' && + github.event.workflow_run.event == 'pull_request' && + github.event.workflow_run.conclusion == 'success' + runs-on: ubuntu-slim + permissions: + actions: read + pull-requests: write + steps: + # Never check out PR code in this job: it has permission to add labels. + - uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 + with: + script: | + const run = context.payload.workflow_run; + if (run.path !== '.github/workflows/api_change.yml' || !run.head_repository) return; + const jobs = await github.paginate(github.rest.actions.listJobsForWorkflowRun, { + ...context.repo, run_id: run.id, filter: 'latest', per_page: 100, + }); + if (!jobs.some(job => job.steps?.some(step => + step.name === 'API changes detected' && step.conclusion === 'success'))) return; + + // Fork PRs may be missing from workflow_run.pull_requests. Resolve + // them through the API and ignore runs for an outdated PR head. + const prs = await github.paginate(github.rest.pulls.list, { + ...context.repo, state: 'open', + head: run.head_repository.owner.login + ':' + run.head_branch, + per_page: 100, + }); + for (const pr of prs) { + if (pr.head.sha !== run.head_sha || + pr.head.repo?.full_name !== run.head_repository.full_name) continue; + await github.rest.issues.addLabels({ + ...context.repo, issue_number: pr.number, labels: ['api-change'], + }); + } diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index c47dc7ad38..edd4ffbaad 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -233,6 +233,10 @@ This means that if your PR has a breaking API change, it should be marked as `api-change` and it will not be merged until development opens for the next major release. See [this ticket] for details. +CI uses `cargo-semver-checks` to add `api-change` for detected breakage without +failing the check. Manual review is still needed, especially for Parquet features +outside its defaults. + [release schedule]: README.md#release-versioning-and-schedule [this ticket]: https://github.com/apache/arrow-rs/issues/5907
