Skip to content

Commit

Permalink
fix fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
enitrat committed Sep 28, 2024
1 parent 4b73c09 commit 490ea1b
Show file tree
Hide file tree
Showing 3 changed files with 123 additions and 105 deletions.
10 changes: 4 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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]
Expand All @@ -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
Expand Down
31 changes: 22 additions & 9 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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]
Expand All @@ -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
Expand Down
187 changes: 97 additions & 90 deletions scripts/setup_cairo_native.sh
Original file line number Diff line number Diff line change
@@ -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)

Check notice on line 35 in scripts/setup_cairo_native.sh

View workflow job for this annotation

GitHub Actions / Trunk Check

shellcheck(SC2312)

[new] Consider invoking this command separately to avoid masking its return value (or use '|| true' to ignore).
[[ -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 -

Check notice on line 43 in scripts/setup_cairo_native.sh

View workflow job for this annotation

GitHub Actions / Trunk Check

shellcheck(SC2312)

[new] Consider invoking this command separately to avoid masking its return value (or use '|| true' to ignore).

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}"

Check notice on line 64 in scripts/setup_cairo_native.sh

View workflow job for this annotation

GitHub Actions / Trunk Check

shellcheck(SC2129)

[new] Consider using { cmd1; cmd2; } >> file instead of individual redirects.
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

Check notice on line 77 in scripts/setup_cairo_native.sh

View workflow job for this annotation

GitHub Actions / Trunk Check

shellcheck(SC2312)

[new] Consider invoking this command separately to avoid masking its return value (or use '|| true' to ignore).
echo >&2 "Failed to install Rust. Aborting."
return 1
fi

# shellcheck disable=SC1090
source "${HOME}/.cargo/env" || {

Check notice on line 83 in scripts/setup_cairo_native.sh

View workflow job for this annotation

GitHub Actions / Trunk Check

shellcheck(SC1091)

[new] Not following: ./.cargo/env: openBinaryFile: does not exist (No such file or directory)
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

Check notice on line 114 in scripts/setup_cairo_native.sh

View workflow job for this annotation

GitHub Actions / Trunk Check

shellcheck(SC2312)

[new] Consider invoking this command separately to avoid masking its return value (or use '|| true' to ignore).

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 "$@"

0 comments on commit 490ea1b

Please sign in to comment.