Skip to content

Commit

Permalink
fix: linux installation of anvil-zksync and add ci check (#780)
Browse files Browse the repository at this point in the history
* fix: linux install

* ci: add workflow to check anvil-zksync installation

* fix: remove unneeded mv
  • Loading branch information
dutterbutter authored Dec 12, 2024
1 parent 082aff2 commit e899df9
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 27 deletions.
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

0 comments on commit e899df9

Please sign in to comment.