Skip to content

Commit e899df9

Browse files
authored
fix: linux installation of anvil-zksync and add ci check (#780)
* fix: linux install * ci: add workflow to check anvil-zksync installation * fix: remove unneeded mv
1 parent 082aff2 commit e899df9

File tree

2 files changed

+52
-27
lines changed

2 files changed

+52
-27
lines changed

.github/workflows/test.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,3 +154,22 @@ jobs:
154154
run: cp ./install-foundry-zksync ./foundryup-zksync/* /tmp/ && cd /tmp && ./install-foundry-zksync
155155
- name: Verify installation
156156
run: forge --version
157+
158+
check-ci-install-anvil:
159+
name: CI install anvil-zksync
160+
strategy:
161+
fail-fast: false
162+
matrix:
163+
os: [ubuntu-22.04, macos-latest]
164+
runs-on: ${{ matrix.os }}
165+
steps:
166+
- uses: actions/checkout@v4
167+
168+
- name: Install foundry-zksync
169+
run: |
170+
cp ./install-foundry-zksync ./foundryup-zksync/* /tmp/
171+
cd /tmp
172+
./install-foundry-zksync
173+
174+
- name: Verify anvil-zksync installation
175+
run: anvil-zksync --version

foundryup-zksync/foundryup-zksync

Lines changed: 33 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -179,33 +179,43 @@ EOF
179179
done
180180

181181
# Begin anvil-zksync installation
182-
say "downloading anvil-zksync"
183-
184-
# Supported targets for anvil-zksync
185-
SUPPORTED_TARGETS=(
186-
"x86_64-apple-darwin"
187-
"aarch64-apple-darwin"
188-
"x86_64-unknown-linux-gnu"
189-
"aarch64-unknown-linux-gnu"
190-
)
191-
192-
if [ "$ARCHITECTURE" = "arm64" ]; then
193-
ARCHITECTURE="aarch64"
194-
fi
182+
say "downloading latest anvil-zksync"
183+
184+
uname_str="$(uname)"
185+
case "$uname_str" in
186+
"Linux")
187+
os="unknown-linux-gnu"
188+
# Note: If `lscpu` isn't guaranteed to be available,
189+
# you may want to fallback to `uname -m`
190+
arch=$(lscpu | awk '/Architecture:/{print $2}')
191+
;;
192+
"Darwin")
193+
os="apple-darwin"
194+
arch=$(arch)
195+
;;
196+
*)
197+
err "anvil-zksync only supports Linux and MacOS! Detected OS: $uname_str"
198+
;;
199+
esac
195200

196-
if [ "$PLATFORM" = "darwin" ]; then
197-
TARGET="${ARCHITECTURE}-apple-${PLATFORM}"
198-
elif [ "$PLATFORM" = "linux" ]; then
199-
TARGET="${ARCHITECTURE}-unknown-${PLATFORM}-gnu"
200-
else
201-
TARGET="${ARCHITECTURE}-${PLATFORM}"
202-
fi
201+
# Normalize architecture
202+
case "$arch" in
203+
"x86_64")
204+
architecture="x86_64"
205+
;;
206+
"arm64"|"aarch64")
207+
architecture="aarch64"
208+
;;
209+
*)
210+
err "Unsupported architecture detected!"
211+
;;
212+
esac
213+
214+
TARGET="${architecture}-${os}"
203215

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

207-
say "getting latest tag for anvil-zksync"
208-
209219
ANVIL_TAG=$(curl -s https://api.github.com/repos/$ANVIL_REPO/releases/latest | sed -n 's/.*"tag_name": "\([^"]*\)".*/\1/p')
210220

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

219229
ANVIL_BIN_PATH="$FOUNDRY_BIN_DIR/anvil-zksync"
220230

221-
say "downloading anvil-zksync from $ANVIL_BIN_URL"
222-
223231
ensure download "$ANVIL_BIN_URL" | ensure tar -xzC "$FOUNDRY_BIN_DIR"
224232

225-
mv "$FOUNDRY_BIN_DIR/anvil-zksync" "$ANVIL_BIN_PATH"
226-
227233
chmod +x "$ANVIL_BIN_PATH"
228234

229235
say "installed - $(ensure "$ANVIL_BIN_PATH" --version)"

0 commit comments

Comments
 (0)