From 490ea1b41b443958f9b3a19fa370e0af9b095ef2 Mon Sep 17 00:00:00 2001 From: enitrat Date: Sat, 28 Sep 2024 23:02:01 +0200 Subject: [PATCH] fix fmt --- .github/workflows/ci.yml | 10 +- .github/workflows/test.yml | 31 ++++-- scripts/setup_cairo_native.sh | 187 ++++++++++++++++++---------------- 3 files changed, 123 insertions(+), 105 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f858a28f..256039b7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -33,10 +33,6 @@ jobs: - name: Build contracts run: scarb build -p contracts - upload-artifacts: - runs-on: ubuntu-latest - needs: build - steps: - name: Upload artifacts uses: actions/upload-artifact@v3 with: @@ -54,7 +50,7 @@ jobs: - run: scarb build - run: scarb test - ef-tests: + ef-tests: # trunk-ignore(actionlint/runner-label) runs-on: ubuntu-latest-16-cores needs: [build] @@ -72,7 +68,9 @@ jobs: ~/.cargo/git/db/ target/ ./libcairo_native_runtime.a - key: ${{ runner.os }}-cairo-native-${{ hashFiles('**/Cargo.lock', 'scripts/setup_cairo_native.sh') }} + key: + ${{ runner.os }}-cairo-native-${{ hashFiles('**/Cargo.lock', + 'scripts/setup_cairo_native.sh') }} - name: Make setup script executable run: chmod +x ./scripts/setup_cairo_native.sh diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index da38c8bc..3a84e33b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -9,15 +9,26 @@ concurrency: cancel-in-progress: true jobs: - build: - # trunk-ignore(actionlint/runner-label) - runs-on: ubuntu-latest-16-cores + runs-on: ubuntu-latest + env: + CI_COMMIT_MESSAGE: CI Formatting Auto Commit + CI_COMMIT_AUTHOR: ${{ github.event.repository.name }} CI steps: - - uses: actions/checkout@v4 - - uses: foundry-rs/setup-snfoundry@v3 - - uses: software-mansion/setup-scarb@v1 - - run: scarb build + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Scarb + uses: software-mansion/setup-scarb@v1 + + - name: Build contracts + run: scarb build -p contracts + + - name: Upload artifacts + uses: actions/upload-artifact@v3 + with: + name: kakarot-ssj-build + path: target/dev tests: # trunk-ignore(actionlint/runner-label) @@ -29,7 +40,7 @@ jobs: - run: scarb fmt --check - run: scarb test - ef-tests: + ef-tests: # trunk-ignore(actionlint/runner-label) runs-on: ubuntu-latest-16-cores needs: [build] @@ -47,7 +58,9 @@ jobs: ~/.cargo/git/db/ target/ ./libcairo_native_runtime.a - key: ${{ runner.os }}-cairo-native-${{ hashFiles('**/Cargo.lock', 'scripts/setup_cairo_native.sh') }} + key: + ${{ runner.os }}-cairo-native-${{ hashFiles('**/Cargo.lock', + 'scripts/setup_cairo_native.sh') }} - name: Make setup script executable run: chmod +x ./scripts/setup_cairo_native.sh diff --git a/scripts/setup_cairo_native.sh b/scripts/setup_cairo_native.sh index 8321cab9..ef81af9f 100644 --- a/scripts/setup_cairo_native.sh +++ b/scripts/setup_cairo_native.sh @@ -1,115 +1,122 @@ #!/bin/bash install_essential_deps_linux() { - apt-get update -y - apt-get install -y \ - curl \ - jq \ - ripgrep \ - wget \ - ca-certificates \ - gnupg \ - git + apt-get update -y + apt-get install -y \ + curl \ + jq \ + ripgrep \ + wget \ + ca-certificates \ + gnupg \ + git } setup_llvm_deps() { - case "$(uname)" in - Darwin) - brew update - brew install llvm@19 - - LIBRARY_PATH=/opt/homebrew/lib - MLIR_SYS_190_PREFIX="$(brew --prefix llvm@19)" - LLVM_SYS_191_PREFIX="$MLIR_SYS_190_PREFIX" - TABLEGEN_190_PREFIX="$MLIR_SYS_190_PREFIX" - - export LIBRARY_PATH - export MLIR_SYS_190_PREFIX - export LLVM_SYS_191_PREFIX - export TABLEGEN_190_PREFIX - ;; - Linux) - export DEBIAN_FRONTEND=noninteractive - export TZ=America/New_York - - CODENAME=$(grep VERSION_CODENAME /etc/os-release | cut -d= -f2) - [ -z "$CODENAME" ] && { echo "Error: Unable to determine OS codename"; exit 1; } - - echo "deb http://apt.llvm.org/$CODENAME/ llvm-toolchain-$CODENAME-19 main" > /etc/apt/sources.list.d/llvm-19.list - echo "deb-src http://apt.llvm.org/$CODENAME/ llvm-toolchain-$CODENAME-19 main" >> /etc/apt/sources.list.d/llvm-19.list - wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add - - - apt-get update && apt-get upgrade -y - apt-get install -y llvm-19 llvm-19-dev llvm-19-runtime clang-19 clang-tools-19 lld-19 libpolly-19-dev libmlir-19-dev mlir-19-tools - - MLIR_SYS_190_PREFIX=/usr/lib/llvm-19/ - LLVM_SYS_191_PREFIX=/usr/lib/llvm-19/ - TABLEGEN_190_PREFIX=/usr/lib/llvm-19/ - - export MLIR_SYS_190_PREFIX - export LLVM_SYS_191_PREFIX - export TABLEGEN_190_PREFIX - ;; - *) - echo "Error: Unsupported operating system" - exit 1 - ;; - esac - - # GitHub Actions specific - [ -n "$GITHUB_ACTIONS" ] && { - echo "MLIR_SYS_190_PREFIX=$MLIR_SYS_190_PREFIX" >> $GITHUB_ENV - echo "LLVM_SYS_191_PREFIX=$LLVM_SYS_191_PREFIX" >> $GITHUB_ENV - echo "TABLEGEN_190_PREFIX=$TABLEGEN_190_PREFIX" >> $GITHUB_ENV - } + case "$(uname)" in + Darwin) + brew update + brew install llvm@19 + + LIBRARY_PATH=/opt/homebrew/lib + MLIR_SYS_190_PREFIX="$(brew --prefix llvm@19)" + LLVM_SYS_191_PREFIX="${MLIR_SYS_190_PREFIX}" + TABLEGEN_190_PREFIX="${MLIR_SYS_190_PREFIX}" + + export LIBRARY_PATH + export MLIR_SYS_190_PREFIX + export LLVM_SYS_191_PREFIX + export TABLEGEN_190_PREFIX + ;; + Linux) + export DEBIAN_FRONTEND=noninteractive + export TZ=America/New_York + + CODENAME=$(grep VERSION_CODENAME /etc/os-release | cut -d= -f2) + [[ -z ${CODENAME} ]] && { + echo "Error: Unable to determine OS codename" + exit 1 + } + + echo "deb http://apt.llvm.org/${CODENAME}/ llvm-toolchain-${CODENAME}-19 main" >/etc/apt/sources.list.d/llvm-19.list + echo "deb-src http://apt.llvm.org/${CODENAME}/ llvm-toolchain-${CODENAME}-19 main" >>/etc/apt/sources.list.d/llvm-19.list + wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add - + + apt-get update && apt-get upgrade -y + apt-get install -y llvm-19 llvm-19-dev llvm-19-runtime clang-19 clang-tools-19 lld-19 libpolly-19-dev libmlir-19-dev mlir-19-tools + + MLIR_SYS_190_PREFIX=/usr/lib/llvm-19/ + LLVM_SYS_191_PREFIX=/usr/lib/llvm-19/ + TABLEGEN_190_PREFIX=/usr/lib/llvm-19/ + + export MLIR_SYS_190_PREFIX + export LLVM_SYS_191_PREFIX + export TABLEGEN_190_PREFIX + ;; + *) + echo "Error: Unsupported operating system" + exit 1 + ;; + esac + + # GitHub Actions specific + [[ -n ${GITHUB_ACTIONS} ]] && { + echo "MLIR_SYS_190_PREFIX=${MLIR_SYS_190_PREFIX}" >>"${GITHUB_ENV}" + echo "LLVM_SYS_191_PREFIX=${LLVM_SYS_191_PREFIX}" >>"${GITHUB_ENV}" + echo "TABLEGEN_190_PREFIX=${TABLEGEN_190_PREFIX}" >>"${GITHUB_ENV}" + } } install_rust() { - if command -v cargo >/dev/null 2>&1; then - echo "Rust is already installed with cargo available in PATH." - return 0 - fi - - echo "cargo not found. Installing Rust..." - if ! curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain 1.81.0 --no-modify-path; then - echo >&2 "Failed to install Rust. Aborting." - return 1 - fi - - # shellcheck disable=SC1090 - source "$HOME/.cargo/env" || { - echo >&2 "Failed to source Rust environment. Aborting." - return 1 - } - - echo "Rust installed successfully." + if command -v cargo >/dev/null 2>&1; then + echo "Rust is already installed with cargo available in PATH." + return 0 + fi + + echo "cargo not found. Installing Rust..." + if ! curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain 1.81.0 --no-modify-path; then + echo >&2 "Failed to install Rust. Aborting." + return 1 + fi + + # shellcheck disable=SC1090 + source "${HOME}/.cargo/env" || { + echo >&2 "Failed to source Rust environment. Aborting." + return 1 + } + + echo "Rust installed successfully." } install_cairo_native_runtime() { - install_rust || { echo "Error: Failed to install Rust"; exit 1; } + install_rust || { + echo "Error: Failed to install Rust" + exit 1 + } - git clone https://github.com/lambdaclass/cairo_native.git - pushd ./cairo_native || exit 1 - make deps - make runtime - popd || exit 1 + git clone https://github.com/lambdaclass/cairo_native.git + pushd ./cairo_native || exit 1 + make deps + make runtime + popd || exit 1 - rm -rf ./cairo_native + rm -rf ./cairo_native - export CAIRO_NATIVE_RUNTIME_LIBRARY="$(pwd)/libcairo_native_runtime.a" + CAIRO_NATIVE_RUNTIME_LIBRARY="$(pwd)/libcairo_native_runtime.a" + export CAIRO_NATIVE_RUNTIME_LIBRARY - echo "CAIRO_NATIVE_RUNTIME_LIBRARY=$CAIRO_NATIVE_RUNTIME_LIBRARY" + echo "CAIRO_NATIVE_RUNTIME_LIBRARY=${CAIRO_NATIVE_RUNTIME_LIBRARY}" - [ -n "$GITHUB_ACTIONS" ] && echo "CAIRO_NATIVE_RUNTIME_LIBRARY=$CAIRO_NATIVE_RUNTIME_LIBRARY" >> $GITHUB_ENV + [[ -n ${GITHUB_ACTIONS} ]] && echo "CAIRO_NATIVE_RUNTIME_LIBRARY=${CAIRO_NATIVE_RUNTIME_LIBRARY}" >>"${GITHUB_ENV}" } main() { - [ "$(uname)" = "Linux" ] && install_essential_deps_linux + [[ "$(uname)" == "Linux" ]] && install_essential_deps_linux - setup_llvm_deps - install_cairo_native_runtime + setup_llvm_deps + install_cairo_native_runtime - echo "LLVM and Cairo native runtime dependencies installed successfully." + echo "LLVM and Cairo native runtime dependencies installed successfully." } main "$@"