@@ -128,28 +128,13 @@ jobs:
128
128
name : " test-results-node-${{ matrix.node-version }}-pg-${{ matrix.pg-version }}"
129
129
path : ' src/packages/*/junit.xml'
130
130
131
- - name : Create CI admin user and API key
132
- run : |
133
- cd src/packages/hub
134
- node run/test-create-admin.js > ../../api_key.txt
135
- # Validate API key was created
136
- if [ ! -s ../../api_key.txt ]; then
137
- echo "Error: API key file is empty or missing"
138
- exit 1
139
- fi
140
- API_KEY=$(cat ../../api_key.txt)
141
- if ! echo "$API_KEY" | grep -qE '^sk-[A-Za-z0-9]+$'; then
142
- echo "Error: Invalid API key format: $API_KEY"
143
- exit 1
144
- fi
145
- echo "API key created successfully"
146
- env :
147
- PGDATABASE : smc
148
- PGUSER : smc
149
- PGHOST : localhost
150
-
151
131
- name : Start CoCalc Hub
152
132
run : |
133
+ # Create conat password for hub internal authentication
134
+ mkdir -p src/data/secrets
135
+ echo "test-conat-password-$(date +%s)" > src/data/secrets/conat-password
136
+ chmod 600 src/data/secrets/conat-password
137
+
153
138
cd src/packages/hub
154
139
pnpm run hub-project-dev-nobuild > hub.log 2>&1 &
155
140
HUB_PID=$!
@@ -168,13 +153,14 @@ jobs:
168
153
PGUSER : smc
169
154
PGHOST : localhost
170
155
COCALC_MODE : single-user
156
+ COCALC_TEST_MODE : yes
171
157
172
158
- name : Wait for hub readiness
173
159
run : |
174
160
MAX_ATTEMPTS=30
175
161
READY=false
176
162
for i in $(seq 1 $MAX_ATTEMPTS); do
177
- if curl -f --max-time 3 http://localhost:5000/healthcheck; then
163
+ if curl -sf --max-time 3 http://localhost:5000/healthcheck > /dev/null ; then
178
164
echo "Hub is ready"
179
165
READY=true
180
166
break
@@ -189,9 +175,54 @@ jobs:
189
175
exit 1
190
176
fi
191
177
178
+ - name : Create CI admin user and API key
179
+ run : |
180
+ cd src/packages/hub
181
+ node dist/run/test-create-admin.js > ../../api_key.txt
182
+ echo "Contents of api_key.txt:"
183
+ cat ../../api_key.txt
184
+ echo ""
185
+ # Validate API key was created
186
+ if [ ! -s ../../api_key.txt ]; then
187
+ echo "Error: API key file is empty or missing"
188
+ exit 1
189
+ fi
190
+ API_KEY=$(cat ../../api_key.txt)
191
+ if ! echo "$API_KEY" | grep -qE '^sk-[A-Za-z0-9]+$'; then
192
+ echo "Error: Invalid API key format: $API_KEY"
193
+ exit 1
194
+ fi
195
+ echo "API key created successfully"
196
+ env :
197
+ PGDATABASE : smc
198
+ PGUSER : smc
199
+ PGHOST : localhost
200
+
192
201
- name : Install uv for cocalc-api tests
193
202
run : curl -LsSf https://astral.sh/uv/install.sh | sh && echo "$HOME/.local/bin" >> $GITHUB_PATH
194
203
204
+ - name : Verify API endpoint is responding
205
+ run : |
206
+ API_KEY=$(cat src/api_key.txt)
207
+ echo "Testing API endpoint with system.ping..."
208
+ MAX_ATTEMPTS=30
209
+ for i in $(seq 1 $MAX_ATTEMPTS); do
210
+ if curl -sf --max-time 5 -u "$API_KEY:" -H 'Content-Type: application/json' \
211
+ -d '{"name":"system.ping", "args":[]}' \
212
+ http://localhost:5000/api/conat/hub > /dev/null; then
213
+ echo "API endpoint is responding"
214
+ break
215
+ fi
216
+ if [ $i -eq $MAX_ATTEMPTS ]; then
217
+ echo "API endpoint failed to respond after $MAX_ATTEMPTS attempts"
218
+ echo "Hub log tail:"
219
+ tail -100 src/packages/hub/hub.log || echo "No log file found"
220
+ exit 1
221
+ fi
222
+ echo "Waiting for API endpoint... ($i/$MAX_ATTEMPTS)"
223
+ sleep 3
224
+ done
225
+
195
226
- name : Run cocalc-api tests
196
227
run : |
197
228
export COCALC_API_KEY=$(cat src/api_key.txt)
0 commit comments