Skip to content
This repository was archived by the owner on Jul 22, 2024. It is now read-only.

Revert "Update Pr: Make contract caches shared (#1071)" #1116

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .gitattributes

This file was deleted.

297 changes: 182 additions & 115 deletions .github/workflows/rust-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,169 +9,240 @@ on:

env:
CARGO_TERM_COLOR: always
RUST_TOOLCHAIN: '1.72.1'
RUST_TOOLCHAIN: 1.70.0
CAIRO_PROGRAMS_PATH: |
cairo_programs/**/*.casm
cairo_programs/**/*.sierra
cairo_programs/**/*.json
starknet_programs/**/*.casm
starknet_programs/**/*.sierra
starknet_programs/**/*.json
!starknet_programs/raw_contract_classes/*

jobs:
build:
name: Build with release profile
runs-on: ubuntu-latest
build-programs:
strategy:
matrix:
program-target: [
compile-cairo,
compile-starknet,
compile-cairo-1-casm,
compile-cairo-1-sierra,
compile-cairo-2-casm,
compile-cairo-2-sierra,
]
name: Build Cairo programs
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install Rust $RUST_TOOLCHAIN
uses: dtolnay/rust-toolchain@master
with:
toolchain: $RUST_TOOLCHAIN
components: rustfmt, clippy
fetch-depth: 0

- name: Fetch from cache
uses: actions/cache@v3
id: cache-programs
with:
path: ${{ env.CAIRO_PROGRAMS_PATH }}
key: ${{ matrix.program-target }}-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'starknet_programs/**/*.cairo') }}
restore-keys: ${{ matrix.program-target }}-cache-

# This is not pretty, but we need `make` to see the compiled programs are
# actually newer than the sources, otherwise it will try to rebuild them
- name: Restore timestamps
uses: chetan/git-restore-mtime-action@v1

- name: Python3 Build
if: ${{ steps.cache-programs.outputs.cache-hit != 'true' }}
uses: actions/setup-python@v4
with:
python-version: '3.9'
cache: 'pip'

- name: Install deps
if: ${{ steps.cache-programs.outputs.cache-hit != 'true' }}
run: make deps

- name: Build programs
if: ${{ steps.cache-programs.outputs.cache-hit != 'true' }}
run: make -j ${{ matrix.program-target }}

# NOTE: used to reduce the amount of cache steps we need in later jobs
# TODO: remove this cache once the workflow finishes
merge-caches:
name: Merge Cairo programs cache
runs-on: ubuntu-22.04
needs: build-programs
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Fetch from cache (compile-cairo)
uses: actions/cache/restore@v3
id: cache-programs
with:
path: ${{ env.CAIRO_PROGRAMS_PATH }}
key: compile-cairo-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'starknet_programs/**/*.cairo') }}
fail-on-cache-miss: true

- name: Fetch from cache (compile-starknet)
uses: actions/cache/restore@v3
with:
path: ${{ env.CAIRO_PROGRAMS_PATH }}
key: compile-starknet-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'starknet_programs/**/*.cairo') }}
fail-on-cache-miss: true

- name: Fetch from cache (compile-cairo-1-casm)
uses: actions/cache/restore@v3
with:
path: ${{ env.CAIRO_PROGRAMS_PATH }}
key: compile-cairo-1-casm-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'starknet_programs/**/*.cairo') }}
fail-on-cache-miss: true

- name: Fetch from cache (compile-cairo-1-sierra)
uses: actions/cache/restore@v3
with:
path: ${{ env.CAIRO_PROGRAMS_PATH }}
key: compile-cairo-1-sierra-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'starknet_programs/**/*.cairo') }}
fail-on-cache-miss: true

- name: Fetch from cache (compile-cairo-2-casm)
uses: actions/cache/restore@v3
with:
path: ${{ env.CAIRO_PROGRAMS_PATH }}
key: compile-cairo-2-casm-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'starknet_programs/**/*.cairo') }}
fail-on-cache-miss: true

