team-ljyzipelo

공개

로컬 검증 도구 탐색과 파일시스템 예외를 수정함

작성자
코노모리 카논
작성 시각
커밋
9752bce0414b65a5c82f3b7275a69fd56a8f3265
부모
4160fcc
이 시점의 파일 보기

변경된 파일 3개

+174-14
수정tests/ci/README.md+3-2
@@ -8,15 +8,16 @@ bash tests/ci/setup_windows.sh
88python3 tests/ci/run_rust.py local
99```
1010
11삭제: `local`은 실행기 자체 검사 후 Linux 전체 빌드, Linux Rust 시험, Windows 교차 빌드를 순서대로 수행합니다. 단계별 통과/실패/비해당 개수를 출력하고 `tests/ci/local-results.json`에 검증한 HEAD와 결과를 기록합니다. 실패가 있으면 종료 코드는 1입니다.
11추가: `local`은 실행기 자체 검사 후 교차 도구를 찾습니다. 도구가 없으면 `setup_windows.sh`를 실행해 프로젝트 안에 최초 준비하므로 네트워크와 아래 준비 도구가 필요합니다. 준비 실패는 결과 JSON에 `tool-setup` 실패로 남깁니다. 준비된 도구가 있으면 다시 다운로드하지 않습니다. 이후 Linux 전체 빌드, Linux Rust 시험, Windows 교차 빌드를 순서대로 수행합니다. 단계별 통과/실패/비해당 개수를 출력하고 `tests/ci/local-results.json`에 검증한 HEAD와 결과를 기록합니다. 실패가 있으면 종료 코드는 1입니다.
1212
1313- Rust 1.99.1, 기존 Cargo.lock, `--locked --all-targets --all-features`를 사용합니다. `experiments/*/Cargo.toml`과 `tests/*/Cargo.toml`을 자동 발견합니다.
1414- Windows는 `x86_64-pc-windows-gnu` 대상의 링크까지 확인합니다. 시험 바이너리도 컴파일하지만 실행하지 않습니다. Windows MSVC 빌드 및 실제 실행 검증을 대신하지 않습니다.
1515- 빌드 기본 병렬 수는 2이며 `CARGO_BUILD_JOBS`로 조절합니다. 시험 스레드는 1개입니다. `CARGO_TARGET_DIR` 기본값은 `tests/ci/target`이므로 후속 실행에서 빌드 캐시를 재사용합니다.
16삭제: - `setup_windows.sh`는 관리자 권한 없이 도구를 `tests/ci/tools`에 풉니다. apt-get, dpkg-deb, rustup 및 GCC 호스트 실행 라이브러리가 필요합니다. 공용 도구 경로를 재사용할 때는 프로젝트 안의 소유 경로를 `ZIPELO_CI_TOOLS`로 지정합니다. 기존 Rust target과 MinGW가 있으면 준비 스크립트 없이 PATH와 관련 Cargo/CC/CXX 환경 설정을 사용할 수 있습니다.
16추가: - `setup_windows.sh`는 관리자 권한 없이 도구를 `tests/ci/tools`에 풉니다. apt-get, dpkg-deb, rustup 및 GCC 호스트 실행 라이브러리가 필요합니다. 공용 도구 경로를 재사용할 때는 프로젝트 안의 소유 경로를 `ZIPELO_CI_TOOLS`로 지정합니다. 연결된 Git worktree에서는 현재 checkout의 도구를 먼저 찾고 같은 저장소 기본 worktree의 `tests/ci/tools`도 찾습니다. `ZIPELO_CI_TOOLS`를 지정하면 그 경로만 사용하며 별도 PATH 내보내기는 필요하지 않습니다. 기존 Rust target과 MinGW가 있으면 준비 스크립트 없이 PATH와 관련 Cargo/CC/CXX 환경 설정을 사용할 수 있습니다.
1717- Linux GUI 빌드에는 pkg-config, libxkbcommon-dev, libwayland-dev, libgl1-mesa-dev가 필요하며 글꼴 시험에는 fonts-noto-cjk가 필요합니다.
1818- 추적된 fixture를 Git blob과 대조합니다. Windows checkout 시 core.autocrlf=false를 사용해야 하며 기대값의 바이트를 바꾸지 않습니다.
1919- Unix 소켓 시험을 위해 짧은 checkout 경로를 사용합니다. 예: 프로젝트 아래 `tests/ci-k`. 기존 `runs` 디렉터리는 소유권, 0700, 빈 상태를 확인하고 새 디렉터리만 생성합니다. 실패한 fixture는 삭제하거나 권한을 바꾸지 않습니다.
20추가: - 파일 게시 계층은 ext4/XFS만 지원합니다. tmpfs 등 다른 파일시스템에서는 `rust-file-publication`과 `rust-gzip-file-job`의 Rust 실행 시험만 `not-applicable`로 기록하고 파일시스템 식별값과 사유를 출력합니다. 해당 crate의 Linux 및 Windows 빌드와 snapshot 등 나머지 시험은 계속합니다. 전체 시험 통과가 필요한 검증은 짧은 ext4/XFS checkout에서 수행합니다. 파일시스템 탐색 오류나 기존 시험 디렉터리의 소유권 문제는 실패로 남깁니다.
2021- 개별 단계는 `build`, `test`, `cross-build`로 실행할 수 있습니다. 한 crate가 실패해도 다른 crate 결과를 수집합니다.
2122- GUI 앱과 GUI race harness는 컴파일하며 실제 화면 시나리오는 실행하지 않습니다. C# 시험과 역사적 hash 검사는 포함하지 않습니다.
2223
수정tests/ci/run_rust.py+76-12
@@ -18,6 +18,7 @@ LINUX_ONLY = {
1818 "rust-ui-system-font-regressions",
1919}
2020FILE_FIXTURES = LINUX_ONLY - {"rust-ui-system-font-regressions"}
21추가: PUBLICATION_FIXTURES = {"rust-file-publication", "rust-gzip-file-job"}
2122
2223
2324def manifests(root):
@@ -50,9 +51,7 @@ def command(manifest, phase):
5051
5152
5253def prepare_fixtures(root):
53삭제: socket = root / "tests/rust-file-publication/runs/case-2147483647-99/parent/output"
54삭제: if len(os.fsencode(socket)) >= 108:
55삭제: raise ValueError("Unix 소켓 시험을 위해 더 짧은 checkout 경로가 필요함")
54추가: skipped = {}
5655 for name in sorted(FILE_FIXTURES):
5756 path = root / "tests" / name / "runs"
5857 if not path.exists() and not path.is_symlink():
@@ -66,15 +65,40 @@ def prepare_fixtures(root):
6665 or any(path.iterdir())
6766 ):
6867 raise ValueError(f"비어 있는 소유 시험 디렉터리가 필요함: {path}")
68추가: if name in PUBLICATION_FIXTURES:
69추가: filesystem = subprocess.check_output(
70추가: ["stat", "-f", "-c", "%t", "--", str(path)], text=True
71추가: ).strip().lower()
72추가: if filesystem not in {"ef53", "58465342"}:
73추가: skipped[name] = (
74추가: f"파일 게시 시험은 ext4/XFS가 필요함: filesystem=0x{filesystem}"
75추가: " (tmpfs 포함 다른 파일시스템은 제품 코드에서 지원하지 않음)"
76추가: )
77추가: continue
78추가: if name == "rust-file-publication":
79추가: socket = path / "case-2147483647-99/parent/output"
80추가: if len(os.fsencode(socket)) >= 108:
81추가: raise ValueError("Unix 소켓 시험을 위해 더 짧은 checkout 경로가 필요함")
82추가: return skipped
6983
7084
7185def run(root, phase):
7286 paths = manifests(root)
87추가: skipped = {}
7388 if phase == "test" and sys.platform == "linux":
74삭제: prepare_fixtures(root)
89추가: skipped = prepare_fixtures(root)
7590 results = []
7691 for manifest in paths:
7792 relative = manifest.relative_to(root).as_posix()
93추가: if manifest.parent.parent.name == "tests" and manifest.parent.name in skipped:
94추가: reason = skipped[manifest.parent.name]
95추가: results.append({
96추가: "manifest": relative,
97추가: "status": "not-applicable",
98추가: "reason": reason,
99추가: })
100추가: print(f"NOT APPLICABLE: {relative} ({reason})", flush=True)
101추가: continue
78102 if (
79103 phase == "test"
80104 and sys.platform != "linux"
@@ -99,6 +123,28 @@ def run(root, phase):
99123 return results
100124
101125
126추가: def prepare_tools(root):
127추가: configured = os.environ.get("ZIPELO_CI_TOOLS")
128추가: if configured:
129추가: directories = [Path(configured).resolve()]
130추가: else:
131추가: directories = [root / "tests/ci/tools"]
132추가: common = Path(subprocess.check_output(
133추가: ["git", "rev-parse", "--path-format=absolute", "--git-common-dir"],
134추가: cwd=root, text=True,
135추가: ).strip())
136추가: # 같은 저장소의 기본 worktree에 준비한 도구만 재사용함.
137추가: if common.name == ".git" and common.parent != root:
138추가: directories.append(common.parent / "tests/ci/tools")
139추가: for tools in directories:
140추가: if (tools / "rustup/toolchains/1.99.1-x86_64-unknown-linux-gnu").is_dir():
141추가: os.environ.setdefault("RUSTUP_HOME", str(tools / "rustup"))
142추가: bins = [str(tools / "mingw/usr/bin") for tools in directories
143추가: if (tools / "mingw/usr/bin").is_dir()]
144추가: if bins:
145추가: os.environ["PATH"] = os.pathsep.join(bins + [os.environ.get("PATH", "")])
146추가:
147추가:
102148def prepare_cross_build():
103149 for variable, names in (
104150 ("CARGO_TARGET_X86_64_PC_WINDOWS_GNU_LINKER", [
@@ -115,10 +161,23 @@ def prepare_cross_build():
115161 if not candidate:
116162 candidate = next((shutil.which(name) for name in names if shutil.which(name)), None)
117163 if not candidate or not shutil.which(candidate):
118삭제: raise ValueError(f"Windows 교차 컴파일 도구가 없음: {variable}")
164추가: raise ValueError(
165추가: f"Windows 교차 컴파일 도구가 없음: {variable}. "
166추가: "bash tests/ci/setup_windows.sh 실행 또는 ZIPELO_CI_TOOLS 지정이 필요함"
167추가: )
119168 os.environ[variable] = candidate
120169
121170
171추가: def prepare_local_tools(root):
172추가: try:
173추가: prepare_cross_build()
174추가: except ValueError:
175추가: print("Windows 교차 도구를 프로젝트 내부에 준비함: tests/ci/setup_windows.sh", flush=True)
176추가: subprocess.run(["bash", str(root / "tests/ci/setup_windows.sh")], cwd=root, check=True)
177추가: prepare_tools(root)
178추가: prepare_cross_build()
179추가:
180추가:
122181def execute_phases(root, phases):
123182 results = []
124183 for phase in phases:
@@ -126,7 +185,7 @@ def execute_phases(root, phases):
126185 if phase == "cross-build":
127186 prepare_cross_build()
128187 rows = run(root, phase)
129삭제: except (OSError, ValueError) as error:
188추가: except (OSError, ValueError, subprocess.CalledProcessError) as error:
130189 rows = [{"manifest": "preflight", "status": "failed", "reason": str(error)}]
131190 for row in rows:
132191 results.append({"phase": phase, **row})
@@ -139,11 +198,7 @@ def main():
139198 args = parser.parse_args()
140199 if args.phase == "local" and sys.platform != "linux":
141200 parser.error("local 모드는 Linux에서 실행해야 함")
142삭제: tools = Path(os.environ.get("ZIPELO_CI_TOOLS", ROOT / "tests/ci/tools")).resolve()
143삭제: if (tools / "rustup/toolchains/1.99.1-x86_64-unknown-linux-gnu").is_dir():
144삭제: os.environ.setdefault("RUSTUP_HOME", str(tools / "rustup"))
145삭제: if (tools / "mingw/usr/bin").is_dir():
146삭제: os.environ["PATH"] = str(tools / "mingw/usr/bin") + os.pathsep + os.environ["PATH"]
201추가: prepare_tools(ROOT)
147202 os.environ.setdefault("CARGO_BUILD_JOBS", "2")
148203 os.environ.setdefault("CARGO_TARGET_DIR", str(ROOT / "tests/ci/target"))
149204 phases = ["build", "test", "cross-build"] if args.phase == "local" else [args.phase]
@@ -159,7 +214,16 @@ def main():
159214 "exit_code": checks.returncode,
160215 }]
161216 else:
162삭제: results = execute_phases(ROOT, phases)
217추가: try:
218추가: if args.phase == "local":
219추가: prepare_local_tools(ROOT)
220추가: except (OSError, ValueError, subprocess.CalledProcessError) as error:
221추가: results = [{
222추가: "phase": "tool-setup", "manifest": "preflight",
223추가: "status": "failed", "reason": str(error),
224추가: }]
225추가: else:
226추가: results = execute_phases(ROOT, phases)
163227 report = {
164228 "head": subprocess.check_output(["git", "rev-parse", "HEAD"], cwd=ROOT, text=True).strip(),
165229 "platform": sys.platform,
수정tests/ci/test_runner.py+95-0
@@ -90,6 +90,8 @@ class RunnerTests(unittest.TestCase):
9090 report_path = root / f"tests/ci/{phase}-results.json"
9191 with (
9292 patch.object(run_rust, "ROOT", root),
93추가: patch.object(run_rust, "prepare_tools"),
94추가: patch.object(run_rust, "prepare_local_tools"),
9395 patch.object(run_rust.sys, "argv", ["run_rust.py", phase]),
9496 patch.object(run_rust.sys, "platform", platform),
9597 patch.dict(run_rust.os.environ, {"GITHUB_STEP_SUMMARY": ""}),
@@ -120,6 +122,99 @@ class RunnerTests(unittest.TestCase):
120122 self.assertFalse(failed["windows_runtime_tested"])
121123 execute.assert_called_once()
122124
125추가: def test_linked_worktree_finds_setup_tools_without_path_export(self):
126추가: with tempfile.TemporaryDirectory(dir=run_rust.ROOT / "tests/ci") as directory:
127추가: base = Path(directory)
128추가: root = base / "linked"
129추가: tools = base / "tests/ci/tools"
130추가: binaries = tools / "mingw/usr/bin"
131추가: binaries.mkdir(parents=True)
132추가: for name in ("gcc", "g++"):
133추가: executable = binaries / f"x86_64-w64-mingw32-{name}-posix"
134추가: executable.write_text("#!/bin/sh\nexit 0\n")
135추가: executable.chmod(0o700)
136추가: rustup = tools / "rustup"
137추가: (rustup / "toolchains/1.99.1-x86_64-unknown-linux-gnu").mkdir(parents=True)
138추가: with (
139추가: patch.dict(run_rust.os.environ, {"PATH": ""}, clear=True),
140추가: patch.object(run_rust.subprocess, "check_output", return_value=str(base / ".git")),
141추가: ):
142추가: run_rust.prepare_tools(root)
143추가: run_rust.prepare_cross_build()
144추가: self.assertEqual(run_rust.os.environ["RUSTUP_HOME"], str(rustup))
145추가: self.assertEqual(
146추가: run_rust.os.environ["CARGO_TARGET_X86_64_PC_WINDOWS_GNU_LINKER"],
147추가: str(binaries / "x86_64-w64-mingw32-gcc-posix"),
148추가: )
149추가:
150추가: def test_local_bootstraps_missing_cross_tools_and_reloads_paths(self):
151추가: root = Path("/repo")
152추가: with (
153추가: patch.object(run_rust, "prepare_cross_build", side_effect=[ValueError("missing"), None]) as detect,
154추가: patch.object(run_rust.subprocess, "run") as setup,
155추가: patch.object(run_rust, "prepare_tools") as reload,
156추가: ):
157추가: run_rust.prepare_local_tools(root)
158추가: setup.assert_called_once_with(
159추가: ["bash", "/repo/tests/ci/setup_windows.sh"], cwd=root, check=True,
160추가: )
161추가: reload.assert_called_once_with(root)
162추가: self.assertEqual(detect.call_count, 2)
163추가:
164추가: def test_existing_cross_tools_do_not_trigger_downloads(self):
165추가: with (
166추가: patch.object(run_rust, "prepare_cross_build"),
167추가: patch.object(run_rust.subprocess, "run") as setup,
168추가: ):
169추가: run_rust.prepare_local_tools(Path("/repo"))
170추가: setup.assert_not_called()
171추가:
172추가: def test_explicit_tools_directory_does_not_fall_back_to_other_worktree(self):
173추가: with (
174추가: patch.dict(run_rust.os.environ, {"PATH": "", "ZIPELO_CI_TOOLS": "/missing"}, clear=True),
175추가: patch.object(run_rust.subprocess, "check_output") as git,
176추가: ):
177추가: run_rust.prepare_tools(Path("/repo"))
178추가: git.assert_not_called()
179추가: with self.assertRaisesRegex(ValueError, "setup_windows.sh"):
180추가: run_rust.prepare_cross_build()
181추가:
182추가: def test_filesystem_skip_is_limited_to_publication_test_crates(self):
183추가: with tempfile.TemporaryDirectory(dir=run_rust.ROOT / "tests/ci") as directory:
184추가: root = Path(directory)
185추가: for name in run_rust.FILE_FIXTURES:
186추가: (root / "tests" / name).mkdir(parents=True)
187추가: paths = [
188추가: root / "tests/rust-file-publication/Cargo.toml",
189추가: root / "tests/rust-gzip-file-job/Cargo.toml",
190추가: root / "tests/rust-file-snapshot/Cargo.toml",
191추가: root / "experiments/rust-file-publication/Cargo.toml",
192추가: ]
193추가: with (
194추가: patch.object(run_rust.sys, "platform", "linux"),
195추가: patch.object(run_rust, "manifests", return_value=paths),
196추가: patch.object(run_rust.subprocess, "check_output", return_value="1021994\n"),
197추가: patch.object(run_rust.subprocess, "run", return_value=subprocess.CompletedProcess([], 0)) as cargo,
198추가: ):
199추가: results = run_rust.run(root, "test")
200추가: self.assertEqual([row["status"] for row in results], [
201추가: "not-applicable", "not-applicable", "passed", "passed",
202추가: ])
203추가: self.assertIn("0x1021994", results[0]["reason"])
204추가: self.assertEqual(cargo.call_count, 2)
205추가: cargo.reset_mock()
206추가: results = run_rust.run(root, "cross-build")
207추가: self.assertTrue(all(row["status"] == "passed" for row in results))
208추가: self.assertEqual(cargo.call_count, 4)
209추가:
210추가: def test_unknown_filesystem_probe_error_is_failure(self):
211추가: with (
212추가: patch.object(run_rust, "prepare_fixtures", side_effect=subprocess.CalledProcessError(1, "stat")),
213추가: patch.object(run_rust.sys, "platform", "linux"),
214추가: ):
215추가: results = run_rust.execute_phases(run_rust.ROOT, ["test"])
216추가: self.assertEqual(results[0]["status"], "failed")
217추가:
123218 def test_cargo_contract(self):
124219 args = run_rust.command(Path("tests/example/Cargo.toml"), "test")
125220 self.assertIn("--locked", args)