From f54a06919fc085f6ddd73f1ef55b0d61488aa23d Mon Sep 17 00:00:00 2001 From: Dori Medini Date: Tue, 7 May 2024 13:11:03 +0300 Subject: [PATCH] ci: support Cairo1 recompile in CI Signed-off-by: Dori Medini --- .github/workflows/compiled_cairo.yml | 31 ++++++++++++++++--- .../src/test_utils/cairo_compile.rs | 1 - .../feature_contracts_compatibility_test.rs | 4 --- 3 files changed, 27 insertions(+), 9 deletions(-) diff --git a/.github/workflows/compiled_cairo.yml b/.github/workflows/compiled_cairo.yml index 747c6349cf..37deadab0c 100644 --- a/.github/workflows/compiled_cairo.yml +++ b/.github/workflows/compiled_cairo.yml @@ -14,21 +14,44 @@ on: - synchronize paths: - 'crates/blockifier/feature_contracts/cairo0/**' + - 'crates/blockifier/feature_contracts/cairo1/**' + - 'crates/blockifier/tests/feature_contracts_compatibility_test.rs' jobs: verify_cairo_file_dependencies: runs-on: ubuntu-latest + steps: - - uses: actions/checkout@v4 - - uses: dtolnay/rust-toolchain@master + # Checkout blockifier into a dedicated directory - technical requirement in order to be able to checkout `cairo` in a sibling directory. + - name: checkout blockifier into `blockifier` directory. + uses: actions/checkout@v4 + with: + repository: 'starkware-libs/blockifier' + path: 'blockifier' + + - name: Read Cairo1 Tag to compile contracts with from Blockifier. + id: read-tag + # GITHUB_ENV is a variable github allocates for dynamic stuff inside workflow like our usage, name not customizable. + run: echo "TAG=$(cat blockifier/crates/blockifier/tests/cairo1_compiler_tag.txt)" >> $GITHUB_ENV + + - name: checkout cairo1 repo in order to compile cairo1 contracts. + uses: actions/checkout@v4 + with: + repository: 'starkware-libs/cairo' + fetch-tags: tags + ref: ${{ env.TAG }} + path: 'cairo' + + - uses: actions-rs/toolchain@master with: components: rustfmt - toolchain: nightly-2024-01-12 + toolchain: nightly-2023-07-05 - uses: Swatinem/rust-cache@v2 - uses: actions/setup-python@v4 with: python-version: '3.9' cache: 'pip' - run: - pip install -r crates/blockifier/tests/requirements.txt; + cd blockifier && + pip install -r crates/blockifier/tests/requirements.txt && cargo test verify_feature_contracts -- --include-ignored diff --git a/crates/blockifier/src/test_utils/cairo_compile.rs b/crates/blockifier/src/test_utils/cairo_compile.rs index be66c009a7..2fee3815b6 100644 --- a/crates/blockifier/src/test_utils/cairo_compile.rs +++ b/crates/blockifier/src/test_utils/cairo_compile.rs @@ -169,7 +169,6 @@ fn verify_cairo1_compiler_deps(git_tag_override: Option) { // Checkout the required version in the compiler repo. run_and_verify_output(Command::new("git").args([ "-C", - // TODO(Dori, 1/6/2024): Handle CI case (repo path will be different). cairo_repo_path.to_str().unwrap(), "checkout", &tag, diff --git a/crates/blockifier/tests/feature_contracts_compatibility_test.rs b/crates/blockifier/tests/feature_contracts_compatibility_test.rs index f9b2be7e9d..5c8561a947 100644 --- a/crates/blockifier/tests/feature_contracts_compatibility_test.rs +++ b/crates/blockifier/tests/feature_contracts_compatibility_test.rs @@ -136,10 +136,6 @@ fn verify_feature_contracts_match_enum() { fn verify_feature_contracts( #[values(CairoVersion::Cairo0, CairoVersion::Cairo1)] cairo_version: CairoVersion, ) { - if std::env::var("CI").is_ok() && matches!(cairo_version, CairoVersion::Cairo1) { - // TODO(Dori, 1/6/2024): Support Cairo1 contracts in the CI and remove this `if` statement. - return; - } let fix_features = std::env::var("FIX_FEATURE_TEST").is_ok(); verify_feature_contracts_compatibility(fix_features, cairo_version) }