Skip to content

Commit

Permalink
chore(infra): use rust-toolchain.toml to align rust toolchains locall…
Browse files Browse the repository at this point in the history
…y and in ci
  • Loading branch information
alon-dotan-starkware committed Aug 29, 2024
1 parent 00b348d commit 59239d8
Show file tree
Hide file tree
Showing 13 changed files with 8 additions and 63 deletions.
25 changes: 1 addition & 24 deletions .github/actions/install_rust/action.yml
Original file line number Diff line number Diff line change
@@ -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
1 change: 0 additions & 1 deletion .github/actions/install_rust/rust_version.txt

This file was deleted.

8 changes: 0 additions & 8 deletions .github/workflows/blockifier_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/blockifier_compiled_cairo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/blockifier_post-merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ jobs:
- uses: actions/checkout@v4
- uses: ./.github/actions/install_rust
- uses: Noelware/[email protected]
- 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
Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/committer_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
9 changes: 0 additions & 9 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,6 @@ jobs:

# Install rust components.
- uses: ./.github/actions/install_rust
with:
components: rustfmt, clippy

# Run tests.
- name: "Run rustfmt and clippy"
Expand All @@ -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:
Expand All @@ -106,9 +103,6 @@ jobs:
fetch-depth: 0
- uses: ./.github/actions/install_rust
- uses: Noelware/[email protected]
- 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
Expand Down Expand Up @@ -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 [email protected]

# Setup pypy and link to the location expected by .cargo/config.toml.
Expand Down
5 changes: 0 additions & 5 deletions .github/workflows/papyrus_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/install_rust
- uses: Swatinem/rust-cache@v2
- uses: Noelware/[email protected]
with:
version: ${{env.PROTOC_VERSION}}
Expand All @@ -66,7 +65,6 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/install_rust
- uses: Swatinem/rust-cache@v2
- uses: Noelware/[email protected]
with:
version: ${{env.PROTOC_VERSION}}
Expand All @@ -85,7 +83,6 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/install_rust
- uses: Swatinem/rust-cache@v2
- uses: Noelware/[email protected]
with:
version: ${{env.PROTOC_VERSION}}
Expand All @@ -102,7 +99,6 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/install_rust
- uses: Swatinem/rust-cache@v2
- uses: Noelware/[email protected]

- run: |
Expand Down Expand Up @@ -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'
1 change: 0 additions & 1 deletion .github/workflows/papyrus_nightly-tests-call.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
5 changes: 0 additions & 5 deletions .github/workflows/papyrus_nightly-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/install_rust
- uses: Swatinem/rust-cache@v2

- run: mkdir data

Expand All @@ -58,7 +57,6 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/install_rust
- uses: Swatinem/rust-cache@v2
- run: npm install -g [email protected]

- run: brew install protobuf@$PROTOC_VERSION
Expand All @@ -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:
Expand All @@ -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
Expand All @@ -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
1 change: 1 addition & 0 deletions commitlint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ const Configuration = {
'fee',
'gateway',
'helm',
'infra',
'JSON-RPC',
'load_test',
'mempool_node',
Expand Down
5 changes: 5 additions & 0 deletions rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[toolchain]
channel = "stable"
components = [ "rustfmt", "rustc-dev", "clippy" ]
targets = [ "x86_64-unknown-linux-gnu" ]
profile = "default"
2 changes: 1 addition & 1 deletion scripts/merge_branches.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]:
Expand Down

0 comments on commit 59239d8

Please sign in to comment.