로컬 검증 도구 탐색과 파일시스템 예외를 수정함
- 작성자
- 코노모리 카논
- 작성 시각
- 커밋
9752bce0414b65a5c82f3b7275a69fd56a8f3265- 부모
- 4160fcc
변경된 파일 3개
+174-14| @@ -8,15 +8,16 @@ bash tests/ci/setup_windows.sh | ||
| 8 | 8 | python3 tests/ci/run_rust.py local |
| 9 | 9 | ``` |
| 10 | 10 | |
| 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입니다. | |
| 12 | 12 | |
| 13 | 13 | - Rust 1.99.1, 기존 Cargo.lock, `--locked --all-targets --all-features`를 사용합니다. `experiments/*/Cargo.toml`과 `tests/*/Cargo.toml`을 자동 발견합니다. |
| 14 | 14 | - Windows는 `x86_64-pc-windows-gnu` 대상의 링크까지 확인합니다. 시험 바이너리도 컴파일하지만 실행하지 않습니다. Windows MSVC 빌드 및 실제 실행 검증을 대신하지 않습니다. |
| 15 | 15 | - 빌드 기본 병렬 수는 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 환경 설정을 사용할 수 있습니다. | |
| 17 | 17 | - Linux GUI 빌드에는 pkg-config, libxkbcommon-dev, libwayland-dev, libgl1-mesa-dev가 필요하며 글꼴 시험에는 fonts-noto-cjk가 필요합니다. |
| 18 | 18 | - 추적된 fixture를 Git blob과 대조합니다. Windows checkout 시 core.autocrlf=false를 사용해야 하며 기대값의 바이트를 바꾸지 않습니다. |
| 19 | 19 | - 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에서 수행합니다. 파일시스템 탐색 오류나 기존 시험 디렉터리의 소유권 문제는 실패로 남깁니다. | |
| 20 | 21 | - 개별 단계는 `build`, `test`, `cross-build`로 실행할 수 있습니다. 한 crate가 실패해도 다른 crate 결과를 수집합니다. |
| 21 | 22 | - GUI 앱과 GUI race harness는 컴파일하며 실제 화면 시나리오는 실행하지 않습니다. C# 시험과 역사적 hash 검사는 포함하지 않습니다. |
| 22 | 23 |
| @@ -18,6 +18,7 @@ LINUX_ONLY = { | ||
| 18 | 18 | "rust-ui-system-font-regressions", |
| 19 | 19 | } |
| 20 | 20 | FILE_FIXTURES = LINUX_ONLY - {"rust-ui-system-font-regressions"} |
| 21 | 추가: PUBLICATION_FIXTURES = {"rust-file-publication", "rust-gzip-file-job"} | |
| 21 | 22 | |
| 22 | 23 | |
| 23 | 24 | def manifests(root): |
| @@ -50,9 +51,7 @@ def command(manifest, phase): | ||
| 50 | 51 | |
| 51 | 52 | |
| 52 | 53 | def 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 = {} | |
| 56 | 55 | for name in sorted(FILE_FIXTURES): |
| 57 | 56 | path = root / "tests" / name / "runs" |
| 58 | 57 | if not path.exists() and not path.is_symlink(): |
| @@ -66,15 +65,40 @@ def prepare_fixtures(root): | ||
| 66 | 65 | or any(path.iterdir()) |
| 67 | 66 | ): |
| 68 | 67 | 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 | |
| 69 | 83 | |
| 70 | 84 | |
| 71 | 85 | def run(root, phase): |
| 72 | 86 | paths = manifests(root) |
| 87 | 추가: skipped = {} | |
| 73 | 88 | if phase == "test" and sys.platform == "linux": |
| 74 | 삭제: prepare_fixtures(root) | |
| 89 | 추가: skipped = prepare_fixtures(root) | |
| 75 | 90 | results = [] |
| 76 | 91 | for manifest in paths: |
| 77 | 92 | 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 | |
| 78 | 102 | if ( |
| 79 | 103 | phase == "test" |
| 80 | 104 | and sys.platform != "linux" |
| @@ -99,6 +123,28 @@ def run(root, phase): | ||
| 99 | 123 | return results |
| 100 | 124 | |
| 101 | 125 | |
| 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 | 추가: | |
| 102 | 148 | def prepare_cross_build(): |
| 103 | 149 | for variable, names in ( |
| 104 | 150 | ("CARGO_TARGET_X86_64_PC_WINDOWS_GNU_LINKER", [ |
| @@ -115,10 +161,23 @@ def prepare_cross_build(): | ||
| 115 | 161 | if not candidate: |
| 116 | 162 | candidate = next((shutil.which(name) for name in names if shutil.which(name)), None) |
| 117 | 163 | 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 | 추가: ) | |
| 119 | 168 | os.environ[variable] = candidate |
| 120 | 169 | |
| 121 | 170 | |
| 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 | 추가: | |
| 122 | 181 | def execute_phases(root, phases): |
| 123 | 182 | results = [] |
| 124 | 183 | for phase in phases: |
| @@ -126,7 +185,7 @@ def execute_phases(root, phases): | ||
| 126 | 185 | if phase == "cross-build": |
| 127 | 186 | prepare_cross_build() |
| 128 | 187 | rows = run(root, phase) |
| 129 | 삭제: except (OSError, ValueError) as error: | |
| 188 | 추가: except (OSError, ValueError, subprocess.CalledProcessError) as error: | |
| 130 | 189 | rows = [{"manifest": "preflight", "status": "failed", "reason": str(error)}] |
| 131 | 190 | for row in rows: |
| 132 | 191 | results.append({"phase": phase, **row}) |
| @@ -139,11 +198,7 @@ def main(): | ||
| 139 | 198 | args = parser.parse_args() |
| 140 | 199 | if args.phase == "local" and sys.platform != "linux": |
| 141 | 200 | 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) | |
| 147 | 202 | os.environ.setdefault("CARGO_BUILD_JOBS", "2") |
| 148 | 203 | os.environ.setdefault("CARGO_TARGET_DIR", str(ROOT / "tests/ci/target")) |
| 149 | 204 | phases = ["build", "test", "cross-build"] if args.phase == "local" else [args.phase] |
| @@ -159,7 +214,16 @@ def main(): | ||
| 159 | 214 | "exit_code": checks.returncode, |
| 160 | 215 | }] |
| 161 | 216 | 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) | |
| 163 | 227 | report = { |
| 164 | 228 | "head": subprocess.check_output(["git", "rev-parse", "HEAD"], cwd=ROOT, text=True).strip(), |
| 165 | 229 | "platform": sys.platform, |
| @@ -90,6 +90,8 @@ class RunnerTests(unittest.TestCase): | ||
| 90 | 90 | report_path = root / f"tests/ci/{phase}-results.json" |
| 91 | 91 | with ( |
| 92 | 92 | patch.object(run_rust, "ROOT", root), |
| 93 | 추가: patch.object(run_rust, "prepare_tools"), | |
| 94 | 추가: patch.object(run_rust, "prepare_local_tools"), | |
| 93 | 95 | patch.object(run_rust.sys, "argv", ["run_rust.py", phase]), |
| 94 | 96 | patch.object(run_rust.sys, "platform", platform), |
| 95 | 97 | patch.dict(run_rust.os.environ, {"GITHUB_STEP_SUMMARY": ""}), |
| @@ -120,6 +122,99 @@ class RunnerTests(unittest.TestCase): | ||
| 120 | 122 | self.assertFalse(failed["windows_runtime_tested"]) |
| 121 | 123 | execute.assert_called_once() |
| 122 | 124 | |
| 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 | 추가: | |
| 123 | 218 | def test_cargo_contract(self): |
| 124 | 219 | args = run_rust.command(Path("tests/example/Cargo.toml"), "test") |
| 125 | 220 | self.assertIn("--locked", args) |