- name: Fetch from cache (compile-cairo-2-sierra)
uses: actions/cache/restore@v3
with:
path: ${{ env.CAIRO_PROGRAMS_PATH }}
key: compile-cairo-2-sierra-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'starknet_programs/**/*.cairo') }}
fail-on-cache-miss: true

- name: Fetch from cache (compile-cairo-2-sierra)
uses: actions/cache/restore@v3
with:
path: ${{ env.CAIRO_PROGRAMS_PATH }}
key: compile-cairo-2-sierra-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'starknet_programs/**/*.cairo') }}
fail-on-cache-miss: true

- name: Merge caches
uses: actions/cache/save@v3
with:
path: ${{ env.CAIRO_PROGRAMS_PATH }}
key: all-programs-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'starknet_programs/**/*.cairo') }}

build:
name: Build with release profile
needs: merge-caches
runs-on: ubuntu-22.04
steps:
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: ${{ env.RUST_TOOLCHAIN }}
components: rustfmt, clippy
- uses: Swatinem/rust-cache@v2
with:
cache-on-failure: true
- name: Checkout
uses: actions/checkout@v3
- name: Fetch programs
uses: actions/cache/restore@v3
with:
path: ${{ env.CAIRO_PROGRAMS_PATH }}
key: all-programs-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'starknet_programs/**/*.cairo') }}
fail-on-cache-miss: true

- name: Install deps
run: make deps
- name: Build
run: make build
run: cargo build --release --workspace

lint:
name: Lint with fmt and clippy
runs-on: ubuntu-latest
env:
MLIR_SYS_170_PREFIX: /usr/lib/llvm-17/
TABLEGEN_170_PREFIX: /usr/lib/llvm-17/
needs: merge-caches
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install Rust $RUST_TOOLCHAIN
uses: dtolnay/rust-toolchain@master
with:
toolchain: $RUST_TOOLCHAIN
components: rustfmt, clippy
- name: Python3 Build
uses: actions/setup-python@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
python-version: '3.9'
cache: 'pip'
toolchain: ${{ env.RUST_TOOLCHAIN }}
components: rustfmt, clippy
- uses: Swatinem/rust-cache@v2
with:
cache-on-failure: true
- name: check and free hdd space left
run: |
echo "Listing 20 largest packages"
dpkg-query -Wf '${Installed-Size}\t${Package}\n' | sort -n | tail -n 20
df -h
sudo apt-get update
sudo apt-get remove -y '^llvm-.*'
sudo apt-get remove -y 'php.*'
sudo apt-get remove -y '^dotnet-.*'
sudo apt-get remove -y '^temurin-.*'
sudo apt-get remove -y azure-cli google-cloud-cli microsoft-edge-stable google-chrome-stable firefox powershell mono-devel
sudo apt-get autoremove -y
sudo apt-get clean
df -h
echo "Removing large directories"
# deleting 15GB
sudo rm -rf /usr/share/dotnet/
sudo rm -rf /usr/local/lib/android
df -h
- name: add llvm deb repository
uses: myci-actions/add-deb-repo@10
with:
repo: deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-17 main
repo-name: llvm-repo
keys-asc: https://apt.llvm.org/llvm-snapshot.gpg.key
- name: Install LLVM
run: sudo apt-get install llvm-17 llvm-17-dev llvm-17-runtime clang-17 clang-tools-17 lld-17 libpolly-17-dev libmlir-17-dev mlir-17-tools
- name: Install deps
run: make deps
- name: Checkout
uses: actions/checkout@v3
- name: Fetch programs
uses: actions/cache/restore@v3
with:
path: ${{ env.CAIRO_PROGRAMS_PATH }}
key: all-programs-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'starknet_programs/**/*.cairo') }}
fail-on-cache-miss: true

- name: Format
run: cargo fmt --all -- --check
- name: Run clippy
run: make clippy
run: cargo clippy --workspace --all-targets -- -D warnings

