Skip to content

test: add readonly e2e test #4643

test: add readonly e2e test

test: add readonly e2e test #4643

Workflow file for this run

name: rust
on:
push:
branches: [main]
paths:
- ".cargo/**"
- "**/*.rs"
- "**/Cargo.*"
- "prover/client/**"
- ".github/workflows/rust.yml"
pull_request:
branches: ["*"]
paths:
- "**/*.rs"
- "**/Cargo.*"
- "prover/client/**"
- ".github/workflows/rust.yml"
types: [opened, synchronize, reopened, ready_for_review]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
RUST_MIN_STACK: 8388608
RUSTFLAGS: "-D warnings"
jobs:
test:
if: github.event.pull_request.draft == false
runs-on: ubuntu-latest
outputs:
timing: ${{ steps.test-timing.outputs.timing }}
strategy:
matrix:
group:
- name: concurrent-merkle-tree
packages: >-
light-concurrent-merkle-tree
light-batched-merkle-tree
- name: program-libs
packages: >-
aligned-sized
light-bloom-filter
light-hasher
light-utils
light-verifier
light-merkle-tree-metadata
light-zero-copy
light-hash-set
light-indexed-merkle-tree
light-batched-merkle-tree
- name: sdk-libs
packages: >-
light-macros
light-sdk
light-program-test
light-client
light-batched-merkle-tree
fail-fast: false
name: Test ${{ matrix.group.name }}
steps:
- uses: actions/checkout@v4
- name: Setup and build
uses: ./.github/actions/setup-and-build
- name: Build CLI
run: |
source ./scripts/devenv.sh
npx nx build @lightprotocol/zk-compression-cli
- name: Run tests
id: test-timing
run: |
source ./scripts/devenv.sh
{
echo "Testing group: ${{ matrix.group.name }}"
echo "Packages: ${{ matrix.group.packages }}"
echo "Rust version: $(rustc --version)"
} >> "$GITHUB_STEP_SUMMARY"
# Function to format time duration
format_duration() {
local duration="$1"
local minutes=$((duration / 60))
local seconds=$((duration % 60))
echo "${minutes}m ${seconds}s"
}
# Record group start time
group_start=$(date +%s)
# Convert space-separated packages into array
readarray -t packages <<< "$(echo "${{ matrix.group.packages }}" | tr ' ' '\n')"
# Test each package and measure time
for pkg in "${packages[@]}"; do
if [[ -n "$pkg" ]]; then # Skip empty lines
echo "::group::Testing ${pkg}"
start=$(date +%s)
echo "${name}"
echo "${{ matrix.group.name }}"
if [ "${pkg}" == "light-batched-merkle-tree" ]; then
if [ "${{ matrix.group.name }}" == "sdk-libs" ]; then
# execute simulate transactions test
cargo test -p "${pkg}" -- --skip test_simulate_transactions --skip test_e2e || exit 1
elif [ "${{ matrix.group.name }}" == "program-libs" ]; then
# execute e2e test
cargo test -p "${pkg}" -- --test test_e2e || exit 1
else
# execute all tests except test_simulate_transactions and test_e2e
cargo test -p "${pkg}" -- --test test_simulate_transactions || exit 1
fi
else
cargo test -p "${pkg}" || exit 1
fi
end=$(date +%s)
duration=$((end - start))
formatted_time=$(format_duration "$duration")
echo "Package ${pkg} completed in ${formatted_time}"
echo "::endgroup::"
fi
done
# Record and print group total time
group_end=$(date +%s)
group_duration=$((group_end - group_start))
formatted_group_time=$(format_duration "$group_duration")
# Create timing report with simplified output
echo "timing=${{ matrix.group.name }}:${formatted_group_time}" >> "$GITHUB_OUTPUT"
echo "Group ${{ matrix.group.name }} total time: ${formatted_group_time}" >> "$GITHUB_STEP_SUMMARY"
collect-times:
needs: test
runs-on: ubuntu-latest
if: always()
steps:
- name: Create timing summary
run: |
{
echo "# Test Execution Times"
echo "| Group | Time |"
echo "|-------|------|"
for timing in ${{ needs.test.outputs.timing }}; do
group="${timing%%:*}"
time="${timing#*:}"
echo "| $group | $time |"
done
} >> "$GITHUB_STEP_SUMMARY"