diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 29001a5..7c7fcca 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,18 +1,18 @@ // For format details, see https://aka.ms/devcontainer.json. { - "name": "Resemble Devcontainer", - "image": "ghcr.io/reboot-dev/resemble-devcontainer", - "remoteUser": "dev", - - // Features to add to the dev container. More info: https://containers.dev/features. - // "features": {} - - // Use 'forwardPorts' to make a list of ports inside the container available locally. - "forwardPorts": [3000, 9991], - - // Uncomment the next line to run commands after the container is created. - // "postCreateCommand": "cat /etc/os-release", - - // Configure tool-specific properties. - // "customizations": {}, - } \ No newline at end of file + "name": "Resemble Devcontainer", + "image": "ghcr.io/reboot-dev/resemble-devcontainer", + "remoteUser": "dev", + + // Features to add to the dev container. More info: https://containers.dev/features. + // "features": {} + + // Use 'forwardPorts' to make a list of ports inside the container available locally. + "forwardPorts": [3000, 9991] + + // Uncomment the next line to run commands after the container is created. + // "postCreateCommand": "cat /etc/os-release", + + // Configure tool-specific properties. + // "customizations": {}, +} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 7441f60..c6e8540 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -41,6 +41,4 @@ jobs: uses: devcontainers/ci@v0.3 with: runCmd: | - pip install -r ./backend/src/requirements.txt - rsm protoc - pytest backend/ + .tests/test.sh diff --git a/.mergequeue/config.yml b/.mergequeue/config.yml index 1e6f909..6c4cfe2 100644 --- a/.mergequeue/config.yml +++ b/.mergequeue/config.yml @@ -29,4 +29,4 @@ merge_rules: override_labels: squash: "" merge: "" - rebase: mergequeue-rebase \ No newline at end of file + rebase: mergequeue-rebase diff --git a/.tests/test.sh b/.tests/test.sh new file mode 100755 index 0000000..adf7e31 --- /dev/null +++ b/.tests/test.sh @@ -0,0 +1,37 @@ +#!/bin/bash + +set -e # Exit if a command exits with an error. +set -u # Treat expanding an unset variable as an error. +set -x # Echo executed commands to help debug failures. + +# Check that this script has been invoked with the right working directory, by +# checking that the expected subdirectories exist. +ls -l api/ backend/src/ web/ 2> /dev/null > /dev/null || { + echo "ERROR: this script must be invoked from the root of the 'resemble-hello-world' repository." + echo "Current working directory is '$(pwd)'." + exit 1 +} + +# Create and activate a virtual environment so that we don't pollute the +# system's Python installation. +python -m venv ./.hello-world-venv +source ./.hello-world-venv/bin/activate + +# Use the published Resemble pip packages by default, but allow the test system +# to override them with a different value. +REBOOT_RESEMBLE_PACKAGE=${REBOOT_RESEMBLE_PACKAGE:-"reboot-resemble"} + +# Manually install the Resemble packages before installing the requirements.txt. +# This allows us to install unreleased versions of the Resemble packages during +# tests; the requirements.txt refers to the released versions, but it will skip +# packages that have already been installed. +pip install $REBOOT_RESEMBLE_PACKAGE + +pip install -r backend/src/requirements.txt + +rsm protoc + +pytest backend/ + +# Clean up +rm -rf ./.hello-world-venv diff --git a/BUILD.bazel b/BUILD.bazel new file mode 100644 index 0000000..02b0186 --- /dev/null +++ b/BUILD.bazel @@ -0,0 +1,16 @@ +# This `BUILD.bazel` file allows a `bazel` system (configured outside of this +# repository) to use code in this directory and its subdirectories. + +filegroup( + name = "everything", + srcs = glob( + ["**/*"], + exclude = [ + # Folders that may be created by activity in this repository, such + # as manually following the steps of the `README.md` file, but which + # are not part of the "source code" of this repository. + ".pytest_cache/**/*", + ], + ), + visibility = ["//visibility:public"], +) diff --git a/backend/src/main.py b/backend/src/main.py index 342c9dc..d596649 100644 --- a/backend/src/main.py +++ b/backend/src/main.py @@ -1,7 +1,7 @@ import asyncio import logging -from hello_world.v1.greeter_rsm import Greeter from greeter_servicer import GreeterServicer +from hello_world.v1.greeter_rsm import Greeter from resemble.aio.applications import Application from resemble.aio.workflows import Workflow diff --git a/backend/src/requirements.txt b/backend/src/requirements.txt index f5b526e..f54c64f 100644 --- a/backend/src/requirements.txt +++ b/backend/src/requirements.txt @@ -1,2 +1,2 @@ -reboot-resemble>=0.0.7 +reboot-resemble>=0.1.0 pytest>=7.4.2 diff --git a/backend/tests/greeter_servicer_test.py b/backend/tests/greeter_servicer_test.py index 2d27606..09c2c41 100644 --- a/backend/tests/greeter_servicer_test.py +++ b/backend/tests/greeter_servicer_test.py @@ -1,6 +1,6 @@ import unittest -from hello_world.v1.greeter_rsm import Greeter, GreetResponse from greeter_servicer import GreeterServicer +from hello_world.v1.greeter_rsm import Greeter, GreetResponse from resemble.aio.tests import Resemble from resemble.aio.workflows import Workflow @@ -28,8 +28,11 @@ async def test_hello_world(self) -> None: await greeter.Greet(workflow, greeting="Hello, Resemble!") await greeter.Greet(workflow, greeting="Hello, Peace of Mind!") response: GreetingsResponse = await greeter.Greetings(workflow) - self.assertEqual(response.greetings, [ - "Hello, World", - "Hello, Resemble!", - "Hello, Peace of Mind!", - ]) + self.assertEqual( + response.greetings, + [ + "Hello, World", + "Hello, Resemble!", + "Hello, Peace of Mind!", + ], + ) diff --git a/web/config-overrides.js b/web/config-overrides.js index 5feab8f..5df075b 100644 --- a/web/config-overrides.js +++ b/web/config-overrides.js @@ -1,16 +1,16 @@ -const { removeModuleScopePlugin, override, babelInclude } = require("customize-cra"); +const { + removeModuleScopePlugin, + override, + babelInclude, +} = require("customize-cra"); const path = require("path"); module.exports = function (config, env) { - - return Object.assign( - config, - override( - removeModuleScopePlugin(), - babelInclude([ - path.resolve('src'), - path.resolve('../api/hello_world/v1'), - ]) - )(config, env) - ) - } + return Object.assign( + config, + override( + removeModuleScopePlugin(), + babelInclude([path.resolve("src"), path.resolve("../api/hello_world/v1")]) + )(config, env) + ); +}; diff --git a/web/src/index.tsx b/web/src/index.tsx index cc38fa4..6e9a156 100644 --- a/web/src/index.tsx +++ b/web/src/index.tsx @@ -7,7 +7,7 @@ import App from "./App"; import reportWebVitals from "./reportWebVitals"; const root = ReactDOM.createRoot( - document.getElementById("root") as HTMLElement, + document.getElementById("root") as HTMLElement ); // Use TLS (via localhost.direct) so we get the advantage of HTTP/2 // multiplexing. @@ -16,7 +16,7 @@ const client = new ResembleClient("https://localhost.direct:9991"); root.render( - , + ); reportWebVitals(); diff --git a/web/tsconfig.json b/web/tsconfig.json index a273b0c..9d379a3 100644 --- a/web/tsconfig.json +++ b/web/tsconfig.json @@ -1,11 +1,7 @@ { "compilerOptions": { "target": "es5", - "lib": [ - "dom", - "dom.iterable", - "esnext" - ], + "lib": ["dom", "dom.iterable", "esnext"], "allowJs": true, "skipLibCheck": true, "esModuleInterop": true, @@ -20,7 +16,5 @@ "noEmit": true, "jsx": "react-jsx" }, - "include": [ - "src" - ] + "include": ["src"] }