Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ae6a591f9c | ||
|
|
9ef38dc087 | ||
|
|
bef7f1ff72 |
No files matched your search
@@ -0,0 +1,82 @@
|
|||||||
|
name: Backend test probe
|
||||||
|
|
||||||
|
# Temporary: runs every backend test:all profile in the exact CI environment of
|
||||||
|
# docker.yml/backend-test without publishing images. Removed after CI is fixed.
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- ci/backend-test-fix
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
backend-test:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Setup Node 22
|
||||||
|
uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: 22
|
||||||
|
|
||||||
|
- name: Start PostgreSQL 18
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
NAME="mm-pg-${{ gitea.run_id }}-${{ gitea.run_attempt }}"
|
||||||
|
docker rm -f "$NAME" 2>/dev/null || true
|
||||||
|
# Docker-backed Gitea runners execute this step in a separate container.
|
||||||
|
# Join its network; a published host loopback port is not reachable here.
|
||||||
|
NETWORKS=$(docker inspect --format '{{range $name, $network := .NetworkSettings.Networks}}{{println $name}}{{end}}' "$(cat /etc/hostname)" 2>/dev/null || true)
|
||||||
|
if [ -n "$NETWORKS" ]; then
|
||||||
|
test "$(printf '%s\n' "$NETWORKS" | wc -l)" -eq 1
|
||||||
|
NETWORK_ARGS=(--network "$NETWORKS" --network-alias "$NAME")
|
||||||
|
PG_HOST="$NAME"
|
||||||
|
PG_PORT=5432
|
||||||
|
else
|
||||||
|
# Host-based runners can use a Docker-assigned ephemeral host port.
|
||||||
|
NETWORK_ARGS=(-p 127.0.0.1::5432)
|
||||||
|
PG_HOST=127.0.0.1
|
||||||
|
fi
|
||||||
|
docker run -d --name "$NAME" --rm \
|
||||||
|
-e POSTGRES_USER=mmapp \
|
||||||
|
-e POSTGRES_PASSWORD=mmapp \
|
||||||
|
-e POSTGRES_DB=mmapp \
|
||||||
|
"${NETWORK_ARGS[@]}" \
|
||||||
|
postgres:18-alpine
|
||||||
|
echo "PG_CONTAINER=$NAME" >> "${GITHUB_ENV}"
|
||||||
|
if [ "$PG_HOST" = 127.0.0.1 ]; then
|
||||||
|
PG_PORT=$(docker port "$NAME" 5432/tcp | awk -F: '{print $NF}')
|
||||||
|
fi
|
||||||
|
echo "DATABASE_URL=postgres://mmapp:mmapp@${PG_HOST}:${PG_PORT}/mmapp" >> "${GITHUB_ENV}"
|
||||||
|
for i in $(seq 1 40); do
|
||||||
|
if docker exec "$NAME" pg_isready -U mmapp -d mmapp; then
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
sleep 1
|
||||||
|
done
|
||||||
|
echo "PostgreSQL не поднялся"
|
||||||
|
docker logs "$NAME" || true
|
||||||
|
exit 1
|
||||||
|
|
||||||
|
- name: Install and test backend (all profiles)
|
||||||
|
shell: bash
|
||||||
|
env:
|
||||||
|
REQUIRE_TEST_POSTGRES: "1"
|
||||||
|
run: |
|
||||||
|
set -uo pipefail
|
||||||
|
npm ci
|
||||||
|
cd backend
|
||||||
|
failed=""
|
||||||
|
for profile in $(node -e "console.log(require('./package.json').scripts['test:all'].split(/\s*&&\s*/).map(c => c.replace('npm run ', '')).join(' '))"); do
|
||||||
|
echo "PROFILE START $profile"
|
||||||
|
if NODE_ENV=test npm run "$profile"; then echo "PROFILE PASS $profile"; else echo "PROFILE FAIL $profile"; failed="$failed $profile"; fi
|
||||||
|
done
|
||||||
|
echo "FAILED PROFILES:${failed:- none}"
|
||||||
|
test -z "$failed"
|
||||||
|
|
||||||
|
- name: Stop PostgreSQL
|
||||||
|
if: always()
|
||||||
|
shell: bash
|
||||||
|
run: docker rm -f "${PG_CONTAINER:-}" 2>/dev/null || true
|
||||||
|
|
||||||
@@ -394,7 +394,7 @@ try {
|
|||||||
DATABASE_URL: `postgresql://mcp_test:${password}@127.0.0.1:${port}/${database}`,
|
DATABASE_URL: `postgresql://mcp_test:${password}@127.0.0.1:${port}/${database}`,
|
||||||
DATABASE_PATH: join(directory, 'no-legacy-database.sqlite'), SQLITE_IMPORT_FULL_HISTORY: 'false',
|
DATABASE_PATH: join(directory, 'no-legacy-database.sqlite'), SQLITE_IMPORT_FULL_HISTORY: 'false',
|
||||||
MMAPP_OWN_SQL_DB: database, MCP_STATE_DIR: join(directory, 'regression-state'),
|
MMAPP_OWN_SQL_DB: database, MCP_STATE_DIR: join(directory, 'regression-state'),
|
||||||
REQUIRE_TEST_POSTGRES: '1',
|
REQUIRE_TEST_POSTGRES: '1', MMAPP_OWN_REGRESSION: '1',
|
||||||
LOGS_PERFORMANCE: process.argv.includes('--performance') ? '1' : '0',
|
LOGS_PERFORMANCE: process.argv.includes('--performance') ? '1' : '0',
|
||||||
AUTH_REQUIRED: 'false', NODE_ENV: 'test' },
|
AUTH_REQUIRED: 'false', NODE_ENV: 'test' },
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -90,7 +90,8 @@ try {
|
|||||||
finally { if (ownedIds.length) await pool.query("DELETE FROM servers WHERE id=ANY($1::bigint[])", [ownedIds]) }
|
finally { if (ownedIds.length) await pool.query("DELETE FROM servers WHERE id=ANY($1::bigint[])", [ownedIds]) }
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
assert.notEqual(process.env.REQUIRE_TEST_POSTGRES, "1", "Owned SQL/disabled API checks are mandatory in PostgreSQL regression")
|
// Only the owned regression (test-mcp-postgres.mjs) must run them; CI has PostgreSQL but no owned database.
|
||||||
|
assert.notEqual(process.env.MMAPP_OWN_REGRESSION, "1", "Owned SQL/disabled API checks are mandatory in the owned PostgreSQL regression")
|
||||||
console.log("network-disabled-server.test.ts: invalid IDs passed; optional SQL checks need an explicit owned database")
|
console.log("network-disabled-server.test.ts: invalid IDs passed; optional SQL checks need an explicit owned database")
|
||||||
}
|
}
|
||||||
} finally { await closePool() }
|
} finally { await closePool() }
|
||||||
Reference in new issue
Block a user