name: datatransport

on:
  pull_request:
    paths:
    - 'GoogleDataTransport**'
    - '.github/workflows/datatransport.yml'
    - 'Gemfile'
  schedule:
    # Run every day at 11pm (PST) - cron uses UTC times
    - cron:  '0 7 * * *'

jobs:
  pod_lib_lint:
    # Don't run on private repo unless it is a PR.
    if: (github.repository == 'Firebase/firebase-ios-sdk' && github.event_name == 'schedule') || github.event_name == 'pull_request'

    runs-on: macos-latest
    strategy:
      matrix:
        target: [ios, tvos, macos, watchos]
    steps:
    - uses: actions/checkout@v2
    - name: Setup Bundler
      run: ./scripts/setup_bundler.sh
    - name: PodLibLint DataTransport
      run: |
        scripts/third_party/travis/retry.sh scripts/pod_lib_lint.rb GoogleDataTransport.podspec --platforms=${{ matrix.target }}

  catalyst:
    # Don't run on private repo unless it is a PR.
    if: (github.repository == 'Firebase/firebase-ios-sdk' && github.event_name == 'schedule') || github.event_name == 'pull_request'

    runs-on: macOS-latest
    steps:
    - uses: actions/checkout@v2
    - name: Setup Bundler
      run: scripts/setup_bundler.sh
    - name: Setup project and Test Catalyst
      run: scripts/third_party/travis/retry.sh scripts/test_catalyst.sh GoogleDataTransport build

  watchos-testapp:
    # Don't run on private repo unless it is a PR.
    if: (github.repository == 'Firebase/firebase-ios-sdk' && github.event_name == 'schedule') || github.event_name == 'pull_request'

    runs-on: macOS-latest
    steps:
    - uses: actions/checkout@v2
    - name: Xcode 12
      run: sudo xcode-select -s /Applications/Xcode_12.app/Contents/Developer
    - name: Setup Bundler
      run: scripts/setup_bundler.sh
    - name: Prereqs
      run: scripts/install_prereqs.sh GoogleDataTransport watchOS xcodebuild
    - name: Setup project and build watchOS test app
      run: scripts/third_party/travis/retry.sh scripts/build.sh GoogleDataTransport watchOS xcodebuild

# Scheduled jobs

  datatransport-cron-only:
    # Don't run on private repo.
    if: github.event_name == 'schedule' && github.repository == 'Firebase/firebase-ios-sdk'

    runs-on: macos-latest
    strategy:
      matrix:
        target: [ios, tvos, macos, watchos]
        flags: [
          '--use-static-frameworks',
          '--use-libraries'
        ]
    needs: pod_lib_lint
    steps:
    - uses: actions/checkout@v2
    - name: Setup Bundler
      run: ./scripts/setup_bundler.sh
    - name: PodLibLint DataTransport Cron
      run: |
        scripts/third_party/travis/retry.sh scripts/pod_lib_lint.rb GoogleDataTransport.podspec --platforms=${{ matrix.target }} ${{ matrix.flags }}
