Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: linux installation of anvil-zksync and add ci check #780

Merged
merged 3 commits into from
Dec 12, 2024
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
19 changes: 19 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -154,3 +154,22 @@ jobs:
run: cp ./install-foundry-zksync ./foundryup-zksync/* /tmp/ && cd /tmp && ./install-foundry-zksync
- name: Verify installation
run: forge --version

check-ci-install-anvil:
name: CI install anvil-zksync
strategy:
fail-fast: false
matrix:
os: [ubuntu-22.04, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4

- name: Install foundry-zksync
run: |
cp ./install-foundry-zksync ./foundryup-zksync/* /tmp/
cd /tmp
./install-foundry-zksync

- name: Verify anvil-zksync installation
run: anvil-zksync --version
60 changes: 33 additions & 27 deletions foundryup-zksync/foundryup-zksync
Original file line number Diff line number Diff line change
Expand Up @@ -179,33 +179,43 @@ EOF
done

# Begin anvil-zksync installation
say "downloading anvil-zksync"

# Supported targets for anvil-zksync
SUPPORTED_TARGETS=(
"x86_64-apple-darwin"
"aarch64-apple-darwin"
"x86_64-unknown-linux-gnu"
"aarch64-unknown-linux-gnu"
)

if [ "$ARCHITECTURE" = "arm64" ]; then
ARCHITECTURE="aarch64"
fi
say "downloading latest anvil-zksync"

uname_str="$(uname)"
case "$uname_str" in
"Linux")
os="unknown-linux-gnu"
# Note: If `lscpu` isn't guaranteed to be available,
# you may want to fallback to `uname -m`
arch=$(lscpu | awk '/Architecture:/{print $2}')
;;
"Darwin")
os="apple-darwin"
arch=$(arch)
;;
*)
err "anvil-zksync only supports Linux and MacOS! Detected OS: $uname_str"
;;
esac

if [ "$PLATFORM" = "darwin" ]; then
TARGET="${ARCHITECTURE}-apple-${PLATFORM}"
elif [ "$PLATFORM" = "linux" ]; then
TARGET="${ARCHITECTURE}-unknown-${PLATFORM}-gnu"
else
TARGET="${ARCHITECTURE}-${PLATFORM}"
fi
# Normalize architecture
case "$arch" in
"x86_64")
architecture="x86_64"
;;
"arm64"|"aarch64")
architecture="aarch64"
;;
*)
err "Unsupported architecture detected!"
;;
esac

TARGET="${architecture}-${os}"

if [[ " ${SUPPORTED_TARGETS[*]} " == *" $TARGET "* ]]; then
if [ "$PLATFORM" = "linux" ] || [ "$PLATFORM" = "darwin" ]; then
ANVIL_REPO="matter-labs/anvil-zksync"

say "getting latest tag for anvil-zksync"

ANVIL_TAG=$(curl -s https://api.github.com/repos/$ANVIL_REPO/releases/latest | sed -n 's/.*"tag_name": "\([^"]*\)".*/\1/p')

if [ -z "$ANVIL_TAG" ]; then
Expand All @@ -218,12 +228,8 @@ EOF

ANVIL_BIN_PATH="$FOUNDRY_BIN_DIR/anvil-zksync"

say "downloading anvil-zksync from $ANVIL_BIN_URL"

ensure download "$ANVIL_BIN_URL" | ensure tar -xzC "$FOUNDRY_BIN_DIR"

mv "$FOUNDRY_BIN_DIR/anvil-zksync" "$ANVIL_BIN_PATH"

chmod +x "$ANVIL_BIN_PATH"

say "installed - $(ensure "$ANVIL_BIN_PATH" --version)"
Expand Down
Loading