-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Expected Foundry checks and install script updates (#9429)
- Loading branch information
1 parent
0442d9f
commit 8432a71
Showing
4 changed files
with
56 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 30 additions & 3 deletions
33
packages/contracts-bedrock/scripts/verify-foundry-install.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,38 @@ | ||
#!/usr/bin/env bash | ||
|
||
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) | ||
CONTRACTS_BASE=$(dirname "$SCRIPT_DIR") | ||
MONOREPO_BASE=$(dirname "$(dirname "$CONTRACTS_BASE")") | ||
VERSIONS_FILE="${MONOREPO_BASE}/versions.json" | ||
|
||
if ! command -v forge &> /dev/null | ||
then | ||
# shellcheck disable=SC2006 | ||
echo "Is Foundry not installed? Consider installing via `curl -L https://foundry.paradigm.xyz | bash` and then running `foundryup` on a new terminal. For more context, check the installation instructions in the book: https://book.getfoundry.sh/getting-started/installation.html." | ||
echo "Is Foundry not installed? Consider installing via pnpm install:foundry" >&2 | ||
exit 1 | ||
fi | ||
|
||
VERSION=$(forge --version) | ||
echo "Using foundry version: $VERSION" | ||
# Check VERSIONS_FILE has expected foundry property | ||
if ! jq -e '.foundry' "$VERSIONS_FILE" &> /dev/null; then | ||
echo "'foundry' is missing from $VERSIONS_FILE" >&2 | ||
exit 1 | ||
fi | ||
|
||
# Extract the expected foundry version from versions.json | ||
EXPECTED_VERSION=$(jq -r '.foundry' "$VERSIONS_FILE" | cut -c 1-7) | ||
if [ -z "$EXPECTED_VERSION" ]; then | ||
echo "Unable to extract Foundry version from $VERSIONS_FILE" >&2 | ||
exit 1 | ||
fi | ||
|
||
# Extract the installed forge version | ||
INSTALLED_VERSION=$(forge --version | grep -o '[a-f0-9]\{7\}' | head -n 1) | ||
|
||
# Compare the installed timestamp with the expected timestamp | ||
if [ "$INSTALLED_VERSION" = "$EXPECTED_VERSION" ]; then | ||
echo "Foundry version matches the expected version." | ||
else | ||
echo "Mismatch between installed Foundry version ($INSTALLED_VERSION) and expected version ($EXPECTED_VERSION)." | ||
echo "Your version of Foundry may either not be up to date, or it could be a later version." | ||
echo "Running pnpm update:foundry will install the expected version." | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters