The Beam Playground is a web application to run Beam code snippets in a modern browser. This directory holds code to build, test, and deploy the frontend and backend services.
The following requirements are needed for development, testing, and deploying.
cd beam ./gradlew playgroundPrecommit
cd beam ./gradlew playground:tasks
cd beam ./gradlew playground:generateProto
Start:
cd beam ./gradlew playground:backend:containers:router:dockerComposeLocalUp
Stop:
cd beam ./gradlew playground:backend:containers:router:dockerComposeLocalDown
/playground/frontend/lib/config.g.dart
to set your local backend host and ports found in /playground/docker-compose.local.yaml
.cd beam ./gradlew playground:dockerComposeLocalUp
cd beam ./gradlew playground:dockerComposeLocalDown
If you do not need particular runners, comment out:
/playground/build.gradle.kts
in dockerComposeLocalUp
task./playground/docker-compose.local.yaml
.Run the method to remove unused code snippets from the Cloud Datastore. Unused snippets are snippets that are out of date. If the last visited date property less or equals than the current date minus dayDiff parameter then a snippet is out of date
cd beam ./gradlew playground:backend:removeUnusedSnippet -DdayDiff={int} -DprojectId={string}
cd beam ./gradlew playground:backend:testWithoutCache
See terraform for details on how to build and deploy the application and its dependent infrastructure.
The following requirements are needed for deploying examples manually:
Example deployment scripts uses following environment variables:
usage: ci_cd.py [-h] --step {CI,CD} [--namespace NAMESPACE] --datastore-project DATASTORE_PROJECT --sdk {SDK_JAVA,SDK_GO,SDK_PYTHON,SDK_SCIO} --origin {PG_EXAMPLES,TB_EXAMPLES} --subdirs SUBDIRS [SUBDIRS ...] CI/CD Steps for Playground objects optional arguments: -h, --help show this help message and exit --step {CI,CD} CI step to verify all beam examples/tests/katas. CD step to save all beam examples/tests/katas and their outputs on the GCD --namespace NAMESPACE Datastore namespace to use when saving data (default: Playground) --datastore-project DATASTORE_PROJECT Datastore project to use when saving data --sdk {SDK_JAVA,SDK_GO,SDK_PYTHON,SDK_SCIO} Supported SDKs --origin {PG_EXAMPLES,TB_EXAMPLES} ORIGIN field of pg_examples/pg_snippets --subdirs SUBDIRS [SUBDIRS ...] limit sub directories to walk through, relative to BEAM_ROOT_DIR
Helper script to deploy examples for all supported sdk's:
cd playground/infrastructure export BEAM_ROOT_DIR="../../" export SDK_CONFIG="../../playground/sdks.yaml" export BEAM_EXAMPLE_CATEGORIES="../categories.yaml" export BEAM_USE_WEBGRPC=yes export BEAM_CONCURRENCY=4 export PLAYGROUND_DNS_NAME="your registered dns name for Playground" for sdk in go java python scio; do export SDK=$sdk && export SERVER_ADDRESS=https://${SDK}.$PLAYGROUND_DNS_NAME && python3 ci_cd.py --datastore-project $GOOGLE_CLOUD_PROJECT \ --step CD --sdk SDK_${SDK^^} \ --origin PG_EXAMPLES \ --subdirs ./learning/katas ./examples ./sdks done