From abf106eb1eca71f975cf7dee0ed81822f7cc30be Mon Sep 17 00:00:00 2001 From: nimrod-starkware <143319383+nimrod-starkware@users.noreply.github.com> Date: Sun, 11 Aug 2024 10:10:36 +0300 Subject: [PATCH] feat(ci): make rust version in ci configurable (#294) --- .github/actions/install_rust/action.yml | 25 +++++++++++++++++++ .github/workflows/blockifier_ci.yml | 4 +-- .../workflows/blockifier_compiled_cairo.yml | 5 ++-- .github/workflows/blockifier_coverage.yml | 2 +- .github/workflows/blockifier_post-merge.yml | 2 +- .github/workflows/committer_ci.yml | 4 +-- .github/workflows/main.yml | 12 ++++----- .github/workflows/papyrus_ci.yml | 12 ++++----- .../workflows/papyrus_nightly-tests-call.yml | 2 +- .github/workflows/papyrus_nightly-tests.yml | 10 ++++---- .github/workflows/verify-deps.yml | 2 +- 11 files changed, 52 insertions(+), 28 deletions(-) create mode 100644 .github/actions/install_rust/action.yml diff --git a/.github/actions/install_rust/action.yml b/.github/actions/install_rust/action.yml new file mode 100644 index 0000000000..7c44a32ec3 --- /dev/null +++ b/.github/actions/install_rust/action.yml @@ -0,0 +1,25 @@ +# Installs rust toolchain. In order to set/fix the version, edit DEFAULT_TOOLCHAIN env variable. +inputs: + components: + description: "An optional parameter that will be sent to dtolnay/rust-toolchain." + required: false + type: string + +runs: + using: "composite" + steps: + - name: Define toolchain + run: echo "DEFAULT_TOOLCHAIN=stable" >> $GITHUB_ENV + shell: bash + - name: install rust toolchain with given components + if: "${{ inputs.components != '' }}" + uses: dtolnay/rust-toolchain@master + with: + toolchain: ${{ env.DEFAULT_TOOLCHAIN }} + components: ${{ inputs.components }} + + - name: install rust toolchain without given components + if: "${{ inputs.components == '' }}" + uses: dtolnay/rust-toolchain@master + with: + toolchain: ${{ env.DEFAULT_TOOLCHAIN }} diff --git a/.github/workflows/blockifier_ci.yml b/.github/workflows/blockifier_ci.yml index 3cf49f006f..46197b8e02 100644 --- a/.github/workflows/blockifier_ci.yml +++ b/.github/workflows/blockifier_ci.yml @@ -30,7 +30,7 @@ jobs: runs-on: starkware-ubuntu-20-04-medium steps: - uses: actions/checkout@v4 - - uses: dtolnay/rust-toolchain@stable + - uses: ./.github/actions/install_rust - uses: Swatinem/rust-cache@v2 with: prefix-key: "v0-rust-ubuntu-20.04" @@ -41,7 +41,7 @@ jobs: runs-on: starkware-ubuntu-20-04-medium steps: - uses: actions/checkout@v4 - - uses: dtolnay/rust-toolchain@stable + - uses: ./.github/actions/install_rust - uses: Swatinem/rust-cache@v2 with: diff --git a/.github/workflows/blockifier_compiled_cairo.yml b/.github/workflows/blockifier_compiled_cairo.yml index e2eed9636f..878623b641 100644 --- a/.github/workflows/blockifier_compiled_cairo.yml +++ b/.github/workflows/blockifier_compiled_cairo.yml @@ -23,8 +23,7 @@ jobs: runs-on: starkware-ubuntu-20-04-medium steps: - uses: actions/checkout@v4 - - uses: dtolnay/rust-toolchain@stable - - uses: Noelware/setup-protoc@1.1.0 + - uses: ./.github/actions/install_rust - uses: Swatinem/rust-cache@v2 with: prefix-key: "v0-rust-ubuntu-20.04" @@ -41,4 +40,4 @@ jobs: - run: pip install -r crates/blockifier/tests/requirements.txt; - cargo test verify_feature_contracts -- --include-ignored + cargo test -p blockifier --test feature_contracts_compatibility_test --features testing -- --include-ignored diff --git a/.github/workflows/blockifier_coverage.yml b/.github/workflows/blockifier_coverage.yml index 1da1cdbbf2..23cfb58bed 100644 --- a/.github/workflows/blockifier_coverage.yml +++ b/.github/workflows/blockifier_coverage.yml @@ -17,7 +17,7 @@ jobs: CARGO_TERM_COLOR: always steps: - uses: actions/checkout@v4 - - uses: dtolnay/rust-toolchain@stable + - uses: ./.github/actions/install_rust - uses: Swatinem/rust-cache@v2 with: prefix-key: "v0-rust-ubuntu-20.04" diff --git a/.github/workflows/blockifier_post-merge.yml b/.github/workflows/blockifier_post-merge.yml index 404ed09680..4015aab921 100644 --- a/.github/workflows/blockifier_post-merge.yml +++ b/.github/workflows/blockifier_post-merge.yml @@ -13,7 +13,7 @@ jobs: runs-on: starkware-ubuntu-20-04-medium steps: - uses: actions/checkout@v4 - - uses: dtolnay/rust-toolchain@stable + - uses: ./.github/actions/install_rust - uses: Noelware/setup-protoc@1.1.0 - uses: Swatinem/rust-cache@v2 with: diff --git a/.github/workflows/committer_ci.yml b/.github/workflows/committer_ci.yml index ef816bc5d8..80c57e2250 100644 --- a/.github/workflows/committer_ci.yml +++ b/.github/workflows/committer_ci.yml @@ -35,7 +35,7 @@ jobs: runs-on: starkware-ubuntu-latest-small steps: - uses: actions/checkout@v4 - - uses: dtolnay/rust-toolchain@stable + - uses: ./.github/actions/install_rust - uses: Swatinem/rust-cache@v2 - id: auth @@ -117,7 +117,7 @@ jobs: runs-on: ubuntu-20.04 steps: - uses: actions/checkout@v4 - - uses: dtolnay/rust-toolchain@stable + - uses: ./.github/actions/install_rust - uses: Swatinem/rust-cache@v2 # Commit hash on pull request event would be the head commit of the branch. diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index ec8673ed03..9dda3304a1 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -44,7 +44,7 @@ jobs: runs-on: starkware-ubuntu-20-04-medium steps: - uses: actions/checkout@v4 - - uses: dtolnay/rust-toolchain@master + - uses: dtolnay/rust-toolchain@master # TODO(Nimrod, 15/8/2024): Use stable toolchain. with: components: rustfmt toolchain: nightly-2024-04-29 @@ -58,7 +58,7 @@ jobs: steps: - uses: actions/checkout@v4 - uses: Noelware/setup-protoc@1.1.0 - - uses: dtolnay/rust-toolchain@stable + - uses: ./.github/actions/install_rust with: components: clippy - uses: Swatinem/rust-cache@v2 @@ -83,7 +83,7 @@ jobs: # RUSTDOCFLAGS: "-D warnings" steps: - uses: actions/checkout@v4 - - uses: dtolnay/rust-toolchain@stable + - uses: ./.github/actions/install_rust - uses: Swatinem/rust-cache@v2 - uses: Noelware/setup-protoc@1.1.0 with: @@ -97,7 +97,7 @@ jobs: with: # Fetch the entire history. fetch-depth: 0 - - uses: dtolnay/rust-toolchain@stable + - uses: ./.github/actions/install_rust - uses: Noelware/setup-protoc@1.1.0 - uses: Swatinem/rust-cache@v2 with: @@ -137,7 +137,7 @@ jobs: runs-on: starkware-ubuntu-latest-small steps: - uses: actions/checkout@v4 - - uses: dtolnay/rust-toolchain@stable + - uses: ./.github/actions/install_rust - uses: Swatinem/rust-cache@v2 - uses: baptiste0928/cargo-install@v3 with: @@ -159,7 +159,7 @@ jobs: RUSTDOCFLAGS: "-D warnings" steps: - uses: actions/checkout@v4 - - uses: dtolnay/rust-toolchain@stable + - uses: ./.github/actions/install_rust - uses: Swatinem/rust-cache@v2 - uses: Noelware/setup-protoc@1.1.0 with: diff --git a/.github/workflows/papyrus_ci.yml b/.github/workflows/papyrus_ci.yml index 3fb238c381..3ec82a072a 100644 --- a/.github/workflows/papyrus_ci.yml +++ b/.github/workflows/papyrus_ci.yml @@ -41,7 +41,7 @@ jobs: runs-on: starkware-ubuntu-latest-medium steps: - uses: actions/checkout@v4 - - uses: dtolnay/rust-toolchain@stable + - uses: ./.github/actions/install_rust - uses: Swatinem/rust-cache@v2 - uses: Noelware/setup-protoc@1.1.0 with: @@ -60,7 +60,7 @@ jobs: runs-on: starkware-ubuntu-latest-medium steps: - uses: actions/checkout@v4 - - uses: dtolnay/rust-toolchain@stable + - uses: ./.github/actions/install_rust - uses: Swatinem/rust-cache@v2 - uses: Noelware/setup-protoc@1.1.0 with: @@ -79,7 +79,7 @@ jobs: runs-on: starkware-ubuntu-latest-medium steps: - uses: actions/checkout@v4 - - uses: dtolnay/rust-toolchain@stable + - uses: ./.github/actions/install_rust - uses: Swatinem/rust-cache@v2 - uses: Noelware/setup-protoc@1.1.0 with: @@ -96,7 +96,7 @@ jobs: runs-on: starkware-ubuntu-latest-medium steps: - uses: actions/checkout@v4 - - uses: dtolnay/rust-toolchain@stable + - uses: ./.github/actions/install_rust - uses: Swatinem/rust-cache@v2 - uses: Noelware/setup-protoc@1.1.0 @@ -109,7 +109,7 @@ jobs: runs-on: starkware-ubuntu-latest-medium steps: - uses: actions/checkout@v4 - - uses: dtolnay/rust-toolchain@stable + - uses: ./.github/actions/install_rust - name: Set-Up run: | sudo apt-get update @@ -173,7 +173,7 @@ jobs: filters: | target_directory: - 'crates/papyrus_storage/src/db/**' - - uses: dtolnay/rust-toolchain@stable + - uses: ./.github/actions/install_rust - uses: Swatinem/rust-cache@v2 # repeat this job 32 times. this is a random test for part of the code that may cause a corrupted database. - run: for run in {1..32}; do cargo test -r -p papyrus_storage -- --include-ignored common_prefix_compare_with_simple_table_random; done diff --git a/.github/workflows/papyrus_nightly-tests-call.yml b/.github/workflows/papyrus_nightly-tests-call.yml index afdc528be0..64980b6ab5 100644 --- a/.github/workflows/papyrus_nightly-tests-call.yml +++ b/.github/workflows/papyrus_nightly-tests-call.yml @@ -21,7 +21,7 @@ jobs: runs-on: ${{ inputs.os }} steps: - uses: actions/checkout@v4 - - uses: dtolnay/rust-toolchain@stable + - uses: ./.github/actions/install_rust - uses: Swatinem/rust-cache@v2 - run: sudo apt update; sudo apt -y install libclang-dev # Install libclang-dev that is not a part of the ubuntu vm in github actions. diff --git a/.github/workflows/papyrus_nightly-tests.yml b/.github/workflows/papyrus_nightly-tests.yml index 9c0a9bb09f..a7a91d5687 100644 --- a/.github/workflows/papyrus_nightly-tests.yml +++ b/.github/workflows/papyrus_nightly-tests.yml @@ -37,7 +37,7 @@ jobs: if: github.event.schedule == '30 0 * * *' steps: - uses: actions/checkout@v4 - - uses: dtolnay/rust-toolchain@stable + - uses: ./.github/actions/install_rust - uses: Swatinem/rust-cache@v2 - run: mkdir data @@ -57,7 +57,7 @@ jobs: if: github.event.schedule == '30 0 * * *' steps: - uses: actions/checkout@v4 - - uses: dtolnay/rust-toolchain@stable + - uses: ./.github/actions/install_rust - uses: Swatinem/rust-cache@v2 - run: npm install -g ganache@7.4.3 @@ -73,7 +73,7 @@ jobs: if: github.event.schedule == '30 0 * * *' steps: - uses: actions/checkout@v4 - - uses: dtolnay/rust-toolchain@stable + - uses: ./.github/actions/install_rust - uses: Swatinem/rust-cache@v2 - run: cargo build -r -p papyrus_load_test @@ -82,7 +82,7 @@ jobs: if: github.event.schedule == '30 0 * * *' steps: - uses: actions/checkout@v4 - - uses: dtolnay/rust-toolchain@stable + - uses: ./.github/actions/install_rust - uses: Swatinem/rust-cache@v2 - run: > cargo test -r @@ -98,6 +98,6 @@ jobs: runs-on: starkware-ubuntu-latest-small steps: - uses: actions/checkout@v4 - - uses: dtolnay/rust-toolchain@stable + - uses: ./.github/actions/install_rust - uses: Swatinem/rust-cache@v2 - run: for run in {1..100}; do cargo test -r -p papyrus_storage -- --include-ignored common_prefix_compare_with_simple_table_random; done diff --git a/.github/workflows/verify-deps.yml b/.github/workflows/verify-deps.yml index 3b410ef14c..e23ac29496 100644 --- a/.github/workflows/verify-deps.yml +++ b/.github/workflows/verify-deps.yml @@ -11,7 +11,7 @@ jobs: continue-on-error: true steps: - uses: actions/checkout@v4 - - uses: dtolnay/rust-toolchain@stable + - uses: ./.github/actions/install_rust - name: Update Dependencies run: cargo update --verbose - name: Build