perf(ci): pin staged restore mtimes so the restore layer caches, drop build intermediates from the layer [CI]
ci/woodpecker/push/web-build Pipeline was successful
ci/woodpecker/push/verify Pipeline was successful
ci/woodpecker/push/dev-image Pipeline was successful

This commit is contained in:
justme committed 2026-10-19 14:05:22 +08:00
1 parent 5c00ec434e
commit 24ba05fbb6
3 files changed
+14 -2

No files matched your search

+10
View File
@@ -4,11 +4,13 @@
from __future__ import annotations
import argparse
import os
import shutil
import subprocess
from pathlib import Path
ROOT = Path(__file__).resolve().parents[1]
FIXED_MTIME = 946684800 # 2000-01-01T00:00:00Z
BACKEND = ROOT / "backend"
STATIC_MSQUIC = ROOT / "packaging/native/msquic"
IGNORED_PARTS = {".git", ".release", "artifacts", "bin", "obj", "TestResults", "tests"}
@@ -86,6 +88,14 @@ def stage(component: str, runtime_identifier: str, destination: Path) -> None:
# 更新清单和请求放在这里;空的命名卷第一次挂载时会带上这个目录
(config / "update").mkdir()
(config / "update" / ".keep").write_text("", encoding="utf-8")
normalize_mtimes(destination / "restore")
def normalize_mtimes(directory: Path) -> None:
"""The Buildah layer cache keys COPY layers on file metadata as well as content. Files copied from a fresh checkout carry a new
mtime every run, so the restore layer (and the ~70 s of NuGet downloads under it) never hit the cache. Pin the mtimes."""
for path in [directory, *directory.rglob("*")]:
os.utime(path, (FIXED_MTIME, FIXED_MTIME))
def main() -> None: