Skip to content

Commit 84823ec

Browse files
kariyclaude
andcommitted
ci: generate DB fixtures on-demand instead of committing binaries
Remove spawn_and_move.tar.gz and simple.tar.gz from git. These were built on macOS (16KB page size) and fail on Linux CI (4KB page size) with MDBX_CORRUPTED. Instead, add a `generate-db-fixtures` CI job that compiles and runs `generate_migration_db` on the same platform where tests run. Uses actions/cache keyed on db version + dojo ref so full generation only happens on cache miss. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 2756398 commit 84823ec

File tree

5 files changed

+117
-21
lines changed

5 files changed

+117
-21
lines changed

.github/workflows/test.yml

Lines changed: 98 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,6 @@ jobs:
8686
if-no-files-found: error
8787
path: |
8888
./tests/snos/snos/build
89-
./tests/fixtures/db/spawn_and_move
90-
./tests/fixtures/db/simple
9189
./crates/contracts/build
9290
9391
build-katana-binary:
@@ -159,8 +157,100 @@ jobs:
159157
- name: Run Clippy
160158
run: ./scripts/clippy.sh
161159

160+
generate-db-fixtures:
161+
needs: [generate-test-artifacts]
162+
runs-on: ubuntu-latest-32-cores
163+
if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.pull_request.draft == false)
164+
container:
165+
image: ghcr.io/dojoengine/katana-dev:latest
166+
env:
167+
MLIR_SYS_190_PREFIX: /usr/lib/llvm-19/
168+
LLVM_SYS_191_PREFIX: /usr/lib/llvm-19/
169+
TABLEGEN_190_PREFIX: /usr/lib/llvm-19/
170+
steps:
171+
- uses: actions/checkout@v3
172+
with:
173+
submodules: recursive
174+
# Workaround for https://github.com/actions/runner-images/issues/6775
175+
- run: git config --global --add safe.directory "*"
176+
177+
- name: Cache DB fixtures
178+
id: cache-db-fixtures
179+
uses: actions/cache@v4
180+
with:
181+
path: |
182+
tests/fixtures/db/spawn_and_move
183+
tests/fixtures/db/simple
184+
key: db-fixtures-${{ hashFiles('crates/storage/db/src/version.rs') }}-dojo-v1.7.0
185+
186+
- name: Download contract artifacts
187+
if: steps.cache-db-fixtures.outputs.cache-hit != 'true'
188+
uses: actions/download-artifact@v5
189+
with:
190+
name: test-artifacts
191+
192+
- uses: Swatinem/rust-cache@v2
193+
if: steps.cache-db-fixtures.outputs.cache-hit != 'true'
194+
with:
195+
key: ci-${{ github.job }}
196+
shared-key: katana-ci-cache
197+
198+
- name: Checkout Dojo repository
199+
if: steps.cache-db-fixtures.outputs.cache-hit != 'true'
200+
uses: actions/checkout@v3
201+
with:
202+
repository: dojoengine/dojo
203+
ref: v1.7.0
204+
path: dojo
205+
206+
- name: Read scarb version from Dojo
207+
if: steps.cache-db-fixtures.outputs.cache-hit != 'true'
208+
id: dojo-scarb
209+
run: |
210+
SCARB_VERSION=$(grep '^scarb ' dojo/.tool-versions | awk '{print $2}')
211+
echo "version=$SCARB_VERSION" >> $GITHUB_OUTPUT
212+
213+
- uses: software-mansion/setup-scarb@v1
214+
if: steps.cache-db-fixtures.outputs.cache-hit != 'true'
215+
with:
216+
scarb-version: ${{ steps.dojo-scarb.outputs.version }}
217+
218+
- name: Install sozo
219+
if: steps.cache-db-fixtures.outputs.cache-hit != 'true'
220+
run: cargo install --path dojo/bin/sozo --locked --force
221+
222+
- name: Build generate_migration_db
223+
if: steps.cache-db-fixtures.outputs.cache-hit != 'true'
224+
run: cargo build --bin generate_migration_db --features node -p katana-utils
225+
226+
- name: Generate spawn-and-move fixture
227+
if: steps.cache-db-fixtures.outputs.cache-hit != 'true'
228+
run: ./target/debug/generate_migration_db --example spawn-and-move --output /tmp/spawn_and_move.tar.gz
229+
230+
- name: Generate simple fixture
231+
if: steps.cache-db-fixtures.outputs.cache-hit != 'true'
232+
run: ./target/debug/generate_migration_db --example simple --output /tmp/simple.tar.gz
233+
234+
- name: Extract fixtures
235+
if: steps.cache-db-fixtures.outputs.cache-hit != 'true'
236+
run: |
237+
mkdir -p tests/fixtures/db
238+
cd tests/fixtures/db && tar -xzf /tmp/spawn_and_move.tar.gz
239+
cd tests/fixtures/db && tar -xzf /tmp/simple.tar.gz
240+
241+
- name: Upload DB fixtures
242+
uses: actions/upload-artifact@v4
243+
with:
244+
name: db-fixtures
245+
overwrite: true
246+
retention-days: 14
247+
if-no-files-found: error
248+
path: |
249+
./tests/fixtures/db/spawn_and_move
250+
./tests/fixtures/db/simple
251+
162252
test:
163-
needs: [fmt, clippy, generate-test-artifacts, build-katana-binary]
253+
needs: [fmt, clippy, generate-test-artifacts, build-katana-binary, generate-db-fixtures]
164254
runs-on: ubuntu-latest-32-cores
165255
timeout-minutes: 30
166256
if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.pull_request.draft == false)
@@ -188,6 +278,11 @@ jobs:
188278
with:
189279
name: test-artifacts
190280

