From 72ba6916be6f64a3817f8d761f38bc745da72adf Mon Sep 17 00:00:00 2001 From: Dustin Brickwood Date: Thu, 12 Dec 2024 07:54:20 -0600 Subject: [PATCH 1/3] fix: linux install --- foundryup-zksync/foundryup-zksync | 58 ++++++++++++++++++------------- 1 file changed, 33 insertions(+), 25 deletions(-) diff --git a/foundryup-zksync/foundryup-zksync b/foundryup-zksync/foundryup-zksync index b61be118f..51ab38c8d 100755 --- a/foundryup-zksync/foundryup-zksync +++ b/foundryup-zksync/foundryup-zksync @@ -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 @@ -218,8 +228,6 @@ 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" From 68d232ae465b9ec5ebfe84a497e99b3a573fbb10 Mon Sep 17 00:00:00 2001 From: Dustin Brickwood Date: Thu, 12 Dec 2024 08:02:02 -0600 Subject: [PATCH 2/3] ci: add workflow to check anvil-zksync installation --- .github/workflows/test.yml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 3a42d2358..0d8ca6513 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -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 \ No newline at end of file From aef85a6716da1345c82c73f2fd57df2ddf18ed63 Mon Sep 17 00:00:00 2001 From: Dustin Brickwood Date: Thu, 12 Dec 2024 08:18:20 -0600 Subject: [PATCH 3/3] fix: remove unneeded mv --- foundryup-zksync/foundryup-zksync | 2 -- 1 file changed, 2 deletions(-) diff --git a/foundryup-zksync/foundryup-zksync b/foundryup-zksync/foundryup-zksync index 51ab38c8d..a157c78d9 100755 --- a/foundryup-zksync/foundryup-zksync +++ b/foundryup-zksync/foundryup-zksync @@ -230,8 +230,6 @@ EOF 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)"