forked from Lightprotocol/light-protocol
-
Notifications
You must be signed in to change notification settings - Fork 0
157 lines (138 loc) · 4.88 KB
/
rust.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
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"