Commit 16a5d617 authored by smartcontracts's avatar smartcontracts Committed by GitHub

maint: clean up primary justfile (#12997)

Various things in the primary justfile weren't particularly
legible, particularly around installing tooling versions. Cleans
up the primary justfile so that everything has comments and the
process for installing tooling is unified.
Co-authored-by: default avatarMatthew Slipper <me@matthewslipper.com>
parent 8a32cbaa
issues: # Checks that TODO comments have corresponding issues.
todo-checker:
./ops/scripts/todo-checker.sh ./ops/scripts/todo-checker.sh
# Runs semgrep on the entire monorepo. # Runs semgrep on the entire monorepo.
...@@ -9,56 +10,94 @@ semgrep: ...@@ -9,56 +10,94 @@ semgrep:
semgrep-test: semgrep-test:
semgrep scan --test --config .semgrep/rules/ .semgrep/tests/ semgrep scan --test --config .semgrep/rules/ .semgrep/tests/
lint-shellcheck: # Runs shellcheck.
shellcheck:
find . -type f -name '*.sh' -not -path '*/node_modules/*' -not -path './packages/contracts-bedrock/lib/*' -not -path './packages/contracts-bedrock/kout*/*' -exec sh -c 'echo "Checking $1"; shellcheck "$1"' _ {} \; find . -type f -name '*.sh' -not -path '*/node_modules/*' -not -path './packages/contracts-bedrock/lib/*' -not -path './packages/contracts-bedrock/kout*/*' -exec sh -c 'echo "Checking $1"; shellcheck "$1"' _ {} \;
########################################################
# DEPENDENCY MANAGEMENT #
########################################################
# Generic task for checking if a tool version is up to date.
check-tool-version tool:
#!/usr/bin/env bash
EXPECTED=$(jq -r .{{tool}} < versions.json)
ACTUAL=$(just print-{{tool}})
if [ "$ACTUAL" = "$EXPECTED" ]; then
echo "✓ {{tool}} versions match"
else
echo "✗ {{tool}} version mismatch (expected $EXPECTED, got $ACTUAL), run 'just install-{{tool}}' to upgrade"
exit 1
fi
# Installs foundry
install-foundry: install-foundry:
curl -L https://foundry.paradigm.xyz | bash && just update-foundry
update-foundry:
bash ./ops/scripts/install-foundry.sh bash ./ops/scripts/install-foundry.sh
# Prints current foundry version.
print-foundry:
forge --version
# Checks if installed foundry version is correct.
check-foundry: check-foundry:
bash ./ops/scripts/check-foundry.sh bash ./ops/scripts/check-foundry.sh
# Installs correct kontrol version.
install-kontrol: install-kontrol:
curl -L https://kframework.org/install | bash && just update-kontrol bash ./ops/scripts/install-kontrol.sh
# Prints current kontrol version.
print-kontrol:
kontrol version
update-kontrol: # Checks if installed kontrol version is correct.
kup install kontrol --version v$(jq -r .kontrol < versions.json) check-kontrol:
just check-tool-version kontrol
# Installs correct abigen version.
install-abigen: install-abigen:
go install github.com/ethereum/go-ethereum/cmd/abigen@$(jq -r .abigen < versions.json) go install github.com/ethereum/go-ethereum/cmd/abigen@$(jq -r .abigen < versions.json)
# Prints current abigen version.
print-abigen: print-abigen:
abigen --version | sed -e 's/[^0-9]/ /g' -e 's/^ *//g' -e 's/ *$//g' -e 's/ /./g' -e 's/^/v/' abigen --version | sed -e 's/[^0-9]/ /g' -e 's/^ *//g' -e 's/ *$//g' -e 's/ /./g' -e 's/^/v/'
# Checks if installed abigen version is correct.
check-abigen: check-abigen:
[[ $(just print-abigen) = $(cat versions.json | jq -r '.abigen') ]] && echo '✓ abigen versions match' || (echo '✗ abigen version mismatch. Run `just upgrade:abigen` to upgrade.' && exit 1) just check-tool-version abigen
upgrade-abigen:
jq '.abigen = $v' --arg v $(just print:abigen) <<<$(cat versions.json) > versions.json
# Installs correct slither version.
install-slither: install-slither:
pip3 install slither-analyzer==$(jq -r .slither < versions.json) pip3 install slither-analyzer==$(jq -r .slither < versions.json)
# Prints current slither version.
print-slither: print-slither:
slither --version slither --version
# Checks if installed slither version is correct.
check-slither: check-slither:
[[ $(just print-slither) = $(jq -r .slither < versions.json) ]] && echo '✓ slither versions match' || (echo '✗ slither version mismatch. Run `just upgrade-slither` to upgrade.' && exit 1) just check-tool-version slither
upgrade-slither:
jq '.slither = $v' --arg v $(just print-slither) <<<$(cat versions.json) > versions.json
# Installs correct semgrep version.
install-semgrep: install-semgrep:
pip3 install semgrep pip3 install semgrep=="$(jq -r .semgrep < versions.json)"
# Prints current semgrep version.
print-semgrep: print-semgrep:
semgrep --version semgrep --version | head -n 1
# Checks if installed semgrep version is correct.
check-semgrep: check-semgrep:
[ "$(just print-semgrep)" = "$(jq -r .semgrep < versions.json)" ] && echo '✓ semgrep versions match' || (echo '✗ semgrep version mismatch. Run `just upgrade-semgrep` to upgrade.' && exit 1) just check-tool-version semgrep
upgrade-semgrep: # Installs correct go version.
pip3 install semgrep=="$(jq -r .semgrep < versions.json)" install-go:
echo "error: go must be installed manually" && exit 1
# Prints current go version.
print-go:
go version | sed -E 's/.*go([0-9]+\.[0-9]+\.[0-9]+).*/\1/'
# Checks if installed go version is correct.
check-go:
just check-tool-version go
...@@ -2,6 +2,12 @@ ...@@ -2,6 +2,12 @@
set -e set -e
# Check if foundryup exists, if not, install it
if ! command -v foundryup &> /dev/null; then
echo "foundryup not found, installing..."
curl -L https://foundry.paradigm.xyz | bash
fi
SCRIPTS_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) SCRIPTS_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
MONOREPO_DIR=$(cd "$SCRIPTS_DIR/../../" && pwd) MONOREPO_DIR=$(cd "$SCRIPTS_DIR/../../" && pwd)
......
#!/bin/bash
set -e
# Check if kup exists, if not, install it
if ! command -v kup &> /dev/null; then
echo "kup not found, installing..."
yes | bash <(curl -L https://kframework.org/install)
fi
SCRIPTS_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
MONOREPO_DIR=$(cd "$SCRIPTS_DIR/../../" && pwd)
# Grab the correct kontrol version.
VERSION=$(jq -r .kontrol < "$MONOREPO_DIR"/versions.json)
kup install kontrol --version v"$VERSION"
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