Repository navigation
Add Conductor workspace automation #44
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,46 @@ | ||||||||||||||||||||||||||||
| #!/usr/bin/env bash | ||||||||||||||||||||||||||||
| set -e | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| RED='\033[0;31m' | ||||||||||||||||||||||||||||
| GREEN='\033[0;32m' | ||||||||||||||||||||||||||||
| NC='\033[0m' | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| error() { echo -e "${RED}✗${NC} $1"; exit 1; } | ||||||||||||||||||||||||||||
| success() { echo -e "${GREEN}✓${NC} $1"; } | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| echo "🚀 Setting up Superset workspace..." | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| # Check dependencies | ||||||||||||||||||||||||||||
| command -v bun &> /dev/null || error "Bun not installed. Install from https://bun.sh" | ||||||||||||||||||||||||||||
| command -v neonctl &> /dev/null || error "Neon CLI not installed. Run: npm install -g neonctl" | ||||||||||||||||||||||||||||
| command -v jq &> /dev/null || error "jq not installed. Run: brew install jq" | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| # Install dependencies | ||||||||||||||||||||||||||||
| echo "📥 Installing dependencies..." | ||||||||||||||||||||||||||||
| bun install | ||||||||||||||||||||||||||||
| success "Dependencies installed" | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| # Link direnv config | ||||||||||||||||||||||||||||
| echo "🔧 Linking .envrc..." | ||||||||||||||||||||||||||||
| ln -sf "$CONDUCTOR_ROOT_PATH/.envrc" .envrc | ||||||||||||||||||||||||||||
| success "direnv configured" | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| # Create Neon branch for this workspace | ||||||||||||||||||||||||||||
| echo "🗄️ Creating Neon branch..." | ||||||||||||||||||||||||||||
| WORKSPACE_NAME=$(basename "${CONDUCTOR_WORKSPACE_PATH:-$PWD}") | ||||||||||||||||||||||||||||
| NEON_OUTPUT=$(neonctl branches create \ | ||||||||||||||||||||||||||||
| --project-id tiny-cherry-82420694 \ | ||||||||||||||||||||||||||||
| --name "$WORKSPACE_NAME" \ | ||||||||||||||||||||||||||||
| --output json) | ||||||||||||||||||||||||||||
|
Comment on lines
+32
to
+34
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove hardcoded project-id from the script. Embedding Apply this diff to externalize the project-id: WORKSPACE_NAME=$(basename "${CONDUCTOR_WORKSPACE_PATH:-$PWD}")
-NEON_OUTPUT=$(neonctl branches create \
- --project-id tiny-cherry-82420694 \
+NEON_OUTPUT=$(neonctl branches create \
+ --project-id "${NEON_PROJECT_ID:?Error: NEON_PROJECT_ID not set}" \
--name "$WORKSPACE_NAME" \
--output json)Ensure 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| # Parse connection strings and create .env | ||||||||||||||||||||||||||||
| DATABASE_URL=$(echo "$NEON_OUTPUT" | jq -r '.connection_uris[0].connection_uri') | ||||||||||||||||||||||||||||
| DATABASE_POOLED_URL=$(echo "$NEON_OUTPUT" | jq -r '.connection_uris[1].connection_uri // empty') | ||||||||||||||||||||||||||||
|
Comment on lines
+37
to
+38
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fragile JSON parsing; assume specific Neon API response structure without graceful degradation. The jq filters assume Strengthen the parsing logic and add validation (see previous comment for a full fix). Additionally, verify the jq output: # Debug: Print the Neon output structure before parsing
echo "$NEON_OUTPUT" | jq '.'Confirm that 🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| cat > .env << EOF | ||||||||||||||||||||||||||||
| DATABASE_URL=$DATABASE_URL | ||||||||||||||||||||||||||||
| DATABASE_POOLED_URL=$DATABASE_POOLED_URL | ||||||||||||||||||||||||||||
| EOF | ||||||||||||||||||||||||||||
|
Comment on lines
+40
to
+43
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
If a user has manually edited or created a
Apply this diff to add a safety check: -cat > .env << EOF
+if [[ -f .env ]]; then
+ echo "⚠️ Warning: .env already exists. Backing up to .env.bak"
+ mv .env .env.bak
+fi
+
+cat > .env << EOF
DATABASE_URL=$DATABASE_URL
DATABASE_POOLED_URL=$DATABASE_POOLED_URL
EOF📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| success "Neon branch created: $WORKSPACE_NAME" | ||||||||||||||||||||||||||||
| echo "✨ Done!" | ||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| { | ||
| "scripts": { | ||
| "setup": "./conductor-setup.sh" | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Script is not idempotent; rerunning will attempt duplicate Neon branch creation.
Neon will reject a second
branches createcall with the same--name. Running this setup script twice in the same workspace will fail. Consider:This could be addressed with a check before branch creation:
WORKSPACE_NAME=$(basename "${CONDUCTOR_WORKSPACE_PATH:-$PWD}") + +# Check if branch already exists +if neonctl branches get "$WORKSPACE_NAME" --project-id "${NEON_PROJECT_ID}" &> /dev/null; then + echo "ℹ️ Neon branch already exists: $WORKSPACE_NAME" + NEON_OUTPUT=$(neonctl branches get "$WORKSPACE_NAME" --project-id "${NEON_PROJECT_ID}" --output json) +else + echo "Creating new Neon branch..." NEON_OUTPUT=$(neonctl branches create \ - --project-id tiny-cherry-82420694 \ + --project-id "${NEON_PROJECT_ID:?Error: NEON_PROJECT_ID not set}" \ --name "$WORKSPACE_NAME" \ --output json) +fiVerify that
neonctl branches getandneonctl branches createoutputs are compatible with the downstream JSON parsing.📝 Committable suggestion
🤖 Prompt for AI Agents