From 895c161c4c04be353937fd29ea87e57b6dd46852 Mon Sep 17 00:00:00 2001 From: Kent Huang Date: Fri, 31 May 2024 14:44:26 +0800 Subject: [PATCH] [Refine] oso codespace for anonymous users Signed-off-by: Kent Huang fix typo Signed-off-by: Kent Huang run recce server in background Signed-off-by: Kent Huang fix launch recce script Signed-off-by: Kent Huang fix launch script Signed-off-by: Kent Huang fix launch script Signed-off-by: Kent Huang --- .devcontainer/launch_recce_server.sh | 12 ++++++++++-- .devcontainer/post_start_command.sh | 2 -- .devcontainer/prepare_dbt_manifest.sh | 5 +++++ .devcontainer/setup_required_env.sh | 3 +-- 4 files changed, 16 insertions(+), 6 deletions(-) diff --git a/.devcontainer/launch_recce_server.sh b/.devcontainer/launch_recce_server.sh index 45e00128d..3a03f7398 100644 --- a/.devcontainer/launch_recce_server.sh +++ b/.devcontainer/launch_recce_server.sh @@ -8,6 +8,14 @@ if [ -f "${DIR}/../recce_state.json" ]; then echo "Launching the Recce server in review mode. The Recce state file is found." recce server --review ${DIR}/../recce_state.json else - echo "Launching the Recce server." - recce server + if [ -f "${DBT_GOOGLE_KEYFILE}" ]; then + echo "Preparing the dbt manifest." + pushd ${DIR}/../ + dbt deps && dbt build && dbt docs generate + popd + echo "Launching the Recce server." + recce server + else + echo "Google cloud service account key is not found. Skip launching the Recce server." + fi fi \ No newline at end of file diff --git a/.devcontainer/post_start_command.sh b/.devcontainer/post_start_command.sh index f60a8b530..f5a0ddbb0 100644 --- a/.devcontainer/post_start_command.sh +++ b/.devcontainer/post_start_command.sh @@ -7,8 +7,6 @@ if [ "${CODESPACES}" == "true" ]; then # Check environment variables bash .devcontainer/setup_required_env.sh - bash .devcontainer/prepare_dbt_manifest.sh - bash .devcontainer/launch_recce_server.sh fi \ No newline at end of file diff --git a/.devcontainer/prepare_dbt_manifest.sh b/.devcontainer/prepare_dbt_manifest.sh index a6fdef01e..0774d9c02 100644 --- a/.devcontainer/prepare_dbt_manifest.sh +++ b/.devcontainer/prepare_dbt_manifest.sh @@ -8,6 +8,11 @@ if [ -f "${DIR}/../recce_state.json" ]; then exit 0 fi +if [ ! -f "${DBT_GOOGLE_KEYFILE}" ]; then + echo "Google cloud service account key is not found. Skip preparing the dbt manifest." + exit 0 +fi + echo "Preparing the dbt manifest." pushd ${DIR}/../ dbt deps && dbt build && dbt docs generate diff --git a/.devcontainer/setup_required_env.sh b/.devcontainer/setup_required_env.sh index e09fde804..25aa83de3 100644 --- a/.devcontainer/setup_required_env.sh +++ b/.devcontainer/setup_required_env.sh @@ -51,8 +51,7 @@ if [ -z "$GOOGLE_CLOUD_SERVICE_ACCOUNT_KEY_CONTENT" ]; then gcloud auth list exit 0 else - echo -e "[${GREEN}Action${ENDCOLOR}] Please login to Google cloud to continue." - gcloud auth application-default login + echo "User is not logged in Google cloud. Won't be able to run dbt commands." fi else # Use the service account key to login