검증을 로컬 Linux 시험과 Windows 교차 빌드로 전환
- 작성자
- 코노모리 카논
- 작성 시각
- 커밋
f2f587249fa5b290527cefcce0404366b9a08c82- 부모
- e96aa25
변경된 파일 6개
+148-39| @@ -1,9 +1,6 @@ | ||
| 1 | 삭제: name: Rust build and tests | |
| 1 | 추가: name: Manual Windows verification | |
| 2 | 2 | |
| 3 | 3 | on: |
| 4 | 삭제: pull_request: | |
| 5 | 삭제: push: | |
| 6 | 삭제: branches: [main] | |
| 7 | 4 | workflow_dispatch: |
| 8 | 5 | |
| 9 | 6 | permissions: |
| @@ -15,13 +12,9 @@ concurrency: | ||
| 15 | 12 | |
| 16 | 13 | jobs: |
| 17 | 14 | rust: |
| 18 | 삭제: name: Rust (${{ matrix.os }}) | |
| 19 | 삭제: runs-on: ${{ matrix.os }} | |
| 15 | 추가: name: Windows build and tests | |
| 16 | 추가: runs-on: windows-latest | |
| 20 | 17 | timeout-minutes: 45 |
| 21 | 삭제: strategy: | |
| 22 | 삭제: fail-fast: false | |
| 23 | 삭제: matrix: | |
| 24 | 삭제: os: [ubuntu-latest, windows-latest] | |
| 25 | 18 | env: |
| 26 | 19 | CARGO_TERM_COLOR: always |
| 27 | 20 | CARGO_BUILD_JOBS: 1 |
| @@ -40,11 +33,6 @@ jobs: | ||
| 40 | 33 | python-version: '3.13' |
| 41 | 34 | - name: Install Rust |
| 42 | 35 | run: rustup toolchain install 1.99.1 --profile minimal --no-self-update |
| 43 | 삭제: - name: Install Linux GUI build dependencies and test font | |
| 44 | 삭제: if: runner.os == 'Linux' | |
| 45 | 삭제: run: | | |
| 46 | 삭제: sudo apt-get update | |
| 47 | 삭제: sudo apt-get install -y pkg-config libxkbcommon-dev libwayland-dev libgl1-mesa-dev fonts-noto-cjk | |
| 48 | 36 | - name: Check CI runner |
| 49 | 37 | run: python -m unittest discover -s tests/ci -p 'test_*.py' -v |
| 50 | 38 | - name: Build every Rust crate and test harness |
| @@ -1,2 +1,3 @@ | ||
| 1 | 1 | /target/ |
| 2 | 2 | /*-results.json |
| 3 | 추가: /tools/ |
| @@ -1,19 +1,27 @@ | ||
| 1 | 삭제: # Rust CI | |
| 1 | 추가: # 로컬 Rust 검증 | |
| 2 | 2 | |
| 3 | 삭제: `.github/workflows/rust.yml`은 PR, main push와 수동 실행에서 Ubuntu와 Windows를 각각 검사합니다. Rust 1.99.1과 기존 Cargo.lock을 사용하며 제품 소스와 의존성 버전을 바꾸지 않습니다. | |
| 3 | 추가: PR을 병합하기 전에 linux-desktop-2에서 아래 명령을 실행하고 검증한 커밋, 요약과 실패 또는 미실행 항목을 PR 본문에 남깁니다. 실패를 성공으로 처리하지 않습니다. | |
| 4 | 4 | |
| 5 | 5 | ```sh |
| 6 | 삭제: python -m unittest discover -s tests/ci -p 'test_*.py' -v | |
| 7 | 삭제: python tests/ci/run_rust.py build | |
| 8 | 삭제: python tests/ci/run_rust.py test | |
| 6 | 추가: # 최초 1회, Ubuntu의 apt 저장소에서 프로젝트 내부로 교차 도구를 준비함. | |
| 7 | 추가: bash tests/ci/setup_windows.sh | |
| 8 | 추가: python3 tests/ci/run_rust.py local | |
| 9 | 9 | ``` |
| 10 | 10 | |
| 11 | 삭제: - `experiments/*/Cargo.toml`과 `tests/*/Cargo.toml`을 자동 발견합니다. 새 crate도 같은 구조와 Cargo.lock을 사용하면 포함됩니다. | |
| 12 | 삭제: - checkout 단계의 Git 프로세스에만 core.autocrlf=false를 적용해 fixture 원본 바이트를 보존합니다. 빌드 전에 추적된 fixture 33개를 Git blob과 대조하며, OS에 따라 기대값을 바꾸지 않습니다. | |
| 13 | 삭제: - 모든 target과 feature를 빌드합니다. 시험은 Cargo에 등록된 루트 tests/의 Rust 회귀와 crate의 단위시험을 실행합니다. 시험 스레드는 1개입니다. | |
| 14 | 삭제: - Linux 전용 publication, snapshot, file-job, system-font 시험은 Windows에서 `not-applicable`로 표시합니다. 해당 crate의 Windows 빌드는 확인합니다. | |
| 15 | 삭제: - Linux 파일 시험에는 새 소유 `runs` 디렉터리를 0700으로 생성합니다. 기존 디렉터리의 권한은 변경하지 않으며 비어 있지 않으면 중단합니다. 글꼴 시험에는 `fonts-noto-cjk`가 필요합니다. | |
| 16 | 삭제: - Unix 소켓 시험은 최종 fixture 경로가 108바이트 미만이어야 합니다. 로컬 검증은 짧은 checkout 경로를 사용하세요. 실패한 fixture와 로그는 원인 확인 전까지 보존합니다. | |
| 17 | 삭제: - GUI 앱과 GUI race harness는 컴파일하며 실제 GUI 시나리오는 실행하지 않습니다. C# 시험과 역사적 manifest/hash 검사는 이 Rust CI 범위에 포함하지 않습니다. | |
| 18 | 삭제: - Cargo 실패를 숨기지 않고 나머지 crate 결과도 수집한 뒤 실패로 종료합니다. OS 간에는 fail-fast를 끕니다. 빌드와 시험 단계는 각각 20분, 전체 job은 45분 제한입니다. | |
| 19 | 삭제: - 결과는 Actions 로그와 job summary 및 로컬 `tests/ci/*-results.json`에 남습니다. 공유 target은 `tests/ci/target`이며 `CARGO_TARGET_DIR`로 바꿀 수 있습니다. | |
| 11 | 추가: `local`은 실행기 자체 검사 후 Linux 전체 빌드, Linux Rust 시험, Windows 교차 빌드를 순서대로 수행합니다. 단계별 통과/실패/비해당 개수를 출력하고 `tests/ci/local-results.json`에 검증한 HEAD와 결과를 기록합니다. 실패가 있으면 종료 코드는 1입니다. | |
| 12 | 추가: | |
| 13 | 추가: - Rust 1.99.1, 기존 Cargo.lock, `--locked --all-targets --all-features`를 사용합니다. `experiments/*/Cargo.toml`과 `tests/*/Cargo.toml`을 자동 발견합니다. | |
| 14 | 추가: - Windows는 `x86_64-pc-windows-gnu` 대상의 링크까지 확인합니다. 시험 바이너리도 컴파일하지만 실행하지 않습니다. Windows MSVC 빌드 및 실제 실행 검증을 대신하지 않습니다. | |
| 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 환경 설정을 사용할 수 있습니다. | |
| 17 | 추가: - Linux GUI 빌드에는 pkg-config, libxkbcommon-dev, libwayland-dev, libgl1-mesa-dev가 필요하며 글꼴 시험에는 fonts-noto-cjk가 필요합니다. | |
| 18 | 추가: - 추적된 fixture를 Git blob과 대조합니다. Windows checkout 시 core.autocrlf=false를 사용해야 하며 기대값의 바이트를 바꾸지 않습니다. | |
| 19 | 추가: - Unix 소켓 시험을 위해 짧은 checkout 경로를 사용합니다. 예: 프로젝트 아래 `tests/ci-k`. 기존 `runs` 디렉터리는 소유권, 0700, 빈 상태를 확인하고 새 디렉터리만 생성합니다. 실패한 fixture는 삭제하거나 권한을 바꾸지 않습니다. | |
| 20 | 추가: - 개별 단계는 `build`, `test`, `cross-build`로 실행할 수 있습니다. 한 crate가 실패해도 다른 crate 결과를 수집합니다. | |
| 21 | 추가: - GUI 앱과 GUI race harness는 컴파일하며 실제 화면 시나리오는 실행하지 않습니다. C# 시험과 역사적 hash 검사는 포함하지 않습니다. | |
| 22 | 추가: | |
| 23 | 추가: ## 출시 전 Windows 실기 확인 | |
| 24 | 추가: | |
| 25 | 추가: `.github/workflows/rust.yml`에는 `workflow_dispatch`만 있습니다. push/PR 자동 실행과 Linux GitHub job은 없습니다. 수동 Windows 실행은 출시 전에 별도로 배정하며, 이 작업에서는 다시 실행하지 않습니다. workflow가 기본 브랜치에 반영된 후 Actions에서 해당 브랜치를 골라 실행할 수 있습니다. | |
| 26 | 추가: | |
| 27 | 추가: 수동 실행은 Windows에서 전체 빌드와 Rust 시험을 수행하고 Linux 전용 publication, snapshot, file-job, system-font 시험은 `not-applicable`로 표시합니다. 기존 GUI 화면 시나리오는 별도 확인해야 합니다. |
| @@ -2,6 +2,7 @@ import argparse | ||
| 2 | 2 | import json |
| 3 | 3 | import os |
| 4 | 4 | from pathlib import Path |
| 5 | 추가: import shutil | |
| 5 | 6 | import stat |
| 6 | 7 | import subprocess |
| 7 | 8 | import sys |
| @@ -9,6 +10,7 @@ import sys | ||
| 9 | 10 | |
| 10 | 11 | ROOT = Path(__file__).resolve().parents[2] |
| 11 | 12 | TOOLCHAIN = "+1.99.1" |
| 13 | 추가: WINDOWS_TARGET = "x86_64-pc-windows-gnu" | |
| 12 | 14 | LINUX_ONLY = { |
| 13 | 15 | "rust-file-publication", |
| 14 | 16 | "rust-file-snapshot", |
| @@ -33,19 +35,24 @@ def command(manifest, phase): | ||
| 33 | 35 | arguments = [ |
| 34 | 36 | "cargo", |
| 35 | 37 | TOOLCHAIN, |
| 36 | 삭제: phase, | |
| 38 | 추가: "build" if phase == "cross-build" else phase, | |
| 37 | 39 | "--manifest-path", |
| 38 | 40 | str(manifest), |
| 39 | 41 | "--locked", |
| 40 | 42 | "--all-targets", |
| 41 | 43 | "--all-features", |
| 42 | 44 | ] |
| 45 | 추가: if phase == "cross-build": | |
| 46 | 추가: arguments += ["--target", WINDOWS_TARGET] | |
| 43 | 47 | if phase == "test": |
| 44 | 48 | arguments += ["--", "--test-threads=1"] |
| 45 | 49 | return arguments |
| 46 | 50 | |
| 47 | 51 | |
| 48 | 52 | 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 경로가 필요함") | |
| 49 | 56 | for name in sorted(FILE_FIXTURES): |
| 50 | 57 | path = root / "tests" / name / "runs" |
| 51 | 58 | if not path.exists() and not path.is_symlink(): |
| @@ -92,23 +99,87 @@ def run(root, phase): | ||
| 92 | 99 | return results |
| 93 | 100 | |
| 94 | 101 | |
| 102 | 추가: def prepare_cross_build(): | |
| 103 | 추가: for variable, names in ( | |
| 104 | 추가: ("CARGO_TARGET_X86_64_PC_WINDOWS_GNU_LINKER", [ | |
| 105 | 추가: "x86_64-w64-mingw32-gcc", "x86_64-w64-mingw32-gcc-posix", | |
| 106 | 추가: ]), | |
| 107 | 추가: ("CC_x86_64_pc_windows_gnu", [ | |
| 108 | 추가: "x86_64-w64-mingw32-gcc", "x86_64-w64-mingw32-gcc-posix", | |
| 109 | 추가: ]), | |
| 110 | 추가: ("CXX_x86_64_pc_windows_gnu", [ | |
| 111 | 추가: "x86_64-w64-mingw32-g++", "x86_64-w64-mingw32-g++-posix", | |
| 112 | 추가: ]), | |
| 113 | 추가: ): | |
| 114 | 추가: candidate = os.environ.get(variable) | |
| 115 | 추가: if not candidate: | |
| 116 | 추가: candidate = next((shutil.which(name) for name in names if shutil.which(name)), None) | |
| 117 | 추가: if not candidate or not shutil.which(candidate): | |
| 118 | 추가: raise ValueError(f"Windows 교차 컴파일 도구가 없음: {variable}") | |
| 119 | 추가: os.environ[variable] = candidate | |
| 120 | 추가: | |
| 121 | 추가: | |
| 122 | 추가: def execute_phases(root, phases): | |
| 123 | 추가: results = [] | |
| 124 | 추가: for phase in phases: | |
| 125 | 추가: try: | |
| 126 | 추가: if phase == "cross-build": | |
| 127 | 추가: prepare_cross_build() | |
| 128 | 추가: rows = run(root, phase) | |
| 129 | 추가: except (OSError, ValueError) as error: | |
| 130 | 추가: rows = [{"manifest": "preflight", "status": "failed", "reason": str(error)}] | |
| 131 | 추가: for row in rows: | |
| 132 | 추가: results.append({"phase": phase, **row}) | |
| 133 | 추가: return results | |
| 134 | 추가: | |
| 135 | 추가: | |
| 95 | 136 | def main(): |
| 96 | 삭제: parser = argparse.ArgumentParser(description="Rust crate 전체 빌드와 tests/ 회귀 실행") | |
| 97 | 삭제: parser.add_argument("phase", choices=["build", "test"]) | |
| 137 | 추가: parser = argparse.ArgumentParser(description="로컬 Linux 시험과 Windows 교차 빌드") | |
| 138 | 추가: parser.add_argument("phase", choices=["local", "build", "test", "cross-build"]) | |
| 98 | 139 | args = parser.parse_args() |
| 99 | 삭제: os.environ.setdefault("CARGO_BUILD_JOBS", "1") | |
| 140 | 추가: if args.phase == "local" and sys.platform != "linux": | |
| 141 | 추가: 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"] | |
| 147 | 추가: os.environ.setdefault("CARGO_BUILD_JOBS", "2") | |
| 100 | 148 | os.environ.setdefault("CARGO_TARGET_DIR", str(ROOT / "tests/ci/target")) |
| 101 | 삭제: results = run(ROOT, args.phase) | |
| 149 | 추가: phases = ["build", "test", "cross-build"] if args.phase == "local" else [args.phase] | |
| 150 | 추가: checks = subprocess.run( | |
| 151 | 추가: [sys.executable, "-m", "unittest", "discover", "-s", "tests/ci", "-p", "test_*.py"], | |
| 152 | 추가: cwd=ROOT, check=False, | |
| 153 | 추가: ) | |
| 154 | 추가: if checks.returncode != 0: | |
| 155 | 추가: return checks.returncode | |
| 156 | 추가: results = execute_phases(ROOT, phases) | |
| 157 | 추가: report = { | |
| 158 | 추가: "head": subprocess.check_output(["git", "rev-parse", "HEAD"], cwd=ROOT, text=True).strip(), | |
| 159 | 추가: "platform": sys.platform, | |
| 160 | 추가: "windows_cross_target": WINDOWS_TARGET if "cross-build" in phases else None, | |
| 161 | 추가: "windows_runtime_tested": sys.platform == "win32" and "test" in phases, | |
| 162 | 추가: "results": results, | |
| 163 | 추가: } | |
| 102 | 164 | (ROOT / f"tests/ci/{args.phase}-results.json").write_text( |
| 103 | 삭제: json.dumps(results, ensure_ascii=False, indent=4) + "\n", encoding="utf-8" | |
| 165 | 추가: json.dumps(report, ensure_ascii=False, indent=4) + "\n", encoding="utf-8" | |
| 104 | 166 | ) |
| 167 | 추가: lines = [] | |
| 168 | 추가: for phase in phases: | |
| 169 | 추가: selected = [row for row in results if row["phase"] == phase] | |
| 170 | 추가: counts = {status: sum(row["status"] == status for row in selected) | |
| 171 | 추가: for status in ("passed", "failed", "not-applicable")} | |
| 172 | 추가: lines.append(f"{phase}: " + ", ".join(f"{key}={value}" for key, value in counts.items())) | |
| 173 | 추가: for row in results: | |
| 174 | 추가: if row["status"] == "failed": | |
| 175 | 추가: lines.append(f"FAIL {row['phase']} {row['manifest']}: {row.get('reason', row.get('exit_code'))}") | |
| 176 | 추가: if "cross-build" in phases: | |
| 177 | 추가: lines.append("Windows: cross-build only; runtime tests not executed") | |
| 178 | 추가: print("\n".join(lines), flush=True) | |
| 105 | 179 | summary = os.environ.get("GITHUB_STEP_SUMMARY") |
| 106 | 180 | if summary: |
| 107 | 181 | with open(summary, "a", encoding="utf-8") as output: |
| 108 | 삭제: output.write(f"\nRust {args.phase} ({sys.platform})\n\n") | |
| 109 | 삭제: for result in results: | |
| 110 | 삭제: output.write(f"- {result['manifest']}: {result['status']}\n") | |
| 111 | 삭제: output.write("\nGUI harness는 컴파일만 확인하며 실제 화면 시나리오는 실행하지 않음.\n") | |
| 182 | 추가: output.write("\n" + "\n\n".join(lines) + "\n") | |
| 112 | 183 | return int(any(result["status"] == "failed" for result in results)) |
| 113 | 184 | |
| 114 | 185 |
| @@ -0,0 +1,26 @@ | ||
| 1 | 추가: #!/usr/bin/env bash | |
| 2 | 추가: set -euo pipefail | |
| 3 | 추가: | |
| 4 | 추가: repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)" | |
| 5 | 추가: ci_tools="${ZIPELO_CI_TOOLS:-$repo_root/tests/ci/tools}" | |
| 6 | 추가: mkdir -p "$ci_tools/downloads" "$ci_tools/mingw" | |
| 7 | 추가: ci_tools="$(cd "$ci_tools" && pwd)" | |
| 8 | 추가: | |
| 9 | 추가: # 도구를 프로젝트 안에 풀며 시스템 패키지는 설치하지 않음. | |
| 10 | 추가: ( | |
| 11 | 추가: cd "$ci_tools/downloads" | |
| 12 | 추가: apt-get download \ | |
| 13 | 추가: gcc-mingw-w64-x86-64-posix \ | |
| 14 | 추가: g++-mingw-w64-x86-64-posix \ | |
| 15 | 추가: gcc-mingw-w64-x86-64-posix-runtime \ | |
| 16 | 추가: gcc-mingw-w64-base \ | |
| 17 | 추가: binutils-mingw-w64-x86-64 \ | |
| 18 | 추가: binutils-mingw-w64-base \ | |
| 19 | 추가: mingw-w64-x86-64-dev \ | |
| 20 | 추가: mingw-w64-common | |
| 21 | 추가: for package in ./*.deb; do | |
| 22 | 추가: dpkg-deb -x "$package" "$ci_tools/mingw" | |
| 23 | 추가: done | |
| 24 | 추가: ) | |
| 25 | 추가: RUSTUP_HOME="$ci_tools/rustup" rustup toolchain install 1.99.1 \ | |
| 26 | 추가: --profile minimal --no-self-update --target x86_64-pc-windows-gnu |
| @@ -61,6 +61,21 @@ class RunnerTests(unittest.TestCase): | ||
| 61 | 61 | ) |
| 62 | 62 | self.assertEqual((run_rust.ROOT / name).read_bytes(), expected) |
| 63 | 63 | |
| 64 | 추가: def test_cross_build_never_executes_tests(self): | |
| 65 | 추가: args = run_rust.command(Path("tests/example/Cargo.toml"), "cross-build") | |
| 66 | 추가: self.assertEqual(args[2], "build") | |
| 67 | 추가: self.assertIn(run_rust.WINDOWS_TARGET, args) | |
| 68 | 추가: self.assertNotIn("--test-threads=1", args) | |
| 69 | 추가: | |
| 70 | 추가: def test_preflight_failure_is_reported_without_hiding_other_phase(self): | |
| 71 | 추가: with ( | |
| 72 | 추가: patch.object(run_rust, "prepare_cross_build", side_effect=ValueError("missing linker")), | |
| 73 | 추가: patch.object(run_rust, "run", return_value=[{"manifest": "sample", "status": "passed"}]), | |
| 74 | 추가: ): | |
| 75 | 추가: results = run_rust.execute_phases(Path("/repo"), ["build", "cross-build"]) | |
| 76 | 추가: self.assertEqual([row["status"] for row in results], ["passed", "failed"]) | |
| 77 | 추가: self.assertEqual(results[1]["reason"], "missing linker") | |
| 78 | 추가: | |
| 64 | 79 | def test_cargo_contract(self): |
| 65 | 80 | args = run_rust.command(Path("tests/example/Cargo.toml"), "test") |
| 66 | 81 | self.assertIn("--locked", args) |