This is an automated email from the ASF dual-hosted git repository.
XiaoHongbo-Hope pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/paimon-mosaic.git
The following commit(s) were added to refs/heads/main by this push:
new 1b834ba fix(release): isolate Java staging downloads (#96)
1b834ba is described below
commit 1b834ba84aba6d590df1a52c2e17a4fbe7fdecb5
Author: jianguotian <[email protected]>
AuthorDate: Wed Oct 21 10:15:17 2026 +0800
fix(release): isolate Java staging downloads (#96)
---
tools/deploy_java_staging.sh | 21 +++++++++++---
tools/tests/deploy_java_staging_test.sh | 51 +++++++++++++++++++++++++++++----
2 files changed, 62 insertions(+), 10 deletions(-)
diff --git a/tools/deploy_java_staging.sh b/tools/deploy_java_staging.sh
index f4737d4..c79042b 100755
--- a/tools/deploy_java_staging.sh
+++ b/tools/deploy_java_staging.sh
@@ -218,8 +218,6 @@ if [[ ! "$RUN_ID" =~ ^[1-9][0-9]*$ ]]; then
exit 1
fi
-NATIVE_DIR="$SCRIPT_DIR/release/java-native-${TAG}"
-
if [[ -n "$MAVEN_SETTINGS" && ! -f "$MAVEN_SETTINGS" ]]; then
echo "--maven-settings does not exist: $MAVEN_SETTINGS" >&2
exit 1
@@ -332,8 +330,20 @@ fi
validate_github_run
-rm -rf "$NATIVE_DIR"
-mkdir -p "$NATIVE_DIR"
+cleanup_download_dir() {
+ if [[ -n "$NATIVE_DIR" ]]; then
+ rm -rf "$NATIVE_DIR"
+ fi
+}
+
+cleanup_download_only() {
+ local status=$?
+ cleanup_download_dir
+ exit "$status"
+}
+trap cleanup_download_only EXIT
+
+NATIVE_DIR=$(mktemp -d "${TMPDIR:-/tmp}/paimon-mosaic-java-staging.XXXXXX")
for artifact in \
native-linux-x86_64 \
native-linux-aarch64 \
@@ -455,8 +465,11 @@ xml_escape() {
}
cleanup_all() {
+ local status=$?
+ cleanup_download_dir
cleanup_native_resources
cleanup_temp_settings
+ exit "$status"
}
trap cleanup_all EXIT
diff --git a/tools/tests/deploy_java_staging_test.sh
b/tools/tests/deploy_java_staging_test.sh
index 9e08c2b..1683df5 100755
--- a/tools/tests/deploy_java_staging_test.sh
+++ b/tools/tests/deploy_java_staging_test.sh
@@ -52,7 +52,12 @@ new_fixture() {
FIXTURES=$((FIXTURES + 1))
MOCK_BIN="$FIXTURE/mock-bin"
MOCK_LOG="$FIXTURE/mock.log"
- mkdir -p "$FIXTURE/tools"
"$FIXTURE/java/src/test/java/org/apache/paimon/mosaic" "$MOCK_BIN"
+ STAGE_TMPDIR="$FIXTURE/tmp"
+ mkdir -p \
+ "$FIXTURE/tools" \
+ "$FIXTURE/java/src/test/java/org/apache/paimon/mosaic" \
+ "$MOCK_BIN" \
+ "$STAGE_TMPDIR"
cp "$SOURCE_REPO/tools/deploy_java_staging.sh" "$FIXTURE/tools/"
cp
"$SOURCE_REPO/java/src/test/java/org/apache/paimon/mosaic/MosaicNativeLoaderSmokeTest.java"
\
"$FIXTURE/java/src/test/java/org/apache/paimon/mosaic/"
@@ -84,6 +89,9 @@ while [[ $# -gt 0 ]]; do
*) shift ;;
esac
done
+if [[ -n "${FAIL_DOWNLOAD_ARTIFACT:-}" && "$name" == "$FAIL_DOWNLOAD_ARTIFACT"
]]; then
+ exit 41
+fi
mkdir -p "$dir"
case "$name" in
native-linux-x86_64) file=libpaimon_mosaic_jni.so ;;
@@ -192,10 +200,12 @@ PY
run_stage() {
env \
PATH="$MOCK_BIN:$PATH" \
+ TMPDIR="$STAGE_TMPDIR" \
MOCK_LOG="$MOCK_LOG" \
MOCK_RUN_SHA="${MOCK_RUN_SHA:-$HEAD_SHA}" \
MOCK_TAG=v1.2.3-rc1 \
REAL_PYTHON="$REAL_PYTHON" \
+ FAIL_DOWNLOAD_ARTIFACT="${FAIL_DOWNLOAD_ARTIFACT:-}" \
OMIT_CI_JAVADOC="${OMIT_CI_JAVADOC:-0}" \
OMIT_LOCAL_MAIN="${OMIT_LOCAL_MAIN:-0}" \
"$FIXTURE/tools/deploy_java_staging.sh" \
@@ -206,6 +216,14 @@ run_stage() {
"$@"
}
+assert_stage_cleanup() {
+ [[ ! -e "$FIXTURE/tools/release" ]] ||
+ fail "Java staging must not create tools/release"
+ if compgen -G "$STAGE_TMPDIR/paimon-mosaic-java-staging.*" >/dev/null; then
+ fail "Java staging temporary download directory was not removed"
+ fi
+}
+
pass() {
TESTS=$((TESTS + 1))
echo "ok $TESTS - $1"
@@ -216,23 +234,34 @@ run_stage --dry-run > "$FIXTURE/output" 2>&1
for artifact in native-linux-x86_64 native-linux-aarch64 native-macos-aarch64
native-windows-x86_64 java-package; do
assert_contains "$MOCK_LOG" "--name $artifact"
done
+assert_contains "$MOCK_LOG" "--dir $STAGE_TMPDIR/paimon-mosaic-java-staging."
assert_contains "$MOCK_LOG" "mvn clean verify -Prelease -Dgpg.skip=true
-DskipTests"
assert_not_contains "$MOCK_LOG" "mvn deploy"
[[ $(grep -c '^java ' "$MOCK_LOG") -eq 2 ]] || fail "dry-run must smoke local
and CI JARs"
[[ $(grep -c '^python3 .*verify_binary_artifact.py' "$MOCK_LOG") -eq 2 ]] ||
fail "dry-run must verify local and CI JAR contents"
-pass "successful dry-run validates all five artifacts and both JARs"
+assert_stage_cleanup
+[[ ! -e "$FIXTURE/java/src/main/resources/native" ]] ||
+ fail "default cleanup must remove staged Java resources"
+pass "successful dry-run validates all five artifacts and both JARs, and
removes staging downloads"
new_fixture
settings="$FIXTURE/settings.xml"
printf '<settings/>\n' > "$settings"
-run_stage --maven-settings "$settings" --staging-description "Mosaic RC
staging" > "$FIXTURE/output" 2>&1
+run_stage \
+ --maven-settings "$settings" \
+ --staging-description "Mosaic RC staging" \
+ --no-cleanup \
+ > "$FIXTURE/output" 2>&1
verify_line=$(grep -n '^mvn .*clean verify ' "$MOCK_LOG" | cut -d: -f1)
deploy_line=$(grep -n '^mvn .*deploy ' "$MOCK_LOG" | cut -d: -f1)
[[ -n "$verify_line" && -n "$deploy_line" && "$verify_line" -lt "$deploy_line"
]] || fail "verify must run before deploy"
assert_contains "$MOCK_LOG" "-s $settings clean verify"
assert_contains "$MOCK_LOG" "-s $settings deploy -Prelease
-DstagingDescription=Mosaic RC staging"
-pass "successful real run verifies before deploy and forwards Maven options"
+assert_stage_cleanup
+[[ -f
"$FIXTURE/java/src/main/resources/native/linux/x86_64/libpaimon_mosaic_jni.so"
]] ||
+ fail "--no-cleanup must preserve staged Java resources"
+pass "successful real run preserves only requested Java resources"
new_fixture
MOCK_RUN_SHA=0000000000000000000000000000000000000000
@@ -242,6 +271,14 @@ fi
assert_not_contains "$MOCK_LOG" "mvn "
unset MOCK_RUN_SHA
new_fixture
+FAIL_DOWNLOAD_ARTIFACT=native-linux-aarch64
+if run_stage --dry-run > "$FIXTURE/output" 2>&1; then
+ fail "failed artifact download should fail"
+fi
+assert_not_contains "$MOCK_LOG" "mvn "
+assert_stage_cleanup
+unset FAIL_DOWNLOAD_ARTIFACT
+new_fixture
printf '\n<!-- dirty -->\n' >> "$FIXTURE/java/pom.xml"
if run_stage --dry-run > "$FIXTURE/output" 2>&1; then
fail "dirty Java input should fail"
@@ -253,7 +290,7 @@ if run_stage --dry-run > "$FIXTURE/output" 2>&1; then
fail "dirty deploy script should fail"
fi
assert_not_contains "$MOCK_LOG" "mvn "
-pass "wrong run SHA and dirty Java/script inputs fail before Maven"
+pass "early failures do not leave staging downloads"
new_fixture
OMIT_CI_JAVADOC=1
@@ -261,6 +298,7 @@ if run_stage > "$FIXTURE/output" 2>&1; then
fail "missing CI Javadoc JAR should fail"
fi
assert_not_contains "$MOCK_LOG" "mvn deploy"
+assert_stage_cleanup
unset OMIT_CI_JAVADOC
new_fixture
omit_native_from_mock_jar
@@ -268,6 +306,7 @@ if run_stage > "$FIXTURE/output" 2>&1; then
fail "missing native JAR entry should fail"
fi
assert_not_contains "$MOCK_LOG" "mvn deploy"
-pass "missing required JAR or native entry blocks deploy"
+assert_stage_cleanup
+pass "failing runs remove staging downloads and block deploy"
echo "PASS: $TESTS focused Java staging tests"