Skip to content

Commit 2bc600b

Browse files
feat(makefile,ci): add cairo_test_suite_programs target and CI integration
Makefile: - Add CAIRO_TEST_SUITE_ROOT, CAIRO_TEST_SUITE_FILES, COMPILED_CAIRO_TEST_SUITE variables to track cairo test suite sources - Add pattern rule to compile each .cairo to .json via cairo-compile - Add cairo_test_suite_programs target - Hook cairo_test_suite_programs into the test target - Add cairo_test_suite_programs to .PHONY CI (rust.yml): - Add cairo_test_suite_programs to the build-programs matrix - Add vm/src/tests/cairo_test_suite/**/*.json to CAIRO_PROGRAMS_PATH cache - Update all program cache keys to hash test suite source files - Add function_runner feature flag to the tests job Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 6ec5328 commit 2bc600b

2 files changed

Lines changed: 35 additions & 18 deletions

File tree

.github/workflows/rust.yml

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ env:
1818
cairo_programs/**/*.json
1919
!cairo_programs/manually_compiled/*
2020
cairo_programs/cairo-1-programs/bitwise.sierra
21+
vm/src/tests/cairo_test_suite/**/*.json
2122
TEST_COLLECT_COVERAGE: 1
2223
PROPTEST_CASES: 100
2324

@@ -46,6 +47,7 @@ jobs:
4647
- cairo_bench_programs
4748
- cairo_proof_programs
4849
- cairo_test_programs
50+
- cairo_test_suite_programs
4951
- cairo_1_test_contracts
5052
- cairo_2_test_contracts
5153
name: Build Cairo programs
@@ -66,7 +68,7 @@ jobs:
6668
id: cache-programs
6769
with:
6870
path: ${{ env.CAIRO_PROGRAMS_PATH }}
69-
key: ${{ matrix.program-target }}-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'Makefile', 'requirements.txt') }}
71+
key: ${{ matrix.program-target }}-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'vm/src/tests/cairo_test_suite/**/*.cairo', 'Makefile', 'requirements.txt') }}
7072

7173
# This is not pretty, but we need `make` to see the compiled programs are
7274
# actually newer than the sources, otherwise it will try to rebuild them
@@ -120,37 +122,43 @@ jobs:
120122
uses: actions/cache/restore@v3
121123
with:
122124
path: ${{ env.CAIRO_PROGRAMS_PATH }}
123-
key: cairo_test_programs-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'Makefile', 'requirements.txt') }}
125+
key: cairo_test_programs-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'vm/src/tests/cairo_test_suite/**/*.cairo', 'Makefile', 'requirements.txt') }}
124126
fail-on-cache-miss: true
125127
- name: Fetch proof programs
126128
uses: actions/cache/restore@v3
127129
with:
128130
path: ${{ env.CAIRO_PROGRAMS_PATH }}
129-
key: cairo_proof_programs-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'Makefile', 'requirements.txt') }}
131+
key: cairo_proof_programs-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'vm/src/tests/cairo_test_suite/**/*.cairo', 'Makefile', 'requirements.txt') }}
130132
fail-on-cache-miss: true
131133
- name: Fetch bench programs
132134
uses: actions/cache/restore@v3
133135
with:
134136
path: ${{ env.CAIRO_PROGRAMS_PATH }}
135-
key: cairo_bench_programs-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'Makefile', 'requirements.txt') }}
137+
key: cairo_bench_programs-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'vm/src/tests/cairo_test_suite/**/*.cairo', 'Makefile', 'requirements.txt') }}
138+
fail-on-cache-miss: true
139+
- name: Fetch cairo test suite programs
140+
uses: actions/cache/restore@v3
141+
with:
142+
path: ${{ env.CAIRO_PROGRAMS_PATH }}
143+
key: cairo_test_suite_programs-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'vm/src/tests/cairo_test_suite/**/*.cairo', 'Makefile', 'requirements.txt') }}
136144
fail-on-cache-miss: true
137145
- name: Fetch test contracts (Cairo 1)
138146
uses: actions/cache/restore@v3
139147
with:
140148
path: ${{ env.CAIRO_PROGRAMS_PATH }}
141-
key: cairo_1_test_contracts-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'Makefile', 'requirements.txt') }}
149+
key: cairo_1_test_contracts-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'vm/src/tests/cairo_test_suite/**/*.cairo', 'Makefile', 'requirements.txt') }}
142150
fail-on-cache-miss: true
143151
- name: Fetch test contracts (Cairo 2)
144152
uses: actions/cache/restore@v3
145153
with:
146154
path: ${{ env.CAIRO_PROGRAMS_PATH }}
147-
key: cairo_2_test_contracts-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'Makefile', 'requirements.txt') }}
155+
key: cairo_2_test_contracts-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'vm/src/tests/cairo_test_suite/**/*.cairo', 'Makefile', 'requirements.txt') }}
148156
fail-on-cache-miss: true
149157
- name: Merge caches
150158
uses: actions/cache/save@v3
151159
with:
152160
path: ${{ env.CAIRO_PROGRAMS_PATH }}
153-
key: all-programs-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'Makefile', 'requirements.txt') }}
161+
key: all-programs-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'vm/src/tests/cairo_test_suite/**/*.cairo', 'Makefile', 'requirements.txt') }}
154162

