From 59239d8333376d3433b5a3ea2e90815de4303cce Mon Sep 17 00:00:00 2001 From: "alon.dotan" Date: Thu, 29 Aug 2024 14:33:29 +0300 Subject: [PATCH] chore(infra): use rust-toolchain.toml to align rust toolchains locally and in ci --- .github/actions/install_rust/action.yml | 25 +------------------ .github/actions/install_rust/rust_version.txt | 1 - .github/workflows/blockifier_ci.yml | 8 ------ .../workflows/blockifier_compiled_cairo.yml | 3 --- .github/workflows/blockifier_post-merge.yml | 3 --- .github/workflows/committer_ci.yml | 3 --- .github/workflows/main.yml | 9 ------- .github/workflows/papyrus_ci.yml | 5 ---- .../workflows/papyrus_nightly-tests-call.yml | 1 - .github/workflows/papyrus_nightly-tests.yml | 5 ---- commitlint.config.js | 1 + rust-toolchain.toml | 5 ++++ scripts/merge_branches.py | 2 +- 13 files changed, 8 insertions(+), 63 deletions(-) delete mode 100644 .github/actions/install_rust/rust_version.txt create mode 100644 rust-toolchain.toml diff --git a/.github/actions/install_rust/action.yml b/.github/actions/install_rust/action.yml index d40e4baa8a..bf6287cdbe 100644 --- a/.github/actions/install_rust/action.yml +++ b/.github/actions/install_rust/action.yml @@ -1,27 +1,4 @@ -# Installs rust toolchain with the version defined in .github/actions/install_rust/rust_version.txt. -inputs: - components: - description: "Optional: which additional components to install." - required: false - type: string - default: '' - runs: using: "composite" steps: - - name: Define toolchain - run: echo "DEFAULT_TOOLCHAIN=$(cat .github/actions/install_rust/rust_version.txt)" >> $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 }} + - uses: moonrepo/setup-rust@v1 diff --git a/.github/actions/install_rust/rust_version.txt b/.github/actions/install_rust/rust_version.txt deleted file mode 100644 index 2bf5ad0447..0000000000 --- a/.github/actions/install_rust/rust_version.txt +++ /dev/null @@ -1 +0,0 @@ -stable diff --git a/.github/workflows/blockifier_ci.yml b/.github/workflows/blockifier_ci.yml index 9874c86d3d..f64627d15a 100644 --- a/.github/workflows/blockifier_ci.yml +++ b/.github/workflows/blockifier_ci.yml @@ -43,9 +43,6 @@ jobs: steps: - uses: actions/checkout@v4 - uses: ./.github/actions/install_rust - - uses: Swatinem/rust-cache@v2 - with: - prefix-key: "v0-rust-ubuntu-20.04" - run: cargo build -p blockifier - run: cargo test -p blockifier @@ -54,11 +51,6 @@ jobs: steps: - uses: actions/checkout@v4 - uses: ./.github/actions/install_rust - - - uses: Swatinem/rust-cache@v2 - with: - prefix-key: "v1-rust-ubuntu-20.04" - - name: Build native blockifier run: ./build_native_in_docker.sh scripts/build_native_blockifier.sh diff --git a/.github/workflows/blockifier_compiled_cairo.yml b/.github/workflows/blockifier_compiled_cairo.yml index 9e752ae9ef..835e04440a 100644 --- a/.github/workflows/blockifier_compiled_cairo.yml +++ b/.github/workflows/blockifier_compiled_cairo.yml @@ -32,9 +32,6 @@ jobs: steps: - uses: actions/checkout@v4 - uses: ./.github/actions/install_rust - - uses: Swatinem/rust-cache@v2 - with: - prefix-key: "v0-rust-ubuntu-20.04" # Setup pypy and link to the location expected by .cargo/config.toml. - uses: actions/setup-python@v5 diff --git a/.github/workflows/blockifier_post-merge.yml b/.github/workflows/blockifier_post-merge.yml index 194fb23475..c20135acfa 100644 --- a/.github/workflows/blockifier_post-merge.yml +++ b/.github/workflows/blockifier_post-merge.yml @@ -17,9 +17,6 @@ jobs: - uses: actions/checkout@v4 - uses: ./.github/actions/install_rust - uses: Noelware/setup-protoc@1.1.0 - - uses: Swatinem/rust-cache@v2 - with: - prefix-key: "v0-rust-ubuntu-20.04" # Setup pypy and link to the location expected by .cargo/config.toml. - uses: actions/setup-python@v5 diff --git a/.github/workflows/committer_ci.yml b/.github/workflows/committer_ci.yml index d7ce4d16f6..5dbfa34f4d 100644 --- a/.github/workflows/committer_ci.yml +++ b/.github/workflows/committer_ci.yml @@ -42,7 +42,6 @@ jobs: steps: - uses: actions/checkout@v4 - uses: ./.github/actions/install_rust - - uses: Swatinem/rust-cache@v2 - id: auth uses: "google-github-actions/auth@v2" @@ -61,7 +60,6 @@ jobs: - uses: actions/checkout@v4 with: ref: ${{ github.base_ref }} - - uses: Swatinem/rust-cache@v2 # Download the old benchmark inputs. - id: auth @@ -124,7 +122,6 @@ jobs: steps: - uses: actions/checkout@v4 - uses: ./.github/actions/install_rust - - uses: Swatinem/rust-cache@v2 # Commit hash on pull request event would be the head commit of the branch. - name: Get commit hash prefix for PR update diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 61f03d82dc..c29c0b7b3f 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -69,8 +69,6 @@ jobs: # Install rust components. - uses: ./.github/actions/install_rust - with: - components: rustfmt, clippy # Run tests. - name: "Run rustfmt and clippy" @@ -94,7 +92,6 @@ jobs: steps: - uses: actions/checkout@v4 - uses: ./.github/actions/install_rust - - uses: Swatinem/rust-cache@v2 - run: cargo test -p workspace_tests run-tests: @@ -106,9 +103,6 @@ jobs: fetch-depth: 0 - uses: ./.github/actions/install_rust - uses: Noelware/setup-protoc@1.1.0 - - uses: Swatinem/rust-cache@v2 - with: - prefix-key: "v0-rust-ubuntu-20.04" # Setup pypy and link to the location expected by .cargo/config.toml. - uses: actions/setup-python@v5 @@ -183,9 +177,6 @@ jobs: - name: Install cargo-llvm-cov uses: taiki-e/install-action@cargo-llvm-cov - - uses: Swatinem/rust-cache@v2 - with: - prefix-key: "v0-rust-ubuntu-20.04" - run: npm install -g ganache@7.4.3 # Setup pypy and link to the location expected by .cargo/config.toml. diff --git a/.github/workflows/papyrus_ci.yml b/.github/workflows/papyrus_ci.yml index 27f339caa6..140d58a146 100644 --- a/.github/workflows/papyrus_ci.yml +++ b/.github/workflows/papyrus_ci.yml @@ -47,7 +47,6 @@ jobs: steps: - uses: actions/checkout@v4 - uses: ./.github/actions/install_rust - - uses: Swatinem/rust-cache@v2 - uses: Noelware/setup-protoc@1.1.0 with: version: ${{env.PROTOC_VERSION}} @@ -66,7 +65,6 @@ jobs: steps: - uses: actions/checkout@v4 - uses: ./.github/actions/install_rust - - uses: Swatinem/rust-cache@v2 - uses: Noelware/setup-protoc@1.1.0 with: version: ${{env.PROTOC_VERSION}} @@ -85,7 +83,6 @@ jobs: steps: - uses: actions/checkout@v4 - uses: ./.github/actions/install_rust - - uses: Swatinem/rust-cache@v2 - uses: Noelware/setup-protoc@1.1.0 with: version: ${{env.PROTOC_VERSION}} @@ -102,7 +99,6 @@ jobs: steps: - uses: actions/checkout@v4 - uses: ./.github/actions/install_rust - - uses: Swatinem/rust-cache@v2 - uses: Noelware/setup-protoc@1.1.0 - run: | @@ -150,7 +146,6 @@ jobs: target_directory: - 'crates/papyrus_storage/src/db/**' - 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 if: steps.changes.outputs.target_directory == 'true' diff --git a/.github/workflows/papyrus_nightly-tests-call.yml b/.github/workflows/papyrus_nightly-tests-call.yml index 64980b6ab5..3e11b21b1e 100644 --- a/.github/workflows/papyrus_nightly-tests-call.yml +++ b/.github/workflows/papyrus_nightly-tests-call.yml @@ -22,7 +22,6 @@ jobs: steps: - uses: actions/checkout@v4 - 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. if: runner.os == 'Linux' diff --git a/.github/workflows/papyrus_nightly-tests.yml b/.github/workflows/papyrus_nightly-tests.yml index a7a91d5687..af5f385781 100644 --- a/.github/workflows/papyrus_nightly-tests.yml +++ b/.github/workflows/papyrus_nightly-tests.yml @@ -38,7 +38,6 @@ jobs: steps: - uses: actions/checkout@v4 - uses: ./.github/actions/install_rust - - uses: Swatinem/rust-cache@v2 - run: mkdir data @@ -58,7 +57,6 @@ jobs: steps: - uses: actions/checkout@v4 - uses: ./.github/actions/install_rust - - uses: Swatinem/rust-cache@v2 - run: npm install -g ganache@7.4.3 - run: brew install protobuf@$PROTOC_VERSION @@ -74,7 +72,6 @@ jobs: steps: - uses: actions/checkout@v4 - uses: ./.github/actions/install_rust - - uses: Swatinem/rust-cache@v2 - run: cargo build -r -p papyrus_load_test integration-test: @@ -83,7 +80,6 @@ jobs: steps: - uses: actions/checkout@v4 - uses: ./.github/actions/install_rust - - uses: Swatinem/rust-cache@v2 - run: > cargo test -r --test latency_histogram @@ -99,5 +95,4 @@ jobs: steps: - uses: actions/checkout@v4 - 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/commitlint.config.js b/commitlint.config.js index befddee293..c8f31cfc5d 100644 --- a/commitlint.config.js +++ b/commitlint.config.js @@ -33,6 +33,7 @@ const Configuration = { 'fee', 'gateway', 'helm', + 'infra', 'JSON-RPC', 'load_test', 'mempool_node', diff --git a/rust-toolchain.toml b/rust-toolchain.toml new file mode 100644 index 0000000000..2d195afe64 --- /dev/null +++ b/rust-toolchain.toml @@ -0,0 +1,5 @@ +[toolchain] +channel = "stable" +components = [ "rustfmt", "rustc-dev", "clippy" ] +targets = [ "x86_64-unknown-linux-gnu" ] +profile = "default" diff --git a/scripts/merge_branches.py b/scripts/merge_branches.py index 0469e92a51..e13eb336de 100755 --- a/scripts/merge_branches.py +++ b/scripts/merge_branches.py @@ -16,7 +16,7 @@ FINAL_BRANCH = "main" MERGE_PATHS_FILE = "scripts/merge_paths.json" -FILES_TO_PRESERVE = {".github/actions/install_rust/rust_version.txt"} +FILES_TO_PRESERVE = {"rust-toolchain.toml"} def load_merge_paths() -> Dict[str, str]: