Shashikant86.XcodeServer

CIステータス

Xcodeサーバー:iOS継続的インテグレーションのためのAnsibleプロビジョニング

=========

この役割は、AppleのCIサーバーであるXcodeサーバーを使用してmacOS上にiOSの継続的インテグレーションサービスを設定するために使用できます。この役割は、iOS開発者のためのローカル開発環境の設定にも使用できます。Xcode、Swift、Fastlane、Carthage、Cocoapodsなど、iOS開発者に必要なすべてのツールが含まれており、多くのHomebrewパッケージも利用できますが、変数を使って自分の環境を構成する完全なコントロールができます。Xcodeのインストールには、事前にダウンロードしたXIPファイルが必要です。

要件


  • macOS High Sierra
  • Xcode 9 以上

Xcode 9より前のバージョンはこの役割ではサポートされていません。

Xcodeの設定要件

この役割はXcodeをインストールするためのいくつかの方法がありますので、自分に合った方法を選んでください。

  • filesディレクトリにXcodeのXIPファイルを置く

playbookfiles/ディレクトリにxipを配置するか、$HOMEディレクトリ内にXIPファイルを配置します。例:~/Xcode_9.1.xip
インストールしたいXcodeのバージョンを指定するためにxcode_src変数を記載してください。

xcode_src: Xcode_9.1.xip

この役割には何が含まれていますか:

この役割には、iOS継続的インテグレーションサーバーをプロビジョニングするための次のソフトウェアパッケージが含まれています。

  • Xcode 9以上のインストール
  • Xcodeサーバーサービス
  • macOSのデフォルト設定: デフォルト設定とソフトウェアアップデートの管理
  • Homebrew: CarthageやCaskアプリケーションなどのパッケージをインストールするためのmacOS用パッケージマネージャー(オプション)
  • RVMおよび事前インストールされたGem(bundler、Fastlane、Cocoapods、Xcprettyなど)用のカスタマイズされたRubyバージョン(オプション)

自分のplaybookをカスタマイズしてデフォルトを上書きし、自分のplaybookを作成できます。

役割の変数:


この役割には、多くの変数があり、これを使って自分のplaybookを構成できます。すべての変数のリストはdefaults/main.ymlを参照してください。**defaults/main.ymlの変数を上書きして自分の設定を行えます**。変更すべき主な変数は以下です:

xcode_src: Xcode_{your_version}.xip
xcode_server_user: {your_xcodeserver_user}
ansible_ssh_user: {your_ansible_ssh_user}

この役割の使い方:


新しいmacと新しいmacOSがインストールされたと仮定します。この役割のplaybookを作成することで、すべてのXcodeサーバーをCI用に設定できます。必要に応じて設定変数を設定できます。

Ansibleをインストールしたと仮定して、次のコマンドを実行して役割をダウンロードします。

$ ansible-galaxy install Shashikant86.XcodeServer

次に、変数を設定して自分のplaybookを作成する必要があります。defaults/main.ymlファイルをこちらで使用できます。サンプルのplaybookは以下のようになります。

サンプルPlaybook


XcodeServerという新しいディレクトリを作成し、さらにXcodeServer/filesディレクトリを作成し、その中にXcodeのXIPを置きます。

$ mkdir XcodeServer
$ mkdir XcodeServer/files
$ touch xcs_playbook.yml

XcodeServerディレクトリ内に次の内容でxcs_playbook.ymlを作成し、playbookをローカルで実行します。localhostを他のホストに変更できます。

---
- hosts: localhost
  connection: local

  vars:
    clean_xcode: yes
    clean_rvm: yes
    clean_homebrew: yes

    configure_xcode: yes
    configure_xcodeserver: yes
    configure_macos_defaults: yes
    configure_ruby_rvm: yes
    configure_homebrew: yes

    xcode_src: Xcode_9.1.xip

    xcode_server_user: shashi
    ansible_ssh_user: shashi

    ruby_version: 2.4.0
    rubygems_packages_to_install:
      - bundler
      - xcpretty

    macos_sleep_options:
      - systemsetup -setsleep Never
      - systemsetup -setharddisksleep Never
      - systemsetup -setcomputersleep Never

    macos_animation_options:
      - defaults write NSGlobalDomain NSAutomaticWindowAnimationsEnabled -bool false
      - defaults write NSGlobalDomain NSWindowResizeTime -float 0.001
      - defaults write com.apple.dock expose-animation-duration -int 0
      - defaults write com.apple.dock launchanim -bool false

    macos_software_autoupdates:
      - softwareupdate --schedule off

    homebrew_use_brewfile: true
    homebrew_brewfile_dir: '~'
    homebrew_repo: https://github.com/Homebrew/brew
    homebrew_prefix: /usr/local
    homebrew_install_path: "{{ homebrew_prefix }}/Homebrew"
    homebrew_brew_bin_path: /usr/local/bin
    homebrew_upgrade_all_packages: no

    homebrew_installed_packages:
      - autoconf
      - bash-completion
      - git
      - carthage
      - gpg
      - boost
      - cmake
      - ssh-copy-id
      - openssl
      - wget
      - curl

    homebrew_taps:
      - homebrew/core
      - caskroom/cask
      - homebrew/binary
      - homebrew/dupes
      - homebrew/versions

    homebrew_cask_apps:
      - postman

  roles:
    - Shashikant86.XcodeServer

ansible_ssh_userxcode_server_userを自分のユーザー名に変更し、必要に応じて変数を設定してください。次に、このplaybookを実行します。

$ ansible-playbook xcs_playbook.yml

mac MiniサーバーがiOS継続的インテグレーションのために設定されていく様子を見てください。

Travisによる継続的インテグレーションのセットアップ


TravisCIには独自のXcodeイメージがあるため、Xcodeの設定を無効にして、TravisCIでこの役割をテストできます。他のすべての設定についてはTravisCIでテストできます。TravisCIの設定は.travis.ymlにあり、playbook/configはtestsディレクトリにあります。TravisCIの出力はこちらで確認できます。

依存関係


なし

ライセンス


MIT

著者情報


Shashikant Jagtap

プロジェクトについて

Xcode Server Setup macOS for Continuous Integration using Apple Xcode Server

インストール
ansible-galaxy install Shashikant86.XcodeServer
ライセンス
Unknown
ダウンロード
71
所有者
Mobile DevOps, CI/CD, Mobile Build & Test Automation. Swift, Kotlin, XCTest, XCUITest, Xcode Server, Apple Developer tools, Flutter, Ruby, PHP etc