155163
lint:
156164
needs: merge-caches
@@ -179,7 +187,7 @@ jobs:
179187
uses: actions/cache/restore@v3
180188
with:
181189
path: ${{ env.CAIRO_PROGRAMS_PATH }}
182-
key: all-programs-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'Makefile', 'requirements.txt') }}
190+
key: all-programs-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'vm/src/tests/cairo_test_suite/**/*.cairo', 'Makefile', 'requirements.txt') }}
183191
fail-on-cache-miss: true
184192

185193
- name: Run clippy
@@ -229,7 +237,7 @@ jobs:
229237
uses: actions/cache/restore@v3
230238
with:
231239
path: ${{ env.CAIRO_PROGRAMS_PATH }}
232-
key: all-programs-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'Makefile', 'requirements.txt') }}
240+
key: all-programs-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'vm/src/tests/cairo_test_suite/**/*.cairo', 'Makefile', 'requirements.txt') }}
233241
fail-on-cache-miss: true
234242

235243
# NOTE: we do this separately because --workspace operates in weird ways
@@ -274,7 +282,7 @@ jobs:
274282
uses: actions/cache/restore@v3
275283
with:
276284
path: ${{ env.CAIRO_PROGRAMS_PATH }}
277-
key: all-programs-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'Makefile', 'requirements.txt') }}
285+
key: all-programs-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'vm/src/tests/cairo_test_suite/**/*.cairo', 'Makefile', 'requirements.txt') }}
278286
fail-on-cache-miss: true
279287

280288
- name: Check all features (workspace)
@@ -309,7 +317,7 @@ jobs:
309317
uses: actions/cache/restore@v3
310318
with:
311319
path: ${{ env.CAIRO_PROGRAMS_PATH }}
312-
key: all-programs-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'Makefile', 'requirements.txt') }}
320+
key: all-programs-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'vm/src/tests/cairo_test_suite/**/*.cairo', 'Makefile', 'requirements.txt') }}
313321
fail-on-cache-miss: true
314322

315323
- name: Install testing tools
@@ -329,7 +337,7 @@ jobs:
329337
export PARTITION=${MATRIX_TARGET#*#}
330338
cargo llvm-cov nextest --lcov --output-path lcov-${{ matrix.target }}-${{ matrix.special_features }}.info \
331339
--partition count:${PARTITION}/4 \
332-
--workspace --features "cairo-1-hints, test_utils, ${{ matrix.special_features }}"
340+
--workspace --features "cairo-1-hints, test_utils, function_runner, ${{ matrix.special_features }}"
333341
334342
- name: Save coverage
335343
uses: actions/cache/save@v3
@@ -409,7 +417,7 @@ jobs:
409417
uses: actions/cache/restore@v3
410418
with:
411419
path: ${{ env.CAIRO_PROGRAMS_PATH }}
412-
key: ${{ matrix.program-target }}-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'Makefile', 'requirements.txt') }}
420+
key: ${{ matrix.program-target }}-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'vm/src/tests/cairo_test_suite/**/*.cairo', 'Makefile', 'requirements.txt') }}
413421
fail-on-cache-miss: true
414422

415423
# This is not pretty, but we need `make` to see the compiled programs are
@@ -456,7 +464,7 @@ jobs:
456464
uses: actions/cache/restore@v3
457465
with:
458466
path: ${{ env.CAIRO_PROGRAMS_PATH }}
459-
key: ${{ matrix.program-target }}-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'Makefile', 'requirements.txt') }}
467+
key: ${{ matrix.program-target }}-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'vm/src/tests/cairo_test_suite/**/*.cairo', 'Makefile', 'requirements.txt') }}
460468
fail-on-cache-miss: true
461469

462470
- name: Generate traces
@@ -675,7 +683,7 @@ jobs:
675683
uses: actions/cache/restore@v3
676684
with:
677685
path: ${{ env.CAIRO_PROGRAMS_PATH }}
678-
key: cairo_proof_programs-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'Makefile', 'requirements.txt') }}
686+
key: cairo_proof_programs-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'vm/src/tests/cairo_test_suite/**/*.cairo', 'Makefile', 'requirements.txt') }}
679687
fail-on-cache-miss: true
680688

