team-ljyzipelo

공개

Windows와 Ubuntu Rust 빌드 및 시험 CI 추가

작성자
코노모리 카논
작성 시각
커밋
f0a86969417c3136f03fbb092ff01f77243a1372
부모
78cb231
이 시점의 파일 보기

변경된 파일 5개

+246-0
추가.github/workflows/rust.yml+52-0
@@ -0,0 +1,52 @@
1추가: name: Rust build and tests
2추가:
3추가: on:
4추가: pull_request:
5추가: push:
6추가: branches: [main]
7추가: workflow_dispatch:
8추가:
9추가: permissions:
10추가: contents: read
11추가:
12추가: concurrency:
13추가: group: rust-${{ github.workflow }}-${{ github.ref }}
14추가: cancel-in-progress: true
15추가:
16추가: jobs:
17추가: rust:
18추가: name: Rust (${{ matrix.os }})
19추가: runs-on: ${{ matrix.os }}
20추가: timeout-minutes: 45
21추가: strategy:
22추가: fail-fast: false
23추가: matrix:
24추가: os: [ubuntu-latest, windows-latest]
25추가: env:
26추가: CARGO_TERM_COLOR: always
27추가: CARGO_BUILD_JOBS: 1
28추가: CARGO_TARGET_DIR: ${{ github.workspace }}/tests/ci/target
29추가: RUST_BACKTRACE: 1
30추가: steps:
31추가: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
32추가: with:
33추가: persist-credentials: false
34추가: - uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1
35추가: with:
36추가: python-version: '3.13'
37추가: - name: Install Rust
38추가: run: rustup toolchain install 1.99.1 --profile minimal --no-self-update
39추가: - name: Install Linux GUI build dependencies and test font
40추가: if: runner.os == 'Linux'
41추가: run: |
42추가: sudo apt-get update
43추가: sudo apt-get install -y pkg-config libxkbcommon-dev libwayland-dev libgl1-mesa-dev fonts-noto-cjk
44추가: - name: Check CI runner
45추가: run: python -m unittest discover -s tests/ci -p 'test_*.py' -v
46추가: - name: Build every Rust crate and test harness
47추가: timeout-minutes: 20
48추가: run: python tests/ci/run_rust.py build
49추가: - name: Run Rust tests
50추가: if: ${{ !cancelled() }}
51추가: timeout-minutes: 20
52추가: run: python tests/ci/run_rust.py test
추가tests/ci/.gitignore+2-0
@@ -0,0 +1,2 @@
1추가: /target/
2추가: /*-results.json
추가tests/ci/README.md+17-0
@@ -0,0 +1,17 @@
1추가: # Rust CI
2추가:
3추가: `.github/workflows/rust.yml`은 PR, main push와 수동 실행에서 Ubuntu와 Windows를 각각 검사합니다. Rust 1.99.1과 기존 Cargo.lock을 사용하며 제품 소스와 의존성 버전을 바꾸지 않습니다.
4추가:
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
9추가: ```
10추가:
11추가: - `experiments/*/Cargo.toml`과 `tests/*/Cargo.toml`을 자동 발견합니다. 새 crate도 같은 구조와 Cargo.lock을 사용하면 포함됩니다.
12추가: - 모든 target과 feature를 빌드합니다. 시험은 Cargo에 등록된 루트 tests/의 Rust 회귀와 crate의 단위시험을 실행합니다. 시험 스레드는 1개입니다.
13추가: - Linux 전용 publication, snapshot, file-job, system-font 시험은 Windows에서 `not-applicable`로 표시합니다. 해당 crate의 Windows 빌드는 확인합니다.
14추가: - Linux 파일 시험에는 새 소유 `runs` 디렉터리를 0700으로 생성합니다. 기존 디렉터리의 권한은 변경하지 않으며 비어 있지 않으면 중단합니다. 글꼴 시험에는 `fonts-noto-cjk`가 필요합니다.
15추가: - GUI 앱과 GUI race harness는 컴파일하며 실제 GUI 시나리오는 실행하지 않습니다. C# 시험과 역사적 manifest/hash 검사는 이 Rust CI 범위에 포함하지 않습니다.
16추가: - Cargo 실패를 숨기지 않고 나머지 crate 결과도 수집한 뒤 실패로 종료합니다. OS 간에는 fail-fast를 끕니다. 빌드와 시험 단계는 각각 20분, 전체 job은 45분 제한입니다.
17추가: - 결과는 Actions 로그와 job summary 및 로컬 `tests/ci/*-results.json`에 남습니다. 공유 target은 `tests/ci/target`이며 `CARGO_TARGET_DIR`로 바꿀 수 있습니다.
추가tests/ci/run_rust.py+116-0
@@ -0,0 +1,116 @@
1추가: import argparse
2추가: import json
3추가: import os
4추가: from pathlib import Path
5추가: import stat
6추가: import subprocess
7추가: import sys
8추가:
9추가:
10추가: ROOT = Path(__file__).resolve().parents[2]
11추가: TOOLCHAIN = "+1.99.1"
12추가: LINUX_ONLY = {
13추가: "rust-file-publication",
14추가: "rust-file-snapshot",
15추가: "rust-gzip-file-job",
16추가: "rust-ui-system-font-regressions",
17추가: }
18추가: FILE_FIXTURES = LINUX_ONLY - {"rust-ui-system-font-regressions"}
19추가:
20추가:
21추가: def manifests(root):
22추가: paths = sorted(root.glob("experiments/*/Cargo.toml"))
23추가: if not paths:
24추가: raise ValueError("experiments/ Rust crate를 찾지 못함")
25추가: paths += sorted(root.glob("tests/*/Cargo.toml"))
26추가: for path in paths:
27추가: if not path.with_name("Cargo.lock").is_file():
28추가: raise ValueError(f"고정 Cargo.lock이 없음: {path}")
29추가: return paths
30추가:
31추가:
32추가: def command(manifest, phase):
33추가: arguments = [
34추가: "cargo",
35추가: TOOLCHAIN,
36추가: phase,
37추가: "--manifest-path",
38추가: str(manifest),
39추가: "--locked",
40추가: "--all-targets",
41추가: "--all-features",
42추가: ]
43추가: if phase == "test":
44추가: arguments += ["--", "--test-threads=1"]
45추가: return arguments
46추가:
47추가:
48추가: def prepare_fixtures(root):
49추가: for name in sorted(FILE_FIXTURES):
50추가: path = root / "tests" / name / "runs"
51추가: if not path.exists() and not path.is_symlink():
52추가: path.mkdir(mode=0o700)
53추가: info = path.lstat()
54추가: if (
55추가: not stat.S_ISDIR(info.st_mode)
56추가: or stat.S_IMODE(info.st_mode) != 0o700
57추가: or info.st_uid != os.geteuid()
58추가: or path.resolve() != path
59추가: or any(path.iterdir())
60추가: ):
61추가: raise ValueError(f"비어 있는 소유 시험 디렉터리가 필요함: {path}")
62추가:
63추가:
64추가: def run(root, phase):
65추가: paths = manifests(root)
66추가: if phase == "test" and sys.platform == "linux":
67추가: prepare_fixtures(root)
68추가: results = []
69추가: for manifest in paths:
70추가: relative = manifest.relative_to(root).as_posix()
71추가: if (
72추가: phase == "test"
73추가: and sys.platform != "linux"
74추가: and manifest.parent.parent.name == "tests"
75추가: and manifest.parent.name in LINUX_ONLY
76추가: ):
77추가: results.append({
78추가: "manifest": relative,
79추가: "status": "not-applicable",
80추가: "reason": "Linux-only cfg",
81추가: })
82추가: print(f"NOT APPLICABLE: {relative} (Linux-only cfg)", flush=True)
83추가: continue
84추가: print(f"::group::{phase}: {relative}", flush=True)
85추가: completed = subprocess.run(command(manifest, phase), cwd=root, check=False)
86추가: results.append({
87추가: "manifest": relative,
88추가: "status": "passed" if completed.returncode == 0 else "failed",
89추가: "exit_code": completed.returncode,
90추가: })
91추가: print("::endgroup::", flush=True)
92추가: return results
93추가:
94추가:
95추가: def main():
96추가: parser = argparse.ArgumentParser(description="Rust crate 전체 빌드와 tests/ 회귀 실행")
97추가: parser.add_argument("phase", choices=["build", "test"])
98추가: args = parser.parse_args()
99추가: os.environ.setdefault("CARGO_BUILD_JOBS", "1")
100추가: os.environ.setdefault("CARGO_TARGET_DIR", str(ROOT / "tests/ci/target"))
101추가: results = run(ROOT, args.phase)
102추가: (ROOT / f"tests/ci/{args.phase}-results.json").write_text(
103추가: json.dumps(results, ensure_ascii=False, indent=4) + "\n", encoding="utf-8"
104추가: )
105추가: summary = os.environ.get("GITHUB_STEP_SUMMARY")
106추가: if summary:
107추가: 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")
112추가: return int(any(result["status"] == "failed" for result in results))
113추가:
114추가:
115추가: if __name__ == "__main__":
116추가: raise SystemExit(main())
추가tests/ci/test_runner.py+59-0
@@ -0,0 +1,59 @@
1추가: from pathlib import Path
2추가: import subprocess
3추가: import unittest
4추가: from unittest.mock import patch
5추가:
6추가: import run_rust
7추가:
8추가:
9추가: class RunnerTests(unittest.TestCase):
10추가: def test_all_manifests_have_locks(self):
11추가: paths = run_rust.manifests(run_rust.ROOT)
12추가: expected = set(run_rust.ROOT.glob("experiments/*/Cargo.toml"))
13추가: expected |= set(run_rust.ROOT.glob("tests/*/Cargo.toml"))
14추가: self.assertEqual(set(paths), expected)
15추가:
16추가: def test_failure_does_not_hide_later_crates(self):
17추가: paths = [
18추가: Path("/repo/experiments/a/Cargo.toml"),
19추가: Path("/repo/experiments/b/Cargo.toml"),
20추가: ]
21추가: with (
22추가: patch.object(run_rust, "manifests", return_value=paths),
23추가: patch.object(run_rust.subprocess, "run", side_effect=[
24추가: subprocess.CompletedProcess([], 7),
25추가: subprocess.CompletedProcess([], 0),
26추가: ]),
27추가: ):
28추가: results = run_rust.run(Path("/repo"), "build")
29추가: self.assertEqual([row["status"] for row in results], ["failed", "passed"])
30추가: self.assertEqual(results[0]["exit_code"], 7)
31추가:
32추가: def test_windows_exclusion_is_explicit_and_only_for_linux_tests(self):
33추가: paths = [
34추가: Path("/repo/tests/rust-file-publication/Cargo.toml"),
35추가: Path("/repo/experiments/rust-file-publication/Cargo.toml"),
36추가: ]
37추가: with (
38추가: patch.object(run_rust, "manifests", return_value=paths),
39추가: patch.object(run_rust.sys, "platform", "win32"),
40추가: patch.object(
41추가: run_rust.subprocess, "run",
42추가: return_value=subprocess.CompletedProcess([], 0),
43추가: ) as execute,
44추가: ):
45추가: results = run_rust.run(Path("/repo"), "test")
46추가: self.assertEqual(
47추가: [row["status"] for row in results], ["not-applicable", "passed"]
48추가: )
49추가: self.assertEqual(execute.call_count, 1)
50추가:
51추가: def test_cargo_contract(self):
52추가: args = run_rust.command(Path("tests/example/Cargo.toml"), "test")
53추가: self.assertIn("--locked", args)
54추가: self.assertIn("--all-features", args)
55추가: self.assertEqual(args[-2:], ["--", "--test-threads=1"])
56추가:
57추가:
58추가: if __name__ == "__main__":
59추가: unittest.main()