使用 Github Action 為 CCRegionSelector 加上測試的 CI

目前開源的 project 使用 Github Action 是免費的,剛好 travis.ci 也改成超過免費額度就要收費了,所以趁機為 CCRegionSelector 加上 Github Action。

首先先在 project 目錄下的 .github/workflows 資料夾中加上 yml 檔,我這邊命名為 CI-iOS.yml
Github Action 可以設定的參數非常多,這邊目標只是在當 code push 到 master 時才跑測試確認沒問題。

name: CI-iOS

# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the master branch
on:
push:
branches: [ master ]

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build-and-test:
# The type of runner that the job will run on
runs-on: macos-latest

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2

- name: Select Xcode
run: sudo xcode-select -switch /Applications/Xcode_12.4.app

- name: Xcode version
run: /usr/bin/xcodebuild -version

- name: Build and Test
run: xcodebuild -workspace Example/CCRegionSelector.xcworkspace -scheme CCRegionSelector-Unit-Tests CODE_SIGN_IDENTITY="" -configuration Debug CODE_SIGNING_REQUIRED=NO -sdk iphonesimulator -destination "platform=iOS Simulator,name=iPhone 12,OS=14.4" ONLY_ACTIVE_ARCH=YES test

同時為了 xcodebuild 比較好寫,可以把 CCRegionSelector-Unit-Tests 加到 Example 中的 Test 中,如圖下所示

github action

傳上去後,每次有 code push 到 master 便會自動啟動測試了

參考位置:https://github.com/ChadChang/CCRegionSelector

文章目錄
|