Skip to content

Commit 733da27

Browse files
committed
CI/Makefile: run unit/integration tests for each pkg
1 parent 23a2df5 commit 733da27

File tree

3 files changed

+141
-210
lines changed

3 files changed

+141
-210
lines changed
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
#!/usr/bin/env bash
2+
# Script to list all workspace packages with their test requirements
3+
# Outputs JSON suitable for GitHub Actions matrix strategy
4+
5+
set -euo pipefail
6+
7+
# Packages that require nightly Rust
8+
NIGHTLY_PACKAGES=(
9+
"mina-tree"
10+
"vrf"
11+
"mina-p2p-messages"
12+
"transaction_fuzzer"
13+
)
14+
15+
# Packages that don't have unit tests or shouldn't be tested
16+
# cli is tested via wallet-tests (end-to-end tests)
17+
SPECIAL_PACKAGES=(
18+
"cli"
19+
)
20+
21+
# Helper function to check if an element is in an array
22+
contains_element() {
23+
local element="$1"
24+
shift
25+
local array=("$@")
26+
for item in "${array[@]}"; do
27+
if [[ "$item" == "$element" ]]; then
28+
return 0
29+
fi
30+
done
31+
return 1
32+
}
33+
34+
# Get all workspace packages with their features
35+
packages_data=$(cargo metadata --no-deps --format-version 1 2>/dev/null | \
36+
jq -r '.packages[] | "\(.name)|\(.features | keys | length)"')
37+
38+
matrix_entries=()
39+
40+
while IFS='|' read -r package_name feature_count; do
41+
# Skip special packages that have dedicated CI jobs
42+
if contains_element "$package_name" "${SPECIAL_PACKAGES[@]}"; then
43+
continue
44+
fi
45+
46+
# Determine toolchain
47+
toolchain="stable"
48+
if contains_element "$package_name" "${NIGHTLY_PACKAGES[@]}"; then
49+
toolchain="nightly"
50+
fi
51+
52+
# Determine if --all-features is needed
53+
all_features="false"
54+
if [[ "$feature_count" -gt 0 ]]; then
55+
all_features="true"
56+
fi
57+
58+
# Create matrix entry
59+
entry=$(jq -n \
60+
--arg name "$package_name" \
61+
--arg toolchain "$toolchain" \
62+
--arg all_features "$all_features" \
63+
'{
64+
package: $name,
65+
toolchain: $toolchain,
66+
all_features: ($all_features == "true")
67+
}')
68+
69+
matrix_entries+=("$entry")
70+
done <<< "$packages_data"
71+
72+
# Combine all entries into a JSON array (compact format for GitHub Actions)
73+
if [[ ${#matrix_entries[@]} -eq 0 ]]; then
74+
echo '{"include":[]}'
75+
else
76+
printf '%s\n' "${matrix_entries[@]}" | jq -s -c '{include: .}'
77+
fi

.github/workflows/tests.yaml

Lines changed: 38 additions & 156 deletions
Original file line numberDiff line numberDiff line change
@@ -40,156 +40,6 @@ jobs:
4040
- name: Clean cargo cache
4141
run: cargo clean
4242

43-
ledger-tests:
44-
timeout-minutes: 20
45-
runs-on: ubuntu-24.04
46-
steps:
47-
- name: Git checkout
48-
uses: actions/checkout@v5
49-
50-
- name: Setup build dependencies
51-
uses: ./.github/actions/setup-build-deps
52-
53-
- name: Use shared OCaml setting up steps
54-
uses: ./.github/actions/setup-ocaml
55-
with:
56-
ocaml_version: ${{ env.OCAML_VERSION }}
57-
58-
- name: Setup Rust
59-
uses: ./.github/actions/setup-rust
60-
with:
61-
toolchain: ${{ env.RUST_NIGHTLY_VERSION }}
62-
cache-prefix: ledger-${{ env.CACHE_VERSION }}
63-
64-
- name: Download circuits files
65-
uses: ./.github/actions/setup-circuits
66-
67-
- name: Build ledger tests
68-
run: make build-ledger
69-
70-
- name: Run ledger tests
71-
run: make test-ledger
72-
73-
mina-node-native-tests:
74-
timeout-minutes: 30
75-
runs-on: ubuntu-24.04
76-
steps:
77-
- name: Git checkout
78-
uses: actions/checkout@v5
79-
80-
- name: Setup build dependencies
81-
uses: ./.github/actions/setup-build-deps
82-
83-
- name: Setup Rust
84-
uses: ./.github/actions/setup-rust
85-
with:
86-
toolchain: ${{ env.RUST_STABLE_VERSION }}
87-
cache-prefix: mina-node-native-${{ env.CACHE_VERSION }}
88-
89-
- name: Test mina-node-native crate
90-
run: make test-node-native
91-
92-
p2p-messages-tests:
93-
timeout-minutes: 20
94-
runs-on: ubuntu-24.04
95-
steps:
96-
- name: Git checkout
97-
uses: actions/checkout@v5
98-
99-
- name: Setup build dependencies
100-
uses: ./.github/actions/setup-build-deps
101-
102-
- name: Setup Rust
103-
uses: ./.github/actions/setup-rust
104-
with:
105-
toolchain: ${{ env.RUST_NIGHTLY_VERSION }}
106-
cache-prefix: p2p-messages-${{ env.CACHE_VERSION }}
107-
108-
- name: Download circuits files
109-
uses: ./.github/actions/setup-circuits
110-
111-
- name: Run mina-p2p-messages
112-
run: make test-p2p-messages
113-
114-
# TODO: add back when reimplemented
115-
# ledger-32x9-tests:
116-
# runs-on: ubuntu-24.04
117-
# steps:
118-
# - name: Git checkout
119-
# uses: actions/checkout@v5
120-
121-
# - name: Setup build dependencies
122-
# uses: ./.github/actions/setup-build-deps
123-
124-
# - name: Setup Rust
125-
# uses: ./.github/actions/setup-rust
126-
# with:
127-
# toolchain: nightly
128-
# cache-prefix: ledger-32x9-v0
129-
130-
# - name: Download circuits files
131-
# uses: ./.github/actions/setup-circuits
132-
133-
# - name: Enable 32x9 fields implementation
134-
# run: |
135-
# cargo install sd
136-
# sd '^mina-curves.*$' '' ./Cargo.toml
137-
# sd '^ark-ff = \{ version .*$' '' ./Cargo.toml
138-
# sd -F '# UNCOMMENTED_IN_CI ' '' ./Cargo.toml
139-
# cat ./Cargo.toml
140-
141-
# - name: Build ledger tests
142-
# run: make build-ledger
143-
144-
# - name: Run ledger tests
145-
# run: make test-ledger
146-
147-
vrf-tests:
148-
timeout-minutes: 20
149-
runs-on: ubuntu-24.04
150-
steps:
151-
- name: Git checkout
152-
uses: actions/checkout@v5
153-
154-
- name: Setup build dependencies
155-
uses: ./.github/actions/setup-build-deps
156-
157-
- name: Use shared OCaml setting up steps
158-
uses: ./.github/actions/setup-ocaml
159-
with:
160-
ocaml_version: ${{ env.OCAML_VERSION }}
161-
162-
- name: Setup Rust
163-
uses: ./.github/actions/setup-rust
164-
with:
165-
toolchain: ${{ env.RUST_NIGHTLY_VERSION }}
166-
cache-prefix: vrf-${{ env.CACHE_VERSION }}
167-
168-
- name: Build vrf tests
169-
run: make build-vrf
170-
171-
- name: Run vrf tests
172-
run: make test-vrf
173-
174-
p2p-tests:
175-
timeout-minutes: 15
176-
runs-on: ubuntu-24.04
177-
steps:
178-
- name: Git checkout
179-
uses: actions/checkout@v5
180-
181-
- name: Setup build dependencies
182-
uses: ./.github/actions/setup-build-deps
183-
184-
- name: Setup Rust
185-
uses: ./.github/actions/setup-rust
186-
with:
187-
toolchain: ${{ env.RUST_STABLE_VERSION }}
188-
cache-prefix: p2p-${{ env.CACHE_VERSION }}
189-
190-
- name: Test p2p crate
191-
run: make test-p2p
192-
19343
# Fast builds specifically for test artifacts - no cross-platform matrix
19444
build:
19545
timeout-minutes: 60
@@ -239,24 +89,56 @@ jobs:
23989
path: target/release/mina
24090
retention-days: 7
24191

242-
account-tests:
243-
timeout-minutes: 20
92+
# Generate matrix of all packages to test
93+
generate-test-matrix:
94+
runs-on: ubuntu-24.04
95+
outputs:
96+
matrix: ${{ steps.set-matrix.outputs.matrix }}
97+
steps:
98+
- name: Git checkout
99+
uses: actions/checkout@v5
100+
101+
- name: Generate test matrix
102+
id: set-matrix
103+
run: |
104+
MATRIX=$(./.github/scripts/list-test-packages.sh)
105+
echo "matrix=$MATRIX" >> $GITHUB_OUTPUT
106+
echo "Generated matrix:"
107+
echo "$MATRIX" | jq .
108+
109+
# Test all packages in parallel
110+
package-tests:
111+
needs: generate-test-matrix
112+
timeout-minutes: 30
244113
runs-on: ubuntu-24.04
114+
strategy:
115+
fail-fast: false
116+
matrix: ${{ fromJson(needs.generate-test-matrix.outputs.matrix) }}
117+
name: unit-integration-tests-${{ matrix.package }}
245118
steps:
246119
- name: Git checkout
247120
uses: actions/checkout@v5
248121

249122
- name: Setup build dependencies
250123
uses: ./.github/actions/setup-build-deps
251124

125+
- name: Setup OCaml (if needed)
126+
if: matrix.package == 'mina-tree' || matrix.package == 'vrf'
127+
uses: ./.github/actions/setup-ocaml
128+
with:
129+
ocaml_version: ${{ env.OCAML_VERSION }}
130+
131+
- name: Setup circuits
132+
uses: ./.github/actions/setup-circuits
133+
252134
- name: Setup Rust
253135
uses: ./.github/actions/setup-rust
254136
with:
255-
toolchain: ${{ env.RUST_STABLE_VERSION }}
256-
cache-prefix: build-${{ env.CACHE_VERSION }}
137+
toolchain: ${{ matrix.toolchain == 'nightly' && env.RUST_NIGHTLY_VERSION || env.RUST_STABLE_VERSION }}
138+
cache-prefix: test-${{ matrix.package }}-${{ env.CACHE_VERSION }}
257139

258-
- name: Run account tests
259-
run: make test-account
140+
- name: Test package
141+
run: make test-package PACKAGE=${{ matrix.package }} ALL_FEATURES=${{ matrix.all_features }}
260142

261143
wallet-tests:
262144
needs: [build]

0 commit comments

Comments
 (0)