An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:art: Check ONNX Runtime source pin consistency before builds https://github.com/siyuan-note/siyuan/issues/20589
Danielf00425e53ac3
diff --git a/Dockerfile b/Dockerfileindex b06606691e..3ce1e5f54f 100644--- a/Dockerfile+++ b/Dockerfile@@ -1,5 +1,6 @@ARG ALPINE_IMAGE=alpine:3.24@sha256:294b683cb724975bec92580e1e685676bd4b50bda910ddb8c51d4cabeaec77e6ARG GO_IMAGE=golang:1.26-alpine@sha256:3082400e369fa24d5fc60bca20edab3f6d604e0c5a690ec66b295eff4dd87ade+ARG ONNX_VERSION=1.24.3FROM --platform=$BUILDPLATFORM node:22@sha256:0e5f906573693feaa1e21057ebdcfdb5bd5021f050b2dc7c9deceb629c7da2a8 AS node-build@@ -51,6 +52,7 @@ RUN --mount=type=cache,target=/root/.cache/go-build \FROM --platform=$BUILDPLATFORM ${ALPINE_IMAGE} AS onnx-sourceARG ONNX_COMMIT=3a728b75062256951b6e19ce718907cf1a1d4cf0+ARG ONNX_VERSIONRUN apk add --no-cache git# 固定提交的源码在构建机上下载一次,网络中断时重试;子模块保持各自锁定的提交。RUN <<EORUN@@ -71,13 +73,15 @@ git config http.version HTTP/1.1retry git fetch --depth=1 --no-tags origin "${ONNX_COMMIT}"git checkout --detach FETCH_HEADtest "$(git rev-parse HEAD)" = "${ONNX_COMMIT}"+# 源码版本不匹配时,在下载子模块和编译各平台之前停止。+test "$(cat VERSION_NUMBER)" = "${ONNX_VERSION}"retry git -c http.version=HTTP/1.1 submodule update --init --recursive --depth=1EORUNFROM ${ALPINE_IMAGE} AS onnx-buildARG TARGETARCHARG TARGETPLATFORM-ARG ONNX_VERSION=1.24.3+ARG ONNX_VERSIONARG ONNX_TOOLCHAIN_REV=1# ONNX 阶段只依赖 C++ 工具链和固定源码;更新工具链时递增修订号以刷新安装层。RUN echo "${TARGETPLATFORM} toolchain revision ${ONNX_TOOLCHAIN_REV}" \diff --git a/scripts/test_build_ocr_harmony.py b/scripts/test_build_ocr_harmony.pyindex bfa5bbf031..fcdfff500e 100644--- a/scripts/test_build_ocr_harmony.py+++ b/scripts/test_build_ocr_harmony.py@@ -34,6 +34,15 @@ class GitReader:class SourceExportTests(unittest.TestCase):+ def test_docker_and_harmony_use_the_same_pinned_commit(self):+ root = Path(__file__).resolve().parents[1]+ dockerfile = root.joinpath("Dockerfile").read_text(encoding="utf-8")+ commits = [line.removeprefix("ARG ONNX_COMMIT=") for line in dockerfile.splitlines()+ if line.startswith("ARG ONNX_COMMIT=")]+ self.assertEqual(commits, [harmony.REVISION])+ self.assertEqual(len(harmony.REVISION), 40)+ int(harmony.REVISION, 16)+def test_export_reads_pinned_blobs_and_skips_submodules(self):tree = b"100644 blob abc\tcmake/source.txt\0" + b"160000 commit def\tcmake/external/onnx\0"with tempfile.TemporaryDirectory() as directory:diff --git a/scripts/test_docker_release.py b/scripts/test_docker_release.pyindex 2977110dd0..ed1c36cc59 100644--- a/scripts/test_docker_release.py+++ b/scripts/test_docker_release.py@@ -490,7 +490,7 @@ class CacheTests(unittest.TestCase):class SourceDownloadTests(unittest.TestCase):- def execute(self, fetch_failures=0, submodule_failures=0, actual_commit=None):+ def execute(self, fetch_failures=0, submodule_failures=0, actual_commit=None, source_version=None, missing_version=False):shell = shutil.which("sh")if shell is None:git = shutil.which("git")@@ -502,6 +502,7 @@ class SourceDownloadTests(unittest.TestCase):stage = dockerfile.split("AS onnx-source\n", 1)[1].split("\nFROM ", 1)[0]script = stage.split("RUN <<EORUN\n", 1)[1].split("\nEORUN", 1)[0]commit = stage.split("ARG ONNX_COMMIT=", 1)[1].splitlines()[0]+ version = dockerfile.split("ARG ONNX_VERSION=", 1)[1].splitlines()[0]with tempfile.TemporaryDirectory() as directory:root = Path(directory)trace = root / "trace"@@ -510,7 +511,9 @@ submodule_calls=0git() {printf '%s\n' "$*" >> "$TRACE"case "$1" in- init) mkdir -p "$2" ;;+ init)+ mkdir -p "$2"+ if [ "$MISSING_VERSION" != 1 ]; then printf '%s\n' "$SOURCE_VERSION" > "$2/VERSION_NUMBER"; fi ;;fetch)fetch_calls=$((fetch_calls + 1))if [ "$fetch_calls" -le "$FETCH_FAILURES" ]; then return 1; fi ;;@@ -531,6 +534,8 @@ sleep() { printf 'sleep %s\n' "$*" >> "$TRACE"; }encoding="utf-8", newline="\n")env = dict(os.environ, TRACE=trace.as_posix(), FETCH_FAILURES=str(fetch_failures),SUBMODULE_FAILURES=str(submodule_failures), ONNX_COMMIT=commit,+ ONNX_VERSION=version, SOURCE_VERSION=source_version if source_version is not None else version,+ MISSING_VERSION="1" if missing_version else "0",ACTUAL_COMMIT=actual_commit or commit)result = subprocess.run([shell, "-e", str(path)], env=env, capture_output=True, text=True, timeout=20)return result.returncode, trace.read_text(encoding="utf-8").splitlines(), commit@@ -557,6 +562,21 @@ sleep() { printf 'sleep %s\n' "$*" >> "$TRACE"; }self.assertEqual(sum(line.startswith("fetch ") for line in trace), 1)self.assertEqual(trace.count("-c http.version=HTTP/1.1 submodule update --init --recursive --depth=1"), 3)+ def test_wrong_or_missing_source_version_stops_before_submodules(self):+ for options in ({"source_version": "0.0.0"}, {"source_version": ""}, {"missing_version": True}):+ with self.subTest(options=options):+ code, trace, _ = self.execute(**options)+ self.assertNotEqual(code, 0)+ self.assertFalse(any("submodule update" in line for line in trace))++ def test_source_and_build_stages_share_the_global_version_argument(self):+ dockerfile = Path(__file__).resolve().parents[1].joinpath("Dockerfile").read_text(encoding="utf-8")+ self.assertEqual(dockerfile.count("ARG ONNX_VERSION="), 1)+ self.assertIn("ARG ONNX_VERSION=", dockerfile.split("\nFROM ", 1)[0])+ for name in ("onnx-source", "onnx-build"):+ stage = dockerfile.split("AS " + name + "\n", 1)[1].split("\nFROM ", 1)[0]+ self.assertIn("\nARG ONNX_VERSION\n", "\n" + stage)+if __name__ == "__main__":unittest.main()