Skip to content

Add caching for CocoaPods in CI workflow to improve build efficiency #6

Add caching for CocoaPods in CI workflow to improve build efficiency

Add caching for CocoaPods in CI workflow to improve build efficiency #6

Workflow file for this run

name: iOS CI
on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main, develop ]
jobs:
build-and-test:
runs-on: macos-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Select Xcode
run: sudo xcode-select -switch /Applications/Xcode.app
- name: Get Ruby version
id: ruby-version
run: echo "version=$(cat .ruby-version)" >> $GITHUB_OUTPUT
- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ steps.ruby-version.outputs.version }}
bundler-cache: true
- name: Run RuboCop
run: |
bundle exec rubocop
- name: Cache CocoaPods
id: cocoapods-cache
uses: actions/cache@v4
with:
path: |
Example/Pods
~/Library/Caches/CocoaPods
~/.cocoapods
key: ${{ runner.os }}-pods-${{ hashFiles('**/Example/Podfile.lock') }}
restore-keys: |
${{ runner.os }}-pods-
- name: Install dependencies
if: steps.cocoapods-cache.outputs.cache-hit != 'true'
working-directory: Example
run: |
bundle exec pod install --repo-update
- name: List available simulators
run: xcrun simctl list devices available
- name: Build project
working-directory: Example
run: |
xcodebuild clean build \
-workspace arclight-event-tracker.xcworkspace \
-scheme arclight-event-tracker \
-destination 'platform=iOS Simulator,name=iPhone 15,OS=latest' \
-configuration Debug \
CODE_SIGN_IDENTITY="" \
CODE_SIGNING_REQUIRED=NO \
CODE_SIGNING_ALLOWED=NO \
DEVELOPMENT_TEAM="" \
PROVISIONING_PROFILE=""
- name: Run tests
working-directory: Example
run: |
xcodebuild test \
-workspace arclight-event-tracker.xcworkspace \
-scheme arclight-event-tracker \
-destination 'platform=iOS Simulator,name=iPhone 15,OS=latest' \
-configuration Debug \
CODE_SIGN_IDENTITY="" \
CODE_SIGNING_REQUIRED=NO \
CODE_SIGNING_ALLOWED=NO \
DEVELOPMENT_TEAM="" \
PROVISIONING_PROFILE="" \
-only-testing:Tests
- name: Build podspec
run: |
bundle execpod lib lint arclight-event-tracker.podspec --allow-warnings --verbose