|
56 | 56 | cargo pgrx init --pg17 download |
57 | 57 | fi |
58 | 58 |
|
59 | | -# ── Initialize private submodule (duroxide-pg-opt) ────────────────── |
60 | | -# duroxide-pg-opt is a private repo. Two auth mechanisms: |
61 | | -# |
62 | | -# 1. Prebuild phase: GH_PAT Codespace secret provides access. |
63 | | -# We use a temporary git insteadOf rewrite during submodule clone. |
64 | | -# The secret remains available in the Codespace environment, so there |
65 | | -# is no meaningful security benefit to trying to scrub local traces. |
66 | | -# |
67 | | -# 2. Interactive Codespace: devcontainer.json grants the built-in |
68 | | -# GITHUB_TOKEN read access via customizations.codespaces.repositories. |
69 | | -# The Codespace credential helper handles auth automatically. |
70 | | -# |
71 | | -# 3. Local Dev Container: user must have their own credentials. |
72 | | - |
73 | | -SUBMODULE_INITIALIZED=0 |
74 | | - |
75 | | -if [ -n "$GH_PAT" ]; then |
76 | | - echo "GH_PAT detected — initializing submodule with PAT..." |
77 | | - |
78 | | - # Temporarily rewrite GitHub HTTPS URLs to include the token. |
79 | | - PAT_REWRITE_URL="https://x-access-token:${GH_PAT}@github.com/" |
80 | | - |
81 | | - cleanup_pat_rewrite() { |
82 | | - local rc=$? |
83 | | - # GH_PAT is still available in Codespace env vars; cleanup here ensures |
84 | | - # subsequent user git operations prefer devcontainer.json repo permissions |
85 | | - # and Codespaces credential helper instead of forcing PAT rewrite behavior. |
86 | | - git config --global --remove-section "url.${PAT_REWRITE_URL}" 2>/dev/null || true |
87 | | - return $rc |
88 | | - } |
89 | | - |
90 | | - trap cleanup_pat_rewrite EXIT |
91 | | - git config --global url."${PAT_REWRITE_URL}".insteadOf "https://github.com/" |
92 | | - |
93 | | - if [ "$SMOKE_MODE" = "1" ]; then |
94 | | - echo "Smoke mode: skipping git submodule update" |
95 | | - if [ -f "duroxide-pg-opt/Cargo.toml" ]; then |
96 | | - SUBMODULE_INITIALIZED=1 |
97 | | - fi |
98 | | - elif git submodule update --init --recursive; then |
99 | | - echo "✅ Submodule initialized successfully (via PAT)" |
100 | | - SUBMODULE_INITIALIZED=1 |
101 | | - else |
102 | | - echo "⚠️ Submodule initialization failed with PAT" |
103 | | - fi |
104 | | -else |
105 | | - echo "GH_PAT not set — trying submodule init with default credentials..." |
106 | | - if [ "$SMOKE_MODE" = "1" ]; then |
107 | | - echo "Smoke mode: skipping git submodule update" |
108 | | - if [ -f "duroxide-pg-opt/Cargo.toml" ]; then |
109 | | - SUBMODULE_INITIALIZED=1 |
110 | | - fi |
111 | | - elif git submodule update --init --recursive; then |
112 | | - echo "✅ Submodule initialized successfully" |
113 | | - SUBMODULE_INITIALIZED=1 |
114 | | - else |
115 | | - echo "⚠️ Submodule initialization failed — skipping" |
116 | | - echo " Set GH_PAT secret or ensure credentials for microsoft/duroxide-pg-opt" |
117 | | - fi |
118 | | -fi |
119 | | - |
120 | 59 | # ── Build pg_durable ──────────────────────────────────────────────── |
121 | | -# Only build if the submodule is present (needed for compilation) |
122 | | -if [ "$SUBMODULE_INITIALIZED" = "1" ] && [ -f "duroxide-pg-opt/Cargo.toml" ]; then |
123 | | - echo "Building pg_durable..." |
124 | | - if [ "$SMOKE_MODE" = "1" ]; then |
125 | | - echo "Smoke mode: skipping cargo build" |
126 | | - else |
127 | | - cargo build --features pg17,http-allow-test-domains |
128 | | - echo "✅ pg_durable built successfully" |
129 | | - fi |
| 60 | +# duroxide-pg is pulled as a crates.io dependency (see Cargo.toml). |
| 61 | +echo "Building pg_durable..." |
| 62 | +if [ "$SMOKE_MODE" = "1" ]; then |
| 63 | + echo "Smoke mode: skipping cargo build" |
| 64 | +else |
| 65 | + cargo build --features pg17,http-allow-test-domains |
| 66 | + echo "✅ pg_durable built successfully" |
130 | 67 |
|
131 | 68 | echo "Installing pg_durable into PostgreSQL ${PG_MAJOR}..." |
132 | | - if [ "$SMOKE_MODE" = "1" ]; then |
133 | | - echo "Smoke mode: skipping install/cluster bootstrap" |
134 | | - else |
135 | | - resolve_pgrx_environment "$PG_MAJOR" |
136 | | - cargo pgrx install --release --pg-config "$PG_CONFIG" |
| 69 | + resolve_pgrx_environment "$PG_MAJOR" |
| 70 | + cargo pgrx install --release --pg-config "$PG_CONFIG" |
137 | 71 |
|
138 | | - echo "Preparing PostgreSQL ${PG_MAJOR} cluster..." |
139 | | - recreate_local_cluster |
140 | | - start_local_postgres |
141 | | - ensure_compatible_roles |
142 | | - ensure_pg_durable_extension |
| 72 | + echo "Preparing PostgreSQL ${PG_MAJOR} cluster..." |
| 73 | + recreate_local_cluster |
| 74 | + start_local_postgres |
| 75 | + ensure_compatible_roles |
| 76 | + ensure_pg_durable_extension |
143 | 77 |
|
144 | | - VERSION=$(pg_durable_version) |
145 | | - echo "✅ pg_durable ${VERSION} installed and verified" |
| 78 | + VERSION=$(pg_durable_version) |
| 79 | + echo "✅ pg_durable ${VERSION} installed and verified" |
146 | 80 |
|
147 | | - echo "Stopping PostgreSQL ${PG_MAJOR} after prebuild verification..." |
148 | | - stop_local_postgres |
149 | | - fi |
150 | | -else |
151 | | - echo "⚠️ Submodule not available — skipping pg_durable build" |
| 81 | + echo "Stopping PostgreSQL ${PG_MAJOR} after prebuild verification..." |
| 82 | + stop_local_postgres |
152 | 83 | fi |
153 | 84 |
|
154 | 85 | echo "" |
|
0 commit comments