From 1eed42fa03725c03dc8eb70a31f324d1e05724f6 Mon Sep 17 00:00:00 2001 From: tison Date: Thu, 8 Jan 2026 11:08:24 +0800 Subject: [PATCH] ci: generate snaps stably Signed-off-by: tison --- .github/workflows/ci.yml | 22 +++++++++++++--------- tools/generate_serialization_test_data.py | 22 +++++++++++++++++++--- 2 files changed, 32 insertions(+), 12 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 318599e..02ffb73 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -85,6 +85,19 @@ jobs: run: | rustup toolchain install ${{ matrix.rust-version }} rustup default ${{ matrix.rust-version }} + - name: Run examples + shell: bash + working-directory: examples + run: | + set -x + METADATA=$( cargo metadata --format-version=1 --no-deps ) + EXAMPLES=$( echo "$METADATA" | jq -r '.packages[] | select(.name == "examples") | .targets[].name' | tr -d '\r' ) + while read -r example; do + if [ -n "$example" ]; then + echo "Running example: $example" + cargo run --bin "$example" + fi + done <<< "$EXAMPLES" - name: Setup Java uses: actions/setup-java@v5 with: @@ -96,15 +109,6 @@ jobs: - name: Run unit tests shell: bash run: cargo x test - - name: Run examples - shell: bash - working-directory: examples - run: | - set -x - EXAMPLES=( hll_update ) - for example in $EXAMPLES; do - cargo run --bin "$example" - done required: name: Required diff --git a/tools/generate_serialization_test_data.py b/tools/generate_serialization_test_data.py index 7fb488b..c965f39 100755 --- a/tools/generate_serialization_test_data.py +++ b/tools/generate_serialization_test_data.py @@ -71,7 +71,15 @@ def generate_java_files(workspace_dir, project_dir): # 4. Clone repository repo_url = "https://github.com/apache/datasketches-java.git" - run_command(["git", "clone", repo_url, str(temp_dir)]) + branch = "9.0.0" # FIXME: temporarily use fixed branch until mvn issue is resolved + run_command([ + "git", "clone", + "--depth", "1", + "--branch", branch, + "--single-branch", + repo_url, + str(temp_dir) + ]) # 5. Run Maven to generate files mvn_cmd = ["mvn", "test", "-P", "generate-java-files"] @@ -125,7 +133,15 @@ def generate_cpp_files(workspace_dir, project_root): # 4. Clone repository repo_url = "https://github.com/apache/datasketches-cpp.git" - run_command(["git", "clone", repo_url, str(temp_dir)]) + branch = "master" + run_command([ + "git", "clone", + "--depth", "1", + "--branch", branch, + "--single-branch", + repo_url, + str(temp_dir) + ]) # 5. Build and Run CMake build_dir = temp_dir / "build" @@ -152,7 +168,7 @@ def generate_cpp_files(workspace_dir, project_root): files_copied = 0 # Search recursively in build directory for *_cpp.sk for file_path in build_dir.rglob("*_cpp.sk"): - # Avoid copying from CMakeFiles or other intermediate dirs if possible, but the pattern is specific enough + # Avoid copying from CMakeFiles or other intermediate dirs if possible, but the pattern is specific enough shutil.copy2(file_path, output_dir) print(f"Copied: {file_path.name}") files_copied += 1