-
Notifications
You must be signed in to change notification settings - Fork 310
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: modular CLI +
aztec test
(#7426)
Refactors the CLI package to work as a collection of dynamically importable commands in *actual* CLI programs, such as `aztec`. Right now this doesn't add that much value besides avoiding code repetition between builder and CLI, but tidies up the packages and makes it so much easier to build different utilities by mix and matching different commands. This is going to be very useful when we strip the `aztec` binary of some internal commands, and even more so when we start building the infamous CLI wallet (which will certainly pull some of these commands in) Besides that, it cleans up the sandbox so that no redundant `aztecprotocol/cli` image is pulled, and some of the commands are greatly simplified. The sandbox now does: `aztec`: All the previous commands + all the old CLI ones without having to prefix them with `cli` `aztec-nargo`: Same as always REMOVED: `aztec-sandbox` and `aztec sandbox`: now `aztec start --sandbox` `aztec-builder`: now `aztec codegen` + `aztec update` ADDED: `aztec test`: runs `aztec start --txe`&& `aztec-nargo test --use-legacy --oracle-resolver http://aztec:8081 --silence-warnings` via `docker-compose` allowing users to easily run contract tests using TXE ![image](https://github.com/user-attachments/assets/d77dbc5c-5415-434a-92d6-6a1d3037f15a)
- Loading branch information
Showing
96 changed files
with
1,213 additions
and
1,606 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,39 @@ | ||
#!/usr/bin/env bash | ||
set -euo pipefail | ||
|
||
# Call cli image if used with `aztec cli ...args` | ||
if [ -n "${1-}" ] && [ "$1" != "--help" ]; then | ||
if [ "$1" == "cli" ]; then | ||
shift | ||
SKIP_PORT_ASSIGNMENT=1 $(dirname $0)/.aztec-run aztecprotocol/cli "$@" | ||
elif [ "$1" == "sandbox" ]; then | ||
$(dirname $0)/aztec-sandbox | ||
else | ||
$(dirname $0)/.aztec-run aztecprotocol/aztec "$@" | ||
fi | ||
else | ||
# TODO - display help message | ||
echo | ||
echo "Using 'aztec' CLI:" | ||
echo " aztec start <args> - Start aztec infrastructure components. See 'aztec start --help' for detailed command info." | ||
echo " aztec sandbox - Run a local sandbox network (same as aztec-sandbox)." | ||
echo " aztec cli <args> - Run the aztec client CLI. See 'aztec cli --help' for detailed command info." | ||
function get_compose { | ||
# Favour 'docker compose', falling back on docker-compose. | ||
CMD="docker compose" | ||
$CMD &>/dev/null || CMD="docker-compose" | ||
$CMD $@ | ||
} | ||
|
||
CALLED_FROM=$PWD | ||
|
||
if [ "${1:-}" == "test" ]; then | ||
# Change working dir, so relative volume mounts are in the right place. | ||
cd $(dirname $0)/.. | ||
# Compose file to use | ||
FILE_ARG="-f $HOME/.aztec/docker-compose.test.yml" | ||
# Aztec contract test args for nargo | ||
TEST_ARGS="$@ --silence-warnings --use-legacy --oracle-resolver http://aztec:8081" | ||
get_compose -p aztec-test $FILE_ARG run -e NARGO_FOREIGN_CALL_TIMEOUT=300000 --workdir $CALLED_FROM --rm -it aztec-nargo $TEST_ARGS | ||
elif [ $# == 2 ] && [ "$1" == "start" ] && [ "$2" == "--sandbox" ]; then | ||
# Change working dir, so relative volume mounts are in the right place. | ||
cd $(dirname $0)/.. | ||
# Compose file to use | ||
FILE_ARG="-f $HOME/.aztec/docker-compose.sandbox.yml" | ||
|
||
# Function to be executed when SIGINT is received. | ||
cleanup() { | ||
get_compose $FILE_ARG down | ||
} | ||
|
||
# Set trap to catch SIGINT and call the cleanup function. | ||
trap cleanup SIGINT | ||
|
||
get_compose -p sandbox $FILE_ARG up --force-recreate --remove-orphans | ||
else | ||
$(dirname $0)/.aztec-run aztecprotocol/aztec "$@" | ||
fi | ||
|
This file was deleted.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
services: | ||
aztec: | ||
image: "aztecprotocol/aztec" | ||
environment: | ||
DEBUG: # Loaded from the user shell if explicitly set | ||
HOST_WORKDIR: "${PWD}" # Loaded from the user shell to show log files absolute path in host | ||
volumes: | ||
- ./log:/usr/src/yarn-project/aztec/log:rw | ||
command: start --txe | ||
|
||
aztec-nargo: | ||
image: "aztecprotocol/aztec-nargo" | ||
environment: | ||
HOME: # Loaded from the user shell | ||
NARGO_FOREIGN_CALL_TIMEOUT: 300000 # To avoid timeouts when many tests run at once | ||
volumes: | ||
- ${HOME}:${HOME} | ||
depends_on: | ||
- aztec |
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
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
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
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
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
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
Empty file.
Oops, something went wrong.