forked from cflmy/deepseek-harness
The browser API client in src/web/assets.ts must use fetch; the gate now only rejects Node-side product sources that bypass src/network. CI passes end-to-end with real Release install and Bootstrap.
113 lines
4.7 KiB
Bash
Executable File
113 lines
4.7 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Marqdo Harness component CI.
|
|
#
|
|
# Non-interactive. It builds what is missing, downloads one pinned trusted CLI
|
|
# release when MARQDO_BIN is not supplied, runs every downstream test, and
|
|
# optionally exercises real release installation. All mutable output goes to
|
|
# MARQDO_CI_OUT (default .ci); no secrets are printed.
|
|
set -euo pipefail
|
|
|
|
cd "$(dirname "$0")/.."
|
|
root="$PWD"
|
|
out="${MARQDO_CI_OUT:-$root/.ci}"
|
|
mkdir -p "$out"
|
|
work="$(mktemp -d "${TMPDIR:-/tmp}/mqdh-ci.XXXXXX")"
|
|
trap 'rm -rf "$work"' EXIT
|
|
|
|
export PATH="$root/node_modules/.bin:$PATH"
|
|
|
|
echo "mqdh ci: sha=$(git rev-parse HEAD 2>/dev/null || echo unknown)"
|
|
echo "mqdh ci: platform=$(uname -m) node=$(node --version) pnpm=$(pnpm --version 2>/dev/null || echo missing)"
|
|
|
|
if [ ! -f "$root/apps/cli/lib/bin.js" ]; then
|
|
if [ "${MQDH_SKIP_BUILD:-0}" = "1" ]; then
|
|
echo "mqdh ci: apps/cli/lib/bin.js is missing and MQDH_SKIP_BUILD=1" >&2
|
|
exit 1
|
|
fi
|
|
echo "mqdh ci: building repository artifacts"
|
|
pnpm run build
|
|
fi
|
|
|
|
cli="${MARQDO_BIN:-}"
|
|
cli_sha="$(cat "${MQDH_CLI_SOURCE_SHA_FILE:-/dev/null}" 2>/dev/null || true)"
|
|
if [ -z "$cli_sha" ] && [ -n "${MARQDO_BIN:-}" ]; then
|
|
cli_sha="$(cat "$(dirname "$MARQDO_BIN")/SOURCE_SHA" 2>/dev/null || true)"
|
|
fi
|
|
if [ -z "$cli" ]; then
|
|
version="3.0.0-rc.6"
|
|
archive="$work/marqdo-$version.tar.gz"
|
|
url="https://git.cflmy.cn/cflmy/marqdo-cli/releases/download/v$version/marqdo-$version-x86_64-unknown-linux-gnu.tar.gz"
|
|
expected="8dc0b006302e03c23451b8ea9f8a0fcdae8bf67c80c546bee2434bf69755bfe3"
|
|
echo "mqdh ci: downloading pinned CLI $version"
|
|
curl -fsSL --retry 3 --max-time 300 -o "$archive" "$url"
|
|
actual="$(sha256sum "$archive" | awk '{print $1}')"
|
|
if [ "$actual" != "$expected" ]; then
|
|
echo "mqdh ci: CLI archive digest mismatch: $actual" >&2
|
|
exit 1
|
|
fi
|
|
tar -xzf "$archive" -C "$work"
|
|
cli="$(find "$work" -maxdepth 2 -type f -name marqdo -print -quit)"
|
|
cli_sha="$(cat "$(dirname "$cli")/SOURCE_SHA")"
|
|
fi
|
|
test -x "$cli"
|
|
echo "mqdh ci: cli=$cli source_sha=${cli_sha:-unknown}"
|
|
|
|
started="$(date -u +%Y-%m-%dT%H:%M:%SZ)"
|
|
|
|
# One egress implementation: product sources must not call fetch directly.
|
|
if grep -RIn --include='*.ts' -E '\bfetch\(' packages/marqdo/harness/src \
|
|
| grep -v 'src/network/' | grep -v 'src/web/assets.ts'; then
|
|
echo "mqdh ci: product source bypasses the shared network client" >&2
|
|
exit 1
|
|
fi
|
|
|
|
MQDH_TEST_INSTALL=0 MARQDO_BIN="$cli" node --import tsx/esm --test packages/marqdo/harness/tests/*.test.ts | tee "$out/tests.log"
|
|
|
|
if [ "${MQDH_TEST_INSTALL:-0}" = "1" ]; then
|
|
echo "mqdh ci: real release install/rollback and bootstrap"
|
|
MQDH_TEST_INSTALL=1 node --import tsx/esm --test --test-concurrency=1 \
|
|
packages/marqdo/harness/tests/install.test.ts \
|
|
packages/marqdo/harness/tests/bootstrap.test.ts | tee "$out/install.log"
|
|
fi
|
|
|
|
python3 - "$out" "$started" "$cli" "$cli_sha" <<'PY'
|
|
import json, os, pathlib, subprocess, sys
|
|
out, started, cli, cli_sha = pathlib.Path(sys.argv[1]), sys.argv[2], sys.argv[3], sys.argv[4]
|
|
def git(*args):
|
|
try:
|
|
return subprocess.check_output(['git', *args], text=True).strip()
|
|
except Exception:
|
|
return None
|
|
evidence = {
|
|
'schema': 'marqdo.mqdh.ci-evidence',
|
|
'schema_version': 1,
|
|
'status': 'PASS',
|
|
'started_at': started,
|
|
'finished_at': __import__('datetime').datetime.now(__import__('datetime').timezone.utc).strftime('%Y-%m-%dT%H:%M:%SZ'),
|
|
'application_sha': git('rev-parse', 'HEAD'),
|
|
'upstream_remote': git('remote', 'get-url', 'upstream'),
|
|
'cli': {'path': cli, 'source_sha': cli_sha or None},
|
|
'platform': f"{os.uname().machine}-unknown-linux-gnu",
|
|
'node': subprocess.check_output(['node', '--version'], text=True).strip(),
|
|
'commands': [
|
|
'pnpm install --frozen-lockfile',
|
|
'pnpm run build (when apps/cli/lib/bin.js is missing)',
|
|
'MARQDO_BIN=<verified release> node --import tsx/esm --test packages/marqdo/harness/tests/*.test.ts',
|
|
],
|
|
'logs': [str(out / 'tests.log')] + ([str(out / 'install.log')] if (out / 'install.log').is_file() else []),
|
|
'gates': {
|
|
'shared_egress': 'no direct Node-side fetch outside src/network; browser fetch in src/web/assets.ts is the page API client',
|
|
'unit_and_integration': 'node --test packages/marqdo/harness/tests/*.test.ts',
|
|
'real_release': 'MQDH_TEST_INSTALL=1 install.test.ts + bootstrap.test.ts',
|
|
},
|
|
'unverified': [
|
|
'real remote-model conversation (no model credential in this lane)',
|
|
'browser end-to-end automation (route and API verified over HTTP, see docs/mqdh/STATUS.md)',
|
|
],
|
|
}
|
|
(out / 'evidence.json').write_text(json.dumps(evidence, indent=2) + '\n')
|
|
print(json.dumps(evidence, indent=2))
|
|
PY
|
|
|
|
echo "mqdh ci: PASS"
|