681689
- name: Run script
@@ -715,7 +723,7 @@ jobs:
715723
uses: actions/cache/restore@v3
716724
with:
717725
path: ${{ env.CAIRO_PROGRAMS_PATH }}
718-
key: cairo_proof_programs-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'Makefile', 'requirements.txt') }}
726+
key: cairo_proof_programs-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'vm/src/tests/cairo_test_suite/**/*.cairo', 'Makefile', 'requirements.txt') }}
719727
fail-on-cache-miss: true
720728

721729
- name: Fetch pie

Makefile

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ UNAME := $(shell uname)
2121
compare_trace_memory compare_trace compare_memory compare_pie compare_all_no_proof \
2222
compare_trace_memory_proof compare_all_proof compare_trace_proof compare_memory_proof compare_air_public_input compare_air_private_input\
2323
hyper-threading-benchmarks \
24-
cairo_bench_programs cairo_proof_programs cairo_test_programs cairo_1_test_contracts cairo_2_test_contracts \
24+
cairo_bench_programs cairo_proof_programs cairo_test_programs cairo_test_suite_programs cairo_1_test_contracts cairo_2_test_contracts \
2525
cairo_trace cairo-vm_trace cairo_proof_trace cairo-vm_proof_trace python-deps python-deps-macos \
2626
build-cairo-lang hint-accountant \ create-proof-programs-symlinks \
2727
$(RELBIN) $(DBGBIN)
@@ -124,6 +124,10 @@ NORETROCOMPAT_DIR:=cairo_programs/noretrocompat
124124
NORETROCOMPAT_FILES:=$(wildcard $(NORETROCOMPAT_DIR)/*.cairo)
125125
COMPILED_NORETROCOMPAT_TESTS:=$(patsubst $(NORETROCOMPAT_DIR)/%.cairo, $(NORETROCOMPAT_DIR)/%.json, $(NORETROCOMPAT_FILES))
126126

127+
CAIRO_TEST_SUITE_ROOT:=vm/src/tests/cairo_test_suite
128+
CAIRO_TEST_SUITE_FILES:=$(shell find $(CAIRO_TEST_SUITE_ROOT) -name "*.cairo")
129+
COMPILED_CAIRO_TEST_SUITE:=$(patsubst %.cairo,%.json,$(CAIRO_TEST_SUITE_FILES))
130+
127131
$(BENCH_DIR)/%.json: $(BENCH_DIR)/%.cairo
128132
cairo-compile --cairo_path="$(TEST_DIR):$(BENCH_DIR)" $< --output $@ --proof_mode
129133

@@ -145,6 +149,9 @@ $(BAD_TEST_DIR)/%.json: $(BAD_TEST_DIR)/%.cairo
145149
$(PRINT_TEST_DIR)/%.json: $(PRINT_TEST_DIR)/%.cairo
146150
cairo-compile $< --output $@
147151

152+
$(CAIRO_TEST_SUITE_ROOT)/%.json: $(CAIRO_TEST_SUITE_ROOT)/%.cairo
153+
cairo-compile $< --output $@
154+
148155
# ======================
149156
# Test Cairo 1 Contracts
150157
# ======================
@@ -268,6 +275,8 @@ run:
268275
check:
269276
cargo check
270277

278+
cairo_test_suite_programs: $(COMPILED_CAIRO_TEST_SUITE)
279+
271280
cairo_test_programs: $(COMPILED_TESTS) $(COMPILED_BAD_TESTS) $(COMPILED_NORETROCOMPAT_TESTS) $(COMPILED_PRINT_TESTS) $(COMPILED_MOD_BUILTIN_TESTS) $(COMPILED_SECP_CAIRO0_HINTS) $(COMPILED_KZG_DA_CAIRO0_HINTS) $(COMPILED_SEGMENT_ARENA_CAIRO0_HINTS)
272281
cairo_proof_programs: $(COMPILED_PROOF_TESTS) $(COMPILED_MOD_BUILTIN_PROOF_TESTS) $(COMPILED_STWO_EXCLUSIVE_TESTS)
273282
cairo_bench_programs: $(COMPILED_BENCHES)
@@ -286,7 +295,7 @@ ifdef TEST_COLLECT_COVERAGE
286295
TEST_COMMAND:=cargo llvm-cov nextest --no-report
287296
endif
288297

289-
test: cairo_proof_programs cairo_test_programs cairo_1_test_contracts cairo_2_test_contracts cairo_1_program
298+
test: cairo_proof_programs cairo_test_programs cairo_test_suite_programs cairo_1_test_contracts cairo_2_test_contracts cairo_1_program
290299
$(TEST_COMMAND) --workspace --features "test_utils, cairo-1-hints"
291300
test-extensive_hints: cairo_proof_programs cairo_test_programs cairo_1_test_contracts cairo_1_program cairo_2_test_contracts
292301
$(TEST_COMMAND) --workspace --features "test_utils, cairo-1-hints, cairo-0-secp-hints, cairo-0-data-availability-hints, extensive_hints"

0 commit comments

Comments
 (0)