diff --git a/.tests/all_pytests.sh b/.tests/all_pytests.sh index f975a77..913f95b 100755 --- a/.tests/all_pytests.sh +++ b/.tests/all_pytests.sh @@ -8,20 +8,9 @@ all_application_folders=( "hello-tasks" ) -# In case of any errors, this test has failed. Fail immediately. -set -e -# In case of undefined variables, there must be a bug. Fail immediately. -set -u -# Show us the commands we're executing, to aid in debugging. -set -x - -# Check that this script has been invoked with the right working directory, by -# checking that the expected subdirectories exist. -ls -l api/ hello-constructors/backend/src/ 2> /dev/null > /dev/null || { - echo "ERROR: this script must be invoked from the root of the 'reboot-examples' repository." - echo "Current working directory is '$(pwd)'." - exit 1 -} +set -e # Exit if a command exits with an error. +set -u # In case of undefined variables, there must be a bug. Fail immediately. +set -x # Echo executed commands to help debug failures. # Require `REBOOT_WHL_FILE` to have been passed; all tests calling this # file should be explicit about a specific Reboot wheel file they've built. @@ -45,18 +34,11 @@ function runPyTest () { popd } -# Convert symlinks to files that we need to mutate into copies. -for file in "requirements.lock" "requirements-dev.lock" "pyproject.toml"; do - cp "$file" "${file}.tmp" - rm "$file" - mv "${file}.tmp" "$file" -done - # Install the `reboot` package from the specified path explicitly, over- # writing the version from `pyproject.toml`. rye remove --no-sync reboot rye remove --no-sync --dev reboot -rye add --dev reboot --absolute --path=$REBOOT_WHL_FILE +rye add --dev reboot --absolute --path=${SANDBOX_ROOT}$REBOOT_WHL_FILE # Create and activate a virtual environment. rye sync --no-lock diff --git a/.tests/readme_test.sh b/.tests/readme_test.sh index 88b426c..f856f56 100755 --- a/.tests/readme_test.sh +++ b/.tests/readme_test.sh @@ -1,29 +1,11 @@ #!/bin/bash # -# This test mirrors, as closely as possible, the user experience of following -# the `README.md` through its "Test" step. +# This test should fully cover the user experience of following +# the `README.md` through its "Test" step. Because it is not +# interactive, it cannot perfectly match the README.md. -### Preamble: sanity checks and setup not found in the `README.md`. ### - -# In case of any errors, this test has failed. Fail immediately. -set -e -# Show us the commands we're executing, to aid in debugging. -set -x - -# Check that this script has been invoked with the right working directory, by -# checking that the expected subdirectories exist. -ls -l api/ hello-constructors/backend/src/ 2> /dev/null > /dev/null || { - echo "ERROR: this script must be invoked from the root of the 'reboot-examples' repository." - echo "Current working directory is '$(pwd)'." - exit 1 -} - -# Convert symlinks to files that we need to mutate into copies. -for file in "requirements.lock" "requirements-dev.lock" "pyproject.toml"; do - cp "$file" "${file}.tmp" - rm "$file" - mv "${file}.tmp" "$file" -done +set -e # Exit if a command exits with an error. +set -x # Echo executed commands to help debug failures. # Use the published Reboot pip package by default, but allow the test system # to override them with a different value. @@ -32,24 +14,22 @@ if [ -n "$REBOOT_WHL_FILE" ]; then # writing the version from `pyproject.toml`. rye remove --no-sync reboot rye remove --no-sync --dev reboot - rye add --dev reboot --absolute --path=$REBOOT_WHL_FILE + rye add --dev reboot --absolute --path=${SANDBOX_ROOT}$REBOOT_WHL_FILE fi -### Start of the README.md test ### -# From here on we follow the `README.md` instructions verbatim. - # Create and activate a virtual environment. rye sync --no-lock source .venv/bin/activate cd hello-constructors -# Compile protocol buffers. -rbt protoc +# When running in a Bazel test, our `.rbtrc` file ends up in a very deep +# directory structure, which can result in "path too long" errors from RocksDB. +# Explicitly specify a shorter path. +RBT_FLAGS="--state-directory=$(mktemp -d)" + +# Confirm that we can start up. +rbt $RBT_FLAGS dev run --terminate-after-health-check # Test. pytest backend/ - -# Deactivate the virtual environment, since we can run a test which may require -# another virtual environment (currently we do that only in `all_tests.sh`). -deactivate diff --git a/README.md b/README.md index c83152d..8ce9ed0 100644 --- a/README.md +++ b/README.md @@ -76,7 +76,7 @@ way of keeping the options you have to type (and remember!) to a minimum. We provide a different `.rbtrc` for every application in this repository, and by selecting an application directory you select the `.rbtrc` that will be used: - + ```sh cd hello-constructors diff --git a/bank/cli.py b/bank/cli.py index 81b596f..9ebaf78 100755 --- a/bank/cli.py +++ b/bank/cli.py @@ -17,9 +17,9 @@ def configure_parser() -> argparse.ArgumentParser: parser = argparse.ArgumentParser() parser.add_argument( - "--gateway_address", + "--application_api_url", type=str, - default="localhost:9991", + default="http://localhost:9991", ) parser.add_argument( "--bank_id", @@ -91,10 +91,10 @@ def configure_parser() -> argparse.ArgumentParser: return parser -async def run_action(args: argparse.Namespace) -> int: +async def run_action(args: argparse.Namespace) -> None: context = ExternalContext( name=f"bank-cli-action-{str(uuid.uuid4())}", - gateway=args.gateway_address, + url=args.application_api_url, ) bank = Bank.lookup(args.bank_id) diff --git a/hello-constructors/backend/src/main.py b/hello-constructors/backend/src/main.py index dd4c86c..14c339c 100644 --- a/hello-constructors/backend/src/main.py +++ b/hello-constructors/backend/src/main.py @@ -12,8 +12,9 @@ async def initialize(context: ExternalContext): # Explicitly create the state machine. - hello, _ = await Hello.construct().idempotently().Create( - EXAMPLE_STATE_MACHINE_ID, + hello, _ = await Hello.construct( + id=EXAMPLE_STATE_MACHINE_ID + ).idempotently().Create( context, initial_message="Welcome! This message was sent by a constructor.", ) diff --git a/pyproject.toml b/pyproject.toml index a8264ca..b8f681a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,7 @@ [project] requires-python = ">= 3.10" dependencies = [ - "reboot==0.19.2", + "reboot==0.20.0", ] [tool.rye] @@ -9,7 +9,7 @@ dev-dependencies = [ "mypy==1.2.0", "pytest>=7.4.2", "types-protobuf>=4.24.0.20240129", - "reboot==0.19.2", + "reboot==0.20.0", ] # This project only uses `rye` to provide `python` and its dependencies, so diff --git a/requirements-dev.lock b/requirements-dev.lock index 410c374..7e6696b 100644 --- a/requirements-dev.lock +++ b/requirements-dev.lock @@ -139,7 +139,7 @@ python-dateutil==2.9.0.post0 pyyaml==6.0.2 # via kubernetes-asyncio # via reboot -reboot==0.19.2 +reboot==0.20.0 setuptools==75.1.0 # via grpcio-tools six==1.16.0 diff --git a/requirements.lock b/requirements.lock index 303443b..a4ec78b 100644 --- a/requirements.lock +++ b/requirements.lock @@ -128,7 +128,7 @@ python-dateutil==2.9.0.post0 pyyaml==6.0.2 # via kubernetes-asyncio # via reboot -reboot==0.19.2 +reboot==0.20.0 setuptools==75.1.0 # via grpcio-tools six==1.16.0