zeroshade commented on code in PR #2166:
URL: https://github.com/apache/iceberg-go/pull/2166#discussion_r4258149607


##########
dev/check-api-compat.sh:
##########
@@ -0,0 +1,131 @@
+#!/usr/bin/env bash
+
+# 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.
+
+# Reports incompatible changes to the module's exported API between a base
+# revision and the working tree, using golang.org/x/exp/cmd/apidiff.
+#
+# Usage: dev/check-api-compat.sh [BASE_REF]   (default: origin/main)
+#
+# Run from the repository root. Exits 0 when the API is compatible with
+# BASE_REF. When it is not, the changes are printed and the exit status is 1,
+# unless PR_TITLE is set and marks the change as breaking with a
+# Conventional Commits "!" (for example "refactor(io)!: ..."), in which case
+# the changes are reported and the exit status is 0.
+#
+# Exit status: 0 compatible (or breaking and declared), 1 undeclared
+# incompatible changes, 2 the check itself could not run (for example the base
+# or the working tree does not build).
+#
+# When GITHUB_STEP_SUMMARY is set, the report is also appended to it.
+#
+# apidiff only sees the API for the host platform and default build tags, and
+# it does not detect behavior changes, so a pass is not a full compatibility
+# guarantee.
+
+set -euo pipefail
+
+BASE_REF="${1:-origin/main}"

Review Comment:
   Nit: the default base is `origin/main`, but most contributors' `origin` is 
their fork, whose `main` can be stale, so a local run can report breaks that 
aren't in the PR. Either default to the remote whose URL is 
`apache/iceberg-go`, or say "pass `upstream/main`" in the usage line and the 
CONTRIBUTING note.



##########
.github/workflows/api-compat.yml:
##########
@@ -0,0 +1,82 @@
+# 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 compatibility
+
+on:
+  pull_request:
+    # edited re-runs the check when the title gains or loses its "!" marker.
+    types: [opened, synchronize, reopened, edited]

Review Comment:
   Nit: `edited` also fires on body-only edits, which re-runs a full two-tree 
`apidiff` for nothing. `if: github.event.action != 'edited' || 
github.event.changes.title || github.event.changes.base` on the job keeps title 
and base retargeting while skipping description edits.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to