281+
- name: Download DB fixtures
282+
uses: actions/download-artifact@v5
283+
with:
284+
name: db-fixtures
285+
191286
- name: Download Katana binary
192287
uses: actions/download-artifact@v5
193288
with:

.gitignore

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,10 @@ tests/snos/snos
3131
snos-env
3232
tests/fixtures/katana_db
3333

34-
# Ignore all files under tests/fixtures/db except .tar.gz files
34+
# Ignore generated DB fixture directories; keep only committed tarballs
3535
tests/fixtures/db/*
36-
!tests/fixtures/db/*.tar.gz
36+
!tests/fixtures/db/1_6_0.tar.gz
37+
!tests/fixtures/db/snos.tar.gz
3738

3839
crates/contracts/build/
3940
!crates/contracts/build/legacy/

Makefile

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,7 @@ SNOS_DB_DIR := $(DB_FIXTURES_DIR)/snos
1717
COMPATIBILITY_DB_TAR ?= $(DB_FIXTURES_DIR)/1_6_0.tar.gz
1818
COMPATIBILITY_DB_DIR ?= $(DB_FIXTURES_DIR)/1_6_0
1919

20-
SPAWN_AND_MOVE_DB_TAR ?= $(DB_FIXTURES_DIR)/spawn_and_move.tar.gz
2120
SPAWN_AND_MOVE_DB_DIR := $(DB_FIXTURES_DIR)/spawn_and_move
22-
23-
SIMPLE_DB_TAR ?= $(DB_FIXTURES_DIR)/simple.tar.gz
2421
SIMPLE_DB_DIR := $(DB_FIXTURES_DIR)/simple
2522

2623
CONTRACTS_CRATE := crates/contracts
@@ -32,7 +29,7 @@ SCARB_VERSION := 2.8.4
3229

3330
.DEFAULT_GOAL := usage
3431
.SILENT: clean
35-
.PHONY: usage help check-llvm native-deps native-deps-macos native-deps-linux native-deps-windows build-explorer contracts clean deps install-scarb test-artifacts snos-artifacts db-compat-artifacts install-pyenv
32+
.PHONY: usage help check-llvm native-deps native-deps-macos native-deps-linux native-deps-windows build-explorer contracts clean deps install-scarb test-artifacts snos-artifacts db-compat-artifacts generate-db-fixtures install-pyenv
3633

3734
usage help:
3835
@echo "Usage:"
@@ -43,6 +40,7 @@ usage help:
4340
@echo " test-artifacts: Prepare tests artifacts (including test database)."
4441
@echo " snos-artifacts: Prepare SNOS tests artifacts."
4542
@echo " db-compat-artifacts: Prepare database compatibility test artifacts."
43+
@echo " generate-db-fixtures: Generate spawn-and-move and simple DB fixtures (requires scarb + sozo)."
4644
@echo " native-deps-macos: Install cairo-native dependencies for macOS."
4745
@echo " native-deps-linux: Install cairo-native dependencies for Linux."
4846
@echo " native-deps-windows: Install cairo-native dependencies for Windows."
@@ -68,7 +66,7 @@ snos-artifacts: $(SNOS_OUTPUT)
6866
db-compat-artifacts: $(COMPATIBILITY_DB_DIR)
6967
@echo "Database compatibility test artifacts prepared successfully."
7068

71-
test-artifacts: $(SNOS_DB_DIR) $(SNOS_OUTPUT) $(COMPATIBILITY_DB_DIR) $(SPAWN_AND_MOVE_DB_DIR) $(SIMPLE_DB_DIR) contracts
69+
test-artifacts: $(SNOS_DB_DIR) $(SNOS_OUTPUT) $(COMPATIBILITY_DB_DIR) contracts
7270
@echo "All test artifacts prepared successfully."
7371

7472
build-explorer:
@@ -116,17 +114,19 @@ $(COMPATIBILITY_DB_DIR): $(COMPATIBILITY_DB_TAR)
116114
mv katana_db $(notdir $(COMPATIBILITY_DB_DIR)) || { echo "Failed to extract backward compatibility test database\!"; exit 1; }
117115
@echo "Backward compatibility database extracted successfully."
118116

119-
$(SPAWN_AND_MOVE_DB_DIR): $(SPAWN_AND_MOVE_DB_TAR)
120-
@echo "Extracting spawn-and-move test database..."
121-
@cd $(DB_FIXTURES_DIR) && \
122-
tar -xzf $(notdir $(SPAWN_AND_MOVE_DB_TAR)) || { echo "Failed to extract spawn-and-move test database\!"; exit 1; }
123-
@echo "Spawn-and-move test database extracted successfully."
124-
125-
$(SIMPLE_DB_DIR): $(SIMPLE_DB_TAR)
126-
@echo "Extracting simple test database..."
127-
@cd $(DB_FIXTURES_DIR) && \
128-
tar -xzf $(notdir $(SIMPLE_DB_TAR)) || { echo "Failed to extract simple test database\!"; exit 1; }
129-
@echo "Simple test database extracted successfully."
117+
generate-db-fixtures:
118+
@echo "Building generate_migration_db binary..."
119+
cargo build --bin generate_migration_db --features node -p katana-utils
120+
@echo "Generating spawn-and-move database fixture..."
121+
./target/debug/generate_migration_db --example spawn-and-move --output /tmp/spawn_and_move.tar.gz
122+
@echo "Generating simple database fixture..."
123+
./target/debug/generate_migration_db --example simple --output /tmp/simple.tar.gz
124+
@echo "Extracting spawn-and-move fixture..."
125+
@mkdir -p $(DB_FIXTURES_DIR)
126+
@cd $(DB_FIXTURES_DIR) && tar -xzf /tmp/spawn_and_move.tar.gz
127+
@echo "Extracting simple fixture..."
128+
@cd $(DB_FIXTURES_DIR) && tar -xzf /tmp/simple.tar.gz
129+
@echo "DB fixtures generated successfully."
130130

131131
check-llvm:
132132
ifndef MLIR_SYS_190_PREFIX

tests/fixtures/db/simple.tar.gz

-1.49 MB
Binary file not shown.
-2.71 MB
Binary file not shown.

0 commit comments

Comments
 (0)