Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Release] Synchronize for release #73

Merged
merged 1 commit into from
Dec 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 4 additions & 22 deletions .tests/all_pytests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
Expand Down
46 changes: 13 additions & 33 deletions .tests/readme_test.sh
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

<!-- MARKDOWN-AUTO-DOCS:START (CODE:src=./.tests/readme_test.sh&lines=45-45) -->
<!-- MARKDOWN-AUTO-DOCS:START (CODE:src=./.tests/readme_test.sh&lines=24-24) -->
<!-- The below code snippet is automatically added from ./.tests/readme_test.sh -->
```sh
cd hello-constructors
Expand Down
8 changes: 4 additions & 4 deletions bank/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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)
Expand Down
5 changes: 3 additions & 2 deletions hello-constructors/backend/src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
)
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
[project]
requires-python = ">= 3.10"
dependencies = [
"reboot==0.19.2",
"reboot==0.20.0",
]

[tool.rye]
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
Expand Down
2 changes: 1 addition & 1 deletion requirements-dev.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion requirements.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading