name: build

on: [push, pull_request]

jobs:
  run-test:
    runs-on: macOS-latest
    strategy:
      matrix:
        destination: [
          'macOS', 
          'iOS Simulator,name=iPhone 8', 
          'tvOS Simulator,name=Apple TV', 
          'watchOS Simulator,name=Apple Watch Series 5 - 40mm'
        ]
        swift-version: [5.0]
    steps:
      - uses: actions/checkout@v1
      - uses: actions/cache@v1
        id: bundler-cache
        with:
          path: vendor/bundle
          key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}
          restore-keys: |
            ${{ runner.os }}-gems-
      - name: Bundle setup
        run: bundle config path vendor/bundle
      - name: Bundle install
        if: steps.bundler-cache.outputs.cache-hit != 'true'
        run: bundle install --jobs 4 --retry 3
      - name: Run tests
        env:
          DESTINATION: platform=${{ matrix.destination }}
          SWIFT_VERSION: ${{ matrix.swift-version }}
        run: bundle exec fastlane test_ci
