Skip to content

Commit bf7b635

Browse files
authored
Add release support for anvil-polkadot (#444)
1 parent 3dd3c5c commit bf7b635

File tree

4 files changed

+77
-9
lines changed

4 files changed

+77
-9
lines changed

.github/workflows/release.yml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ jobs:
168168
cargo build $flags
169169
fi
170170
171-
bins=(cast forge)
171+
bins=(cast forge anvil-polkadot)
172172
for name in "${bins[@]}"; do
173173
bin=$OUT_DIR/$name$ext
174174
echo ""
@@ -189,16 +189,16 @@ jobs:
189189
shell: bash
190190
run: |
191191
if [ "$PLATFORM_NAME" == "linux" ]; then
192-
tar -czvf "foundry_${VERSION_NAME}_${PLATFORM_NAME}_${ARCH}.tar.gz" -C $OUT_DIR forge cast
192+
tar -czvf "foundry_${VERSION_NAME}_${PLATFORM_NAME}_${ARCH}.tar.gz" -C $OUT_DIR forge cast anvil-polkadot
193193
echo "file_name=foundry_${VERSION_NAME}_${PLATFORM_NAME}_${ARCH}.tar.gz" >> $GITHUB_OUTPUT
194194
elif [ "$PLATFORM_NAME" == "darwin" ]; then
195195
# We need to use gtar here otherwise the archive is corrupt.
196196
# See: https://github.com/actions/virtual-environments/issues/2619
197-
gtar -czvf "foundry_${VERSION_NAME}_${PLATFORM_NAME}_${ARCH}.tar.gz" -C $OUT_DIR forge cast
197+
gtar -czvf "foundry_${VERSION_NAME}_${PLATFORM_NAME}_${ARCH}.tar.gz" -C $OUT_DIR forge cast anvil-polkadot
198198
echo "file_name=foundry_${VERSION_NAME}_${PLATFORM_NAME}_${ARCH}.tar.gz" >> $GITHUB_OUTPUT
199199
else
200200
cd $OUT_DIR
201-
7z a -tzip "foundry_${VERSION_NAME}_${PLATFORM_NAME}_${ARCH}.zip" forge.exe cast.exe
201+
7z a -tzip "foundry_${VERSION_NAME}_${PLATFORM_NAME}_${ARCH}.zip" forge.exe cast.exe anvil-polkadot.exe
202202
mv "foundry_${VERSION_NAME}_${PLATFORM_NAME}_${ARCH}.zip" ../../../
203203
echo "file_name=foundry_${VERSION_NAME}_${PLATFORM_NAME}_${ARCH}.zip" >> $GITHUB_OUTPUT
204204
fi
@@ -215,9 +215,11 @@ jobs:
215215
sudo apt-get -y install help2man
216216
help2man -N $OUT_DIR/forge > forge.1
217217
help2man -N $OUT_DIR/cast > cast.1
218+
help2man -N $OUT_DIR/anvil-polkadot > anvil-polkadot.1
218219
gzip forge.1
219220
gzip cast.1
220-
tar -czvf "foundry_man_${VERSION_NAME}.tar.gz" forge.1.gz cast.1.gz
221+
gzip anvil-polkadot.1
222+
tar -czvf "foundry_man_${VERSION_NAME}.tar.gz" forge.1.gz cast.1.gz anvil-polkadot.1.gz
221223
echo "foundry_man=foundry_man_${VERSION_NAME}.tar.gz" >> $GITHUB_OUTPUT
222224
223225
- name: Binaries attestation
@@ -227,6 +229,7 @@ jobs:
227229
subject-path: |
228230
${{ env.cast_bin_path }}
229231
${{ env.forge_bin_path }}
232+
${{ env.anvil_polkadot_bin_path }}
230233
231234
- name: Record attestation URL
232235
run: |

foundryup/foundryup

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ set -eo pipefail
33

44
# NOTE: if you make modifications to this script, please increment the version number.
55
# WARNING: the SemVer pattern: major.minor.patch must be followed as we use it to determine if the script is up to date.
6-
FOUNDRYUP_INSTALLER_VERSION="1.3.0"
6+
FOUNDRYUP_INSTALLER_VERSION="1.4.0"
77

88
BASE_DIR=${XDG_CONFIG_HOME:-$HOME}
99
FOUNDRY_DIR=${FOUNDRY_DIR:-"$BASE_DIR/.foundry"}
@@ -16,7 +16,7 @@ FOUNDRY_BIN_PATH="$FOUNDRY_BIN_DIR/foundryup-polkadot"
1616
FOUNDRYUP_JOBS=""
1717
FOUNDRYUP_IGNORE_VERIFICATION=false
1818

19-
BINS=(forge cast)
19+
BINS=(forge cast anvil-polkadot)
2020

2121
export RUSTFLAGS="${RUSTFLAGS:--C target-cpu=native}"
2222

@@ -161,7 +161,7 @@ main() {
161161
# If `--force` is set, skip the SHA verification.
162162
if [ "$FOUNDRYUP_IGNORE_VERIFICATION" = false ]; then
163163
# Check if the version is already installed by downloading the attestation file.
164-
say "checking if forge, cast, anvil, and chisel for $FOUNDRYUP_TAG version are already installed"
164+
say "checking if forge, cast, anvil-polkadot, and chisel for $FOUNDRYUP_TAG version are already installed"
165165

166166
# Create a temporary directory to store the attestation link and artifact.
167167
tmp_dir="$(mktemp -d 2>/dev/null || echo ".")"
@@ -252,7 +252,7 @@ main() {
252252
fi
253253

254254
# Download and extract the binaries archive
255-
say "downloading forge and cast for $FOUNDRYUP_TAG version"
255+
say "downloading forge, cast, and anvil-polkadot for $FOUNDRYUP_TAG version"
256256
if [ "$PLATFORM" = "win32" ]; then
257257
tmp="$(mktemp -d 2>/dev/null || echo ".")/foundry.zip"
258258
ensure download "$BIN_ARCHIVE_URL" "$tmp"

release-test/Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
FROM ubuntu:24.04 AS builder
44

5+
# Expose Anvil's default port (Useful for users running the node)
6+
EXPOSE 8545
7+
58
ARG VERSION=stable
69

710
RUN apt-get update && \

release-test/anvil-polkadot.sh

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
#!/bin/sh
2+
3+
# docker run --rm -it -v $PWD/test:/test -w /test foundry sh
4+
5+
REPOSITORY="test"
6+
7+
> anvil-polkadot.txt
8+
9+
clear
10+
11+
rm -rf $REPOSITORY && mkdir $REPOSITORY
12+
13+
docker_run() {
14+
echo "\033[0;32m> $@\033[0m"
15+
16+
echo "> $@" >> anvil-polkadot.txt
17+
18+
cache=$(mktemp)
19+
20+
# Note: running anvil requires passing the command string correctly if it contains shell operators
21+
docker run --rm -v "$PWD/$REPOSITORY":/"$REPOSITORY" -w /"$REPOSITORY" foundry "$@" > "$cache" 2>&1
22+
23+
status=$?
24+
25+
cat "$cache" | tee -a anvil-polkadot.txt
26+
27+
rm -f "$cache"
28+
29+
if [ $status -ne 0 ]; then
30+
echo "\033[0;31mERROR: Command failed with exit status $status: $@\033[0m"
31+
exit 1
32+
fi
33+
}
34+
35+
# 1. Basic Binary Checks
36+
# ----------------------
37+
docker_run anvil-polkadot --version
38+
docker_run anvil-polkadot --help
39+
40+
# 2. Liveness Tests
41+
# ----------------------
42+
# Anvil is a server, so we must start it in the background, wait, and then check if it's still alive.
43+
# We use 'sh -c' to wrap the backgrounding and killing logic inside the container.
44+
# If anvil crashes on startup, 'kill $PID' will fail, causing the test to fail.
45+
46+
echo "\033[0;33mTesting Basic Startup...\033[0m"
47+
docker_run sh -c "anvil-polkadot & PID=\$!; sleep 3; kill \$PID"
48+
49+
# 3. Mining Test
50+
# ----------------------
51+
# Test Block Time configuration.
52+
# We use 1 second block time so we can see blocks produced within the 5 second sleep window.
53+
echo "\033[0;33mTesting Block Time (--block-time 1)...\033[0m"
54+
docker_run sh -c "anvil-polkadot --block-time 1 & PID=\$!; sleep 5; kill \$PID"
55+
56+
# 4. Account Test
57+
# ----------------------
58+
# Test Account Generation configuration (Sanity check for CLI parsing)
59+
echo "\033[0;33mTesting Account Configuration (--accounts)...\033[0m"
60+
docker_run sh -c "anvil-polkadot --accounts 5 --balance 1000 & PID=\$!; sleep 3; kill \$PID"
61+
62+
echo "\033[0;32mAll anvil-polkadot tests passed!\033[0m"

0 commit comments

Comments
 (0)