tuhaihe commented on code in PR #1522:
URL: https://github.com/apache/cloudberry/pull/1522#discussion_r2681090465


##########
.github/workflows/binary-swap-check.yml:
##########
@@ -0,0 +1,675 @@
+# --------------------------------------------------------------------
+#
+# 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.
+#
+# --------------------------------------------------------------------
+# GitHub Actions Workflow: Apache Cloudberry Binary Swap Compatibility Check
+# --------------------------------------------------------------------
+#
+# This workflow detects binary/catalog incompatibilities by comparing the
+# current PR/push code against the latest release tag.
+#
+# Workflow:
+# 1. Resolve baseline: Find the latest release tag from REL_2_STABLE
+# 2. Build baseline: Build RPM from the baseline tag (parallel)
+# 3. Build current: Build RPM from current PR/push code (parallel)
+# 4. Binary swap test: Install baseline, create cluster, swap to current,
+#    verify data integrity
+#
+# Triggers:
+# - Pull requests to `REL_2_STABLE`
+# - Push to `REL_2_STABLE`
+# - Manual workflow dispatch
+#
+# --------------------------------------------------------------------
+
+name: Binary Swap Compatibility Check
+
+on:
+  push:
+    branches: [REL_2_STABLE]
+  pull_request:
+    branches: [REL_2_STABLE]
+    types: [opened, synchronize, reopened]
+  workflow_dispatch:
+    inputs:
+      baseline_ref:
+        description: 'Baseline ref to compare against (leave empty for 
auto-detect latest tag)'
+        required: false
+        default: ''
+        type: string
+
+concurrency:
+  group: binary-swap-${{ github.workflow }}-${{ github.ref }}
+  cancel-in-progress: true
+
+permissions:
+  contents: read
+  packages: read
+  actions: read
+
+env:
+  LOG_RETENTION_DAYS: 7
+  CBDB_INSTALL_DIR: /usr/local/cloudberry-db
+  BASELINE_INSTALL_DIR: /usr/local/cloudberry-db-baseline
+  CURRENT_INSTALL_DIR: /usr/local/cloudberry-db-current
+
+jobs:
+
+  ## ======================================================================
+  ## Job: resolve-baseline
+  ## ======================================================================
+
+  resolve-baseline:
+    name: Resolve Baseline Version
+    runs-on: ubuntu-22.04
+    outputs:
+      baseline_ref: ${{ steps.resolve.outputs.baseline_ref }}
+      baseline_version: ${{ steps.resolve.outputs.baseline_version }}
+    steps:
+      - name: Checkout (for git ls-remote)
+        uses: actions/checkout@v4
+        with:
+          fetch-depth: 1
+
+      - name: Resolve latest release tag
+        id: resolve
+        run: |
+          set -eo pipefail
+
+          # Use manual input if provided
+          if [[ -n "${{ github.event.inputs.baseline_ref }}" ]]; then
+            echo "Using manually specified baseline: ${{ 
github.event.inputs.baseline_ref }}"
+            echo "baseline_ref=${{ github.event.inputs.baseline_ref }}" >> 
"$GITHUB_OUTPUT"
+            echo "baseline_version=${{ github.event.inputs.baseline_ref }}" >> 
"$GITHUB_OUTPUT"
+            exit 0
+          fi
+
+          # Find the latest release tag
+          # Tag format: X.Y.Z-incubating (e.g., 2.0.0-incubating, 
2.1.0-incubating)
+          # Exclude RC versions: X.Y.Z-incubating-rcN
+          echo "Finding latest release tag..."
+          
+          # Get all tags matching the incubating pattern, sort by version, 
filter out RC versions
+          TAG_INFO=$(git ls-remote --tags --refs origin '*-incubating' 
2>/dev/null \
+            | grep -v '\-rc[0-9]*$' \
+            | sort -t'/' -k3 -V \
+            | tail -1 || echo "")
+
+          if [[ -z "$TAG_INFO" ]]; then
+            echo "::error::No release tags found matching pattern 
'*-incubating' (excluding RC versions)"
+            echo "::error::Expected format: X.Y.Z-incubating (e.g., 
2.0.0-incubating)"
+            exit 1
+          fi
+
+          BASELINE_REF=$(echo "$TAG_INFO" | awk '{print $1}')
+          BASELINE_VERSION=$(echo "$TAG_INFO" | awk '{print $2}' | sed 
's|refs/tags/||')
+
+          echo "Found baseline: ${BASELINE_VERSION} (${BASELINE_REF})"
+          echo "baseline_ref=${BASELINE_REF}" >> "$GITHUB_OUTPUT"
+          echo "baseline_version=${BASELINE_VERSION}" >> "$GITHUB_OUTPUT"
+
+  ## ======================================================================
+  ## Job: build-baseline
+  ## ======================================================================
+
+  build-baseline:
+    name: Build Baseline RPM
+    needs: [resolve-baseline]
+    runs-on: ubuntu-22.04
+    timeout-minutes: 120
+
+    container:
+      image: apache/incubator-cloudberry:cbdb-build-rocky9-latest
+      options: >-
+        --user root
+        -h cdw
+        -v /usr/share:/host_usr_share
+        -v /usr/local:/host_usr_local
+        -v /opt:/host_opt
+
+    steps:
+      - name: Free Disk Space
+        run: |
+          echo "=== Disk space before cleanup ==="
+          df -h /
+          rm -rf /host_opt/hostedtoolcache || true
+          rm -rf /host_usr_local/lib/android || true
+          rm -rf /host_usr_share/dotnet || true
+          rm -rf /host_opt/ghc || true
+          rm -rf /host_usr_local/.ghcup || true
+          rm -rf /host_usr_share/swift || true
+          rm -rf /host_usr_local/share/powershell || true
+          rm -rf /host_usr_local/share/chromium || true
+          rm -rf /host_usr_share/miniconda || true
+          rm -rf /host_opt/az || true
+          rm -rf /host_usr_share/sbt || true
+          echo "=== Disk space after cleanup ==="
+          df -h /
+
+      - name: Checkout Baseline Code
+        uses: actions/checkout@v4
+        with:
+          ref: ${{ needs.resolve-baseline.outputs.baseline_version }}

Review Comment:
   Now we don't have the RPM package for release 2.0 yet. So we need to create 
it when running the tests.



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