forked from cflmy/deepseek-harness
Implement the downstream product in `packages/marqdo`: - `@marqdo/mdh-harness`: application home layout, atomic writes, locks, bounded fixed-argv processes, safe tar extraction, Observation 1 and ValueWire validation; - trusted Gitea release discovery, SHA-256/platform/Bundle verification, transactional environment install, rollback and cleanup, CLI Tool changes; - private knowledge collections with strict import policy, the official `marqdo-knowledge` compile/query adapter and a disclosed locator fallback; - Analysis 3 parsing, approved run/call execution, evidence and staleness; - the six model operations (find/read/check/program/ecosystem/knowledge_search); - the `/mdh` workbench over the existing web server with a same-origin fence; - `mdh` launcher, CI/package/upstream scripts and a Woodpecker pipeline. Tests: 28 node:test cases (27 PASS, one network-gated install test also PASS with MDH_TEST_INSTALL=1). Product install/workbench evidence is recorded in docs/mdh/evidence. Part of marqdo#25 (MDH-03..MDH-08).
98 lines
3.9 KiB
Bash
Executable File
98 lines
3.9 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}/mdh-ci.XXXXXX")"
|
|
trap 'rm -rf "$work"' EXIT
|
|
|
|
export PATH="$root/node_modules/.bin:$PATH"
|
|
|
|
echo "mdh ci: sha=$(git rev-parse HEAD 2>/dev/null || echo unknown)"
|
|
echo "mdh 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 [ "${MDH_SKIP_BUILD:-0}" = "1" ]; then
|
|
echo "mdh ci: apps/cli/lib/bin.js is missing and MDH_SKIP_BUILD=1" >&2
|
|
exit 1
|
|
fi
|
|
echo "mdh ci: building repository artifacts"
|
|
pnpm run build
|
|
fi
|
|
|
|
cli="${MARQDO_BIN:-}"
|
|
cli_sha="$(cat "${MDH_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 "mdh 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 "mdh 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 "mdh ci: cli=$cli source_sha=${cli_sha:-unknown}"
|
|
|
|
started="$(date -u +%Y-%m-%dT%H:%M:%SZ)"
|
|
MARQDO_BIN="$cli" node --import tsx/esm --test packages/marqdo/harness/tests/*.test.ts | tee "$out/tests.log"
|
|
|
|
if [ "${MDH_TEST_INSTALL:-0}" = "1" ]; then
|
|
echo "mdh ci: real release install/rollback"
|
|
MDH_TEST_INSTALL=1 node --import tsx/esm --test packages/marqdo/harness/tests/install.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.mdh.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 []),
|
|
'unverified': [
|
|
'real remote-model conversation (no model credential in this lane)',
|
|
'browser end-to-end automation (route and API verified over HTTP, see docs/mdh/STATUS.md)',
|
|
],
|
|
}
|
|
(out / 'evidence.json').write_text(json.dumps(evidence, indent=2) + '\n')
|
|
print(json.dumps(evidence, indent=2))
|
|
PY
|
|
|
|
echo "mdh ci: PASS"
|