Skip to content

Commit

Permalink
fix(makefile): avoid relinking on makefile (#1412)
Browse files Browse the repository at this point in the history
### Key Modifications:
1. **Avoid Always Running `clean` in `build`:** Removed `$(MAKE) clean`
from `build`, so it won't delete and relink files every time.
2. **Timestamp Tracking for Artifacts:**
   - The `SSJ_DIR` target only rebuilds if `$(SSJ_ZIP)` changes.
   - `curl` only runs if the zip file doesn't exist.
3. **Directory creation conditional:** The build directory `build/ssj`
is only recreated when necessary.

<!-- Reviewable:start -->
- - -
This change is [<img src="https://reviewable.io/review_button.svg"
height="34" align="absmiddle"
alt="Reviewable"/>](https://reviewable.io/reviews/kkrt-labs/kakarot/1412)
<!-- Reviewable:end -->
  • Loading branch information
antiyro committed Sep 16, 2024
1 parent 92e5ee5 commit a87ad27
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 19 deletions.
1 change: 0 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,6 @@ jobs:
run: make install-katana
- name: Run tests
run: |
make fetch-ssj-artifacts
cp .env.example .env
make run-nodes & make test-end-to-end
Expand Down
36 changes: 18 additions & 18 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ ifneq ("$(wildcard .env)","")
export $(shell sed 's/=.*//' .env)
endif

.PHONY: build test coverage
.PHONY: build test coverage clean

# 154615699 corresponds to release v0.1.7 of Kakarot SSJ.
KKRT_SSJ_RELEASE_ID = 154615699
Expand All @@ -13,28 +13,28 @@ KKRT_SSJ_BUILD_ARTIFACT_URL = $(shell curl -L https://api.github.com/repos/kkrt-
KATANA_VERSION = v1.0.0-alpha.11
ROOT_DIR:=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))

BUILD_DIR = build
SSJ_DIR = $(BUILD_DIR)/ssj
SSJ_ZIP = dev-artifacts.zip

build: check
$(MAKE) clean
build: $(SSJ_DIR) check
poetry run python ./kakarot_scripts/compile_kakarot.py

check:
poetry check --lock

$(SSJ_DIR): $(SSJ_ZIP)
rm -rf $(SSJ_DIR)
mkdir -p $(SSJ_DIR)
unzip -o $(SSJ_ZIP) -d $(SSJ_DIR)
rm -f $(SSJ_ZIP)

$(SSJ_ZIP):
curl -sL -o $(SSJ_ZIP) "$(KKRT_SSJ_BUILD_ARTIFACT_URL)"

fetch-ef-tests:
poetry run python ./kakarot_scripts/ef_tests/fetch.py

# This action fetches the latest Kakarot SSJ (Cairo compiler version >=2) artifacts
# from the main branch and unzips them into the build/ssj directory.
# This is required because Kakarot Zero (Cairo Zero, compiler version <1) uses some SSJ Cairo programs.
# Most notably for precompiles.
fetch-ssj-artifacts:
rm -rf build/ssj
mkdir -p build/ssj
@curl -sL -o dev-artifacts.zip "$(KKRT_SSJ_BUILD_ARTIFACT_URL)"
unzip -o dev-artifacts.zip -d build/ssj
rm -f dev-artifacts.zip

setup: fetch-ssj-artifacts
poetry install

Expand All @@ -45,7 +45,6 @@ test: deploy
test-unit: build-sol
poetry run pytest tests/src -m "not NoCI" -n logical --seed 42

# run make run-nodes in other terminal
test-end-to-end: deploy
poetry run pytest tests/end_to_end --seed 42

Expand All @@ -59,9 +58,10 @@ format-check:
trunk check --ci

clean:
rm -rf build/*.json
rm -rf build/fixtures/*.json
mkdir -p build
rm -rf $(BUILD_DIR)/*.json
rm -rf $(BUILD_DIR)/fixtures/*.json
rm -rf $(SSJ_DIR)
mkdir -p $(BUILD_DIR)

check-resources:
poetry run python kakarot_scripts/check_resources.py
Expand Down

0 comments on commit a87ad27

Please sign in to comment.