Share
Embed
Transcript
44 slides
-
自己紹介 • Fumitaka Watanabe ◦ @fxwx23 • 株式会社はてな ◦ マンガアプリチーム
◦ GigaViewer for Apps [1] [1] https://hatena.co.jp/solutions/gigaviewer -
CIの高速化とコスト削減 • インスタンスタイプ見直し • キャッシュ活用 • テスト実行の並列化 • 不必要にテストを実行しない •
Flakyなテストを直す etc -
CIの高速化とコスト削減 • インスタンスタイプ見直し • キャッシュ活用 • テスト実行の並列化 • 不必要にテストを実行しない •
Flakyなテストを直す etc -
不必要なテストの実行 • commit度にCIでフルテストが実行される ◦ → 変更とは関係ないテストの実行 • Flakyなテストがある場合、変更とは関係ない テストが落ちる ◦
→ テストが落ちるとJobを再実行することになる ◦ → CIの時間が開発のボトルネックに -
マルチモジュール • 機能単位やレイヤー単位でモジュールを分割 • 嬉しいこと ◦ 機能同士の依存関係の整理 ◦ ビルド時間の削減 ◦
複数人での並行開発時のコンフリクト回避 ◦ 機能の取捨選択 etc -
マルチモジュール • 機能単位やレイヤー単位でモジュールを分割 • 嬉しいこと ◦ 機能同士の依存関係の整理 ◦ ビルド時間の削減 ◦
複数人での並行開発時のコンフリクト回避 ◦ 機能の取捨選択 etc -
📱App Feature 📦 Feature 📦 Feature 📦 Feature 📦 Common
📦 CommonUI 📦 Model 📦 Protocol -
📱App Feature 📦 Feature 📦 Feature 📦 Feature 📦 Common
📦 CommonUI 📦 Model 📦 Protocol -
📱App Feature 📦 Feature 📦 Feature 📦 Feature 📦 Common
📦 CommonUI 📦 Model 📦 Protocol -
Xcodeプロジェクト内のターゲット間 の依存関係 • App.xcworkspace > App.xcproj > project.pbxproj > PBXTarget
> PBXNativeTarget > dependencies http://www.monobjc.net/xcode-project-file-format.html -
• App.xcworkspace > App.xcproj > project.pbxproj > PBXTarget > PBXNativeTarget
> dependencies 491FBA866697560BBEF6A475 /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = 3478A70B9E3147C13F640454 /* AModule */; }; 4C4FDDD28591957330786D9B /* App */ = { isa = PBXNativeTarget; dependencies = ( 491FBA866697560BBEF6A475 /* PBXTargetDependency */ ); } http://www.monobjc.net/xcode-project-file-format.html Xcodeプロジェクト内のターゲット間 の依存関係 -
• App.xcworkspace > App.xcproj > project.pbxproj > PBXTarget > PBXNativeTarget
> dependencies 491FBA866697560BBEF6A475 /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = 3478A70B9E3147C13F640454 /* AModule */; }; 4C4FDDD28591957330786D9B /* App */ = { isa = PBXNativeTarget; dependencies = ( 491FBA866697560BBEF6A475 /* PBXTargetDependency */ ); } http://www.monobjc.net/xcode-project-file-format.html Xcodeプロジェクト内のターゲット間 の依存関係 -
ターゲットとSwift Package間の依存 4C4FDDD28591957330786D9B /* AModule */ = { isa =
PBXNativeTarget; packageProductDependencies = ( 1885F5AAE69D8D13E59C4ECF /* BModule */, ); }; http://www.monobjc.net/xcode-project-file-format.html • App.xcworkspace > App.xcproj > project.pbxproj > PBXTarget > PBXNativeTarget > packageProductDependencies -
Swift Package 内でのターゲット間の 依存 • $ swift package dump-package {
"targets": [ { "dependencies": [ { "byName": ["CModule", null] } ], "name": "BModule" } ] } -
XcodeSelectiveTesting • $ swift run xcode-selective-testing --test-plan App.xctestplan • $
swift run xcode-selective-testing --json https://github.com/mikeger/XcodeSelectiveTesting -
JSON Output [ { "name": "AppTests", "type": "target", "path": "\/path\/to\/your\/App.xcodeproj",
"testTarget": true }, { "name": "App", "type": "target", "path": "\/path\/to\/your\/App.xcodeproj", "testTarget": false } ] -
JSON Output [ { "name": "AppTests", "type": "target", "path": "\/path\/to\/your\/App.xcodeproj",
"testTarget": true }, { "name": "App", "type": "target", "path": "\/path\/to\/your\/App.xcodeproj", "testTarget": false } ] $ jq -r "[.[] | select(.testTarget == true)] | map(.name) | join(\",\")" -
JSON Output [ { "name": "AppTests", "type": "target", "path": "\/path\/to\/your\/App.xcodeproj",
"testTarget": true }, { "name": "App", "type": "target", "path": "\/path\/to\/your\/App.xcodeproj", "testTarget": false } ] $ jq -r "[.[] | select(.testTarget == true)] | map(.name) | join(\",\")" AppTests -
fastlane lane :selective_test do |options| if options[:targets].nil? then UI.user_error!("The required
parameter is invalid or missing.") end if options[:targets].empty? then UI.user_error!("At least one target is required.") end run_tests( scheme: "...", only_testing: options[:targets], ) end -
fastlane TARGETS=$(./scripts/affected-targets.sh) if [ -n "$TARGETS" ]; then bundle exec
fastlane selective_test targets:"$TARGETS" else bundle exec fastlane test fi https://fxwx23.hatenablog.com/entry/tips-integrating-xcode-selective-testing -
フルテスト +-------------------------------+ | Test Results | +-------------------------+-----+ | Number of
tests | 674 | | Number of failures | 0 | +-------------------------+-----+ -
フルテスト +-------------------------------+ | Test Results | +-------------------------+-----+ | Number of
tests | 15 | | Number of failures | 0 | +-------------------------+-----+ +-------------------------------+ | Test Results | +-------------------------+-----+ | Number of tests | 674 | | Number of failures | 0 | +-------------------------+-----+ Application Target 変更の み -
💪 フルテスト +-------------------------------+ | Test Results | +-------------------------+-----+ | Number
of tests | 15 | | Number of failures | 0 | +-------------------------+-----+ +-------------------------------+ | Test Results | +-------------------------+-----+ | Number of tests | 674 | | Number of failures | 0 | +-------------------------+-----+ Application Target 変更の み -
運用方針 • main、 Package更新のPRはフルテスト ◦ 任意のPRでフルテストに切り替える等は今後の課題 • 変更差分がどのモジュールにも影響していな い場合はフルテスト ◦
テストが実行されていないことに気づけないリスクは 防ぎたい -
導入してみて • 影響範囲が小さいほど恩恵が大きい • Flakyなテストの回避 ◦ Success Rate 向上の貢献 •
CPU利用や消費クレジットへの貢献