tests:
env:
INFURA_API_KEY: ${{ secrets.INFURA_API_KEY }}
MLIR_SYS_170_PREFIX: /usr/lib/llvm-17/
TABLEGEN_170_PREFIX: /usr/lib/llvm-17/
strategy:
fail-fast: false
matrix:
target: [ test-cairo-1, test-cairo-2, test-doctests, test-cairo-native ]
target: [ test-cairo-1, test-cairo-2, test-doctests ]
name: Run tests
runs-on: ubuntu-latest
needs: merge-caches
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install Rust $RUST_TOOLCHAIN
uses: dtolnay/rust-toolchain@master
with:
toolchain: $RUST_TOOLCHAIN
components: rustfmt, clippy
- name: Python3 Build
uses: actions/setup-python@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
python-version: '3.9'
cache: 'pip'
toolchain: ${{ env.RUST_TOOLCHAIN }}
components: rustfmt, clippy
- uses: Swatinem/rust-cache@v2
with:
cache-on-failure: true
- name: Checkout
uses: actions/checkout@v3

- name: Install deps
run: make deps

- name: Fetch programs
uses: actions/cache/restore@v3
with:
path: ${{ env.CAIRO_PROGRAMS_PATH }}
key: all-programs-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'starknet_programs/**/*.cairo') }}
fail-on-cache-miss: true

- name: Install testing tools
# TODO: remove `if` when nextest adds doctests support
if: ${{ matrix.target != 'test-doctests' }}
uses: taiki-e/install-action@v2
with:
tool: cargo-nextest@0.9.49

- name: check and free hdd space left
run: |
echo "Listing 20 largest packages"
dpkg-query -Wf '${Installed-Size}\t${Package}\n' | sort -n | tail -n 20
df -h
sudo apt-get update
sudo apt-get remove -y '^llvm-.*'
sudo apt-get remove -y 'php.*'
sudo apt-get remove -y '^dotnet-.*'
sudo apt-get remove -y '^temurin-.*'
sudo apt-get remove -y azure-cli google-cloud-cli microsoft-edge-stable google-chrome-stable firefox powershell mono-devel
sudo apt-get autoremove -y
sudo apt-get clean
df -h
echo "Removing large directories"
# deleting 15GB
sudo rm -rf /usr/share/dotnet/
sudo rm -rf /usr/local/lib/android
df -h
- name: add llvm deb repository
uses: myci-actions/add-deb-repo@10
with:
repo: deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-17 main
repo-name: llvm-repo
keys-asc: https://apt.llvm.org/llvm-snapshot.gpg.key
- name: Install LLVM
run: sudo apt-get install llvm-17 llvm-17-dev llvm-17-runtime clang-17 clang-tools-17 lld-17 libpolly-17-dev libmlir-17-dev mlir-17-tools
- name: Run tests (${{ matrix.target }})
run: make ${{ matrix.target }}

coverage:
needs: merge-caches
name: Generate and upload coverage report
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install Rust
uses: dtolnay/rust-toolchain@nightly
with:
toolchain: ${{ env.RUST_TOOLCHAIN }}

- name: Set nightly as default
run: rustup default nightly

- name: Install Rust nightly
uses: dtolnay/rust-toolchain@master
- name: Install testing tools
uses: taiki-e/install-action@v2
with:
toolchain: nightly
tool: cargo-nextest@0.9.49,cargo-llvm-cov

- uses: Swatinem/rust-cache@v2
with:
Expand All @@ -184,17 +255,13 @@ jobs:
path: lcov.info
key: coverage-cache-${{ github.sha }}

- name: Python3 Build
uses: actions/setup-python@v4
with:
python-version: '3.9'
cache: 'pip'
- uses: Swatinem/rust-cache@v2
- name: Fetch programs
if: steps.restore-report.outputs.cache-hit != 'true'
uses: actions/cache/restore@v3
with:
cache-on-failure: true

- name: Install deps
run: make deps
path: ${{ env.CAIRO_PROGRAMS_PATH }}
key: all-programs-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'starknet_programs/**/*.cairo') }}
fail-on-cache-miss: true

- name: Generate coverage report
if: steps.restore-report.outputs.cache-hit != 'true'
Expand Down
Loading