rluvaton commented on code in PR #21499:
URL: https://github.com/apache/datafusion/pull/21499#discussion_r3146668189


##########
ci/scripts/changed_crates.sh:
##########
@@ -0,0 +1,137 @@
+#!/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.
+
+# Helper script for the breaking-changes-detector workflow.
+#
+# Subcommands:
+#   changed-crates <base_ref>
+#       Print space-separated list of crate names whose files changed vs 
base_ref.
+#
+#   semver-check <base_ref> <packages...>
+#       Run cargo-semver-checks for the given packages against base_ref.
+#       Prints the (ANSI-stripped) log output to stdout.
+#       Exit code matches cargo-semver-checks (0 = pass, non-zero = breaking).
+#
+#   comment <repo> <pr_number> <check_result> [logs]
+#       Upsert or delete a sticky PR comment based on check_result.
+#       check_result: "success" deletes any existing comment,
+#                     anything else upserts the comment with the provided logs.
+#       Requires GH_TOKEN to be set.
+
+set -euo pipefail
+
+MARKER="<!-- semver-check-comment -->"
+
+# ── changed-crates ──────────────────────────────────────────────────
+cmd_changed_crates() {
+  local base_ref="${1:?Usage: changed_crates.sh changed-crates <base_ref>}"
+
+  # Parse workspace members from root Cargo.toml, excluding internal crates
+  # that are not published / not part of the public API.
+  local members
+  members=$(sed -n '/^members = \[/,/\]/p' Cargo.toml | grep '"' | sed 
's/.*"\(.*\)".*/\1/' \
+    | grep -v -e '^benchmarks$' -e '^test-utils$' -e 
'^datafusion/sqllogictest$' -e '^datafusion/doc$')
+
+  local changed_files
+  changed_files=$(git diff --name-only "${base_ref}...HEAD")
+
+  local packages=""
+  for member in $members; do
+    if echo "$changed_files" | grep -q "^${member}/"; then
+      local pkg
+      pkg=$(grep '^name\s*=' "$member/Cargo.toml" | head -1 | sed 
's/.*=\s*"\(.*\)"/\1/')
+      if [ -n "$pkg" ]; then
+        packages="$packages $pkg"
+      fi
+    fi
+  done
+
+  echo "$packages" | xargs
+}
+
+# ── semver-check ────────────────────────────────────────────────────
+cmd_semver_check() {
+  local base_ref="${1:?Usage: changed_crates.sh semver-check <base_ref> 
<packages...>}"
+  shift
+
+  local args=""
+  for pkg in "$@"; do
+    args="$args --package $pkg"
+  done
+
+  set +e
+  # Compare the PR's code against the base branch to detect breaking changes.
+  # Use tee to show output in the Actions log while also capturing it.
+  cargo semver-checks --baseline-rev "$base_ref" $args 2>&1 | tee 
/tmp/semver-output.txt
+  local exit_code=${PIPESTATUS[0]}
+  set -e
+
+  # Strip ANSI escape codes from the captured output for the PR comment.
+  sed 's/\x1b\[[0-9;]*m//g' /tmp/semver-output.txt
+  return "$exit_code"
+}

Review Comment:
   fixed and verified



-- 
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