Commit ac9e583b authored by Mark Tyneway's avatar Mark Tyneway Committed by GitHub

Merge pull request #8142 from ethereum-optimism/cl/ci-builder-foundry-nightly

feat(ci-builder): Add `install-foundry` script to detect commit SHAs with `nightly` tags
parents b00cc29e 5201cb40
d85718785859dc0b5a095d2302d1a20ec06ab77a
529559c01fabad0e6316d605fd2c4326b8ad6567
......@@ -2,8 +2,6 @@ FROM --platform=linux/amd64 debian:bullseye-slim as rust-build
SHELL ["/bin/bash", "-c"]
WORKDIR /opt
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && \
apt-get install -y curl build-essential git clang lld curl
......@@ -21,16 +19,10 @@ RUN source $HOME/.profile && cargo install svm-rs
# Only diff from upstream docker image is this clone instead
# of COPY. We select a specific commit to use.
COPY ./.foundryrc ./.foundryrc
RUN git clone https://github.com/foundry-rs/foundry.git ./foundry \
&& cd foundry && git checkout $(cat ../.foundryrc)
WORKDIR /opt/foundry
COPY ./ops/scripts/install-foundry.sh ./install-foundry.sh
RUN source $HOME/.profile && \
cargo build --release && \
strip /opt/foundry/target/release/forge && \
strip /opt/foundry/target/release/cast && \
strip /opt/foundry/target/release/anvil
RUN curl -L https://foundry.paradigm.xyz | bash
RUN source $HOME/.profile && ./install-foundry.sh
FROM --platform=linux/amd64 ghcr.io/crytic/echidna/echidna:v2.0.4 as echidna-test
......@@ -81,9 +73,9 @@ COPY --from=go-build /go/bin/geth /usr/local/bin/geth
COPY --from=rust-build /root/.cargo/bin /root/.cargo/bin
COPY --from=rust-build /root/.rustup /root/.rustup
# copy tools
COPY --from=rust-build /opt/foundry/target/release/forge /usr/local/bin/forge
COPY --from=rust-build /opt/foundry/target/release/cast /usr/local/bin/cast
COPY --from=rust-build /opt/foundry/target/release/anvil /usr/local/bin/anvil
COPY --from=rust-build /root/.foundry/bin/forge /usr/local/bin/forge
COPY --from=rust-build /root/.foundry/bin/cast /usr/local/bin/cast
COPY --from=rust-build /root/.foundry/bin/anvil /usr/local/bin/anvil
COPY --from=echidna-test /usr/local/bin/echidna-test /usr/local/bin/echidna-test
......
......@@ -3,3 +3,4 @@
!/.abigenrc
!/.gethrc
!/.nvmrc
!/ops/scripts/install-foundry.sh
#!/bin/bash
set -e
# Grab the `.foundryrc` commit hash.
SHA=$(cat ./.foundryrc)
# Check if there is a nightly tag corresponding to the `.foundryrc` commit hash
TAG="nightly-$SHA"
# Create a temporary directory
TMP_DIR=$(mktemp -d)
echo "Created tempdir @ $TMP_DIR"
# Clone the foundry repo temporarily. We do this to avoid the need for a personal access
# token to interact with the GitHub REST API, and clean it up after we're done.
git clone https://github.com/foundry-rs/foundry.git $TMP_DIR && cd $TMP_DIR
# If the nightly tag exists, we can download the pre-built binaries rather than building
# from source. Otherwise, clone the repository, check out the commit SHA, and build `forge`,
# `cast`, `anvil`, and `chisel` from source.
if git rev-parse "$TAG" >/dev/null 2>&1; then
echo "Nightly tag exists! Downloading prebuilt binaries..."
foundryup -v $TAG
else
echo "Nightly tag doesn't exist! Building from source..."
foundryup -C $SHA
fi
# Remove the temporary foundry repo; Used just for checking the nightly tag's existence.
rm -rf $TMP_DIR
echo "Removed tempdir @ $TMP_DIR"
......@@ -31,7 +31,7 @@
"release:publish": "pnpm install --frozen-lockfile && npx nx run-many --target=build && pnpm build && changeset publish",
"release:version": "changeset version && pnpm install --lockfile-only",
"install:foundry": "curl -L https://foundry.paradigm.xyz | bash && pnpm update:foundry",
"update:foundry": "foundryup -C $(cat .foundryrc)",
"update:foundry": "bash ./ops/scripts/install-foundry.sh",
"install:abigen": "go install github.com/ethereum/go-ethereum/cmd/abigen@$(cat .abigenrc)",
"print:abigen": "abigen --version | sed -e 's/[^0-9]/ /g' -e 's/^ *//g' -e 's/ *$//g' -e 's/ /./g' -e 's/^/v/'",
"check:abigen": "[[ $(abigen --version | sed -e 's/[^0-9]/ /g' -e 's/^ *//g' -e 's/ *$//g' -e 's/ /./g' -e 's/^/v/') = $(cat .abigenrc) ]] && echo '✓ abigen versions match' || (echo '✗ abigen version mismatch. Run `pnpm upgrade:abigen` to upgrade.' && exit 1)",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment