fix(workspace): make teardown script resilient to missing deps and env vars#1395
Conversation
…v vars Source root .env via SUPERSET_ROOT_PATH (like setup does) so NEON_PROJECT_ID is available. Degrade gracefully when neonctl or docker are missing — skip steps with warnings instead of hard-failing. Closes superset-sh#1394
📝 WalkthroughWalkthroughUpdated Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant TeardownScript as Teardown
participant EnvFiles as Env
participant Docker
participant NeonCtl as neonctl
participant Summary
User->>Teardown: run .superset/teardown.sh
Teardown->>Env: source $SUPERSET_ROOT_PATH/.env then .env (fallback)
Env-->>Teardown: env variables (or warning if none)
Teardown->>Teardown: check dependencies (emit warnings, do not fail)
Teardown->>Docker: attempt stop container
alt Docker available
Docker-->>Teardown: stopped
else Docker missing/unavailable
Docker-->>Teardown: warning / skip
end
Teardown->>NeonCtl: pre-check neonctl binary
alt neonctl available and NEON vars present
NeonCtl-->>Teardown: delete branch (or warn if not found)
else neonctl missing or NEON vars absent
NeonCtl-->>Teardown: warning / skip
end
Teardown->>Summary: append warnings/skips and finish (exit 0)
Summary-->>User: final teardown summary (warnings, skipped steps)
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
No actionable comments were generated in the recent review. 🎉 🧹 Recent nitpick comments
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Fix all issues with AI agents
In @.superset/teardown.sh:
- Around line 140-143: The checks that bail out when prerequisites are missing
should mark the step as skipped before returning: in the block that checks for
neonctl (the if ! command -v neonctl ...), and in the checks for NEON_PROJECT_ID
and NEON_BRANCH_ID, call step_skipped "neon (reason)" (or similar descriptive
text) immediately before return 0 so the summary records the skip; apply the
same change in step_stop_electric where Docker is missing (call step_skipped
"electric (docker missing)" then return 0). Ensure you use the exact
step_skipped function and provide a concise reason string for each early-exit
path.
- Around line 75-78: The current check only tests if SUPERSET_ROOT_PATH is empty
and never verifies that $SUPERSET_ROOT_PATH/.env actually exists before claiming
"Environment variables loaded"; update the logic in the script to track whether
any .env was sourced: explicitly test for the existence of
"$SUPERSET_ROOT_PATH/.env" when SUPERSET_ROOT_PATH is non-empty and source it if
present, otherwise fall back to sourcing the local ".env" if it exists, and if
neither file was sourced call error and return 1 (keep the existing error and
return behavior). Ensure the script sets or checks a boolean/flag (e.g.,
sourced_any) so the final "Environment variables loaded" message is only printed
when at least one .env file was successfully sourced.
… in summary Use sourced_any flag so teardown only reports success when at least one .env was actually sourced. Call step_skipped with a reason string on every early-exit path so the summary shows exactly what was skipped.
Keep resilient env loading (SUPERSET_ROOT_PATH + local .env with tracking flag) and skip-tracking for missing NEON_BRANCH_ID over simpler main versions.
Instead of erroring out, warn and fall back to existing environment variables when neither SUPERSET_ROOT_PATH/.env nor local .env exists. Track as a skipped step in the teardown summary.
Summary
.envviaSUPERSET_ROOT_PATH(like setup does) soNEON_PROJECT_IDis available during teardownneonctlordockerare missing — skip steps with warnings instead of hard-failingCloses #1394
Test plan
neonctlinstalled — should warn and skip Neon branch deletion instead of failingNEON_PROJECT_IDin local.envbut with it in root.env— should load it from rootSummary by CodeRabbit