name: installations

permissions:
  contents: read

on:
  workflow_dispatch:
  pull_request:
    paths:
    - 'FirebaseInstallations**'
    - '.github/workflows/installations.yml'
    - '.github/workflows/common.yml'
    - '.github/workflows/common_cocoapods.yml'
    - '.github/workflows/common_catalyst.yml'
    - '.github/workflows/common_quickstart.yml'
    - '.github/workflows/common_cocoapods_cron.yml'
    - 'Gemfile*'
  schedule:
    # Run every day at 11pm (PDT) / 2am (EDT) - cron uses UTC times
    - cron:  '0 6 * * *'

concurrency:
    group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
    cancel-in-progress: true

jobs:
  spm:
    uses: ./.github/workflows/common.yml
    with:
      target: FirebaseInstallations
      buildonly_platforms: all

  catalyst:
    uses: ./.github/workflows/common_catalyst.yml
    with:
      product: FirebaseInstallations
      target: FirebaseInstallations-Unit-unit

  pod_lib_lint:
    uses: ./.github/workflows/common_cocoapods.yml
    with:
      product: FirebaseInstallations
      setup_command: |
        scripts/configure_test_keychain.sh
        mkdir -p FirebaseInstallations/Source/Tests/Resources
        scripts/decrypt_gha_secret.sh scripts/gha-encrypted/Installations/GoogleService-Info.plist.gpg \
          FirebaseInstallations/Source/Tests/Resources/GoogleService-Info.plist "$plist_secret"
        echo "FIS_INTEGRATION_TESTS_REQUIRED=1" >> $GITHUB_ENV
    secrets:
      plist_secret: ${{ secrets.GHASecretsGPGPassphrase1 }}

  quickstart:
    uses: ./.github/workflows/common_quickstart.yml
    strategy:
      matrix:
        quickstart_type: [objc, swift]
    with:
      product: Installations
      is_legacy: false
      setup_command: scripts/setup_quickstart.sh installations
      plist_src_path: scripts/gha-encrypted/Installations/GoogleService-Info.plist.gpg
      plist_dst_path: quickstart-ios/installations/GoogleService-Info.plist
      quickstart_type: ${{ matrix.quickstart_type }}
    secrets:
      plist_secret: ${{ secrets.GHASecretsGPGPassphrase1 }}

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

    runs-on: macos-15
    steps:
    - uses: actions/checkout@v4
    - uses: ruby/setup-ruby@354a1ad156761f5ee2b7b13fa8e09943a5e8d252 # v1
    - uses: actions/setup-python@v5
      with:
        python-version: '3.11'
    - name: Xcode
      run: sudo xcode-select -s /Applications/Xcode_16.4.app/Contents/Developer
    - name: Setup quickstart
      run: scripts/setup_quickstart.sh installations
    - name: Copy mock plist
      run: cp quickstart-ios/mock-GoogleService-Info.plist quickstart-ios/installations/GoogleService-Info.plist
    - name: Build objc quickstart
      run: scripts/third_party/travis/retry.sh scripts/test_quickstart_ftl.sh Installations
    - name: Build swift quickstart
      run: scripts/third_party/travis/retry.sh scripts/test_quickstart_ftl.sh Installations swift
    - id: ftl_test
      uses: FirebaseExtended/github-actions/firebase-test-lab@v1.4
      with:
        credentials_json: ${{ secrets.FIREBASE_SERVICE_ACCOUNT_CREDENTIALS }}
        testapp_dir: quickstart-ios/build-for-testing
        test_type: "xctest"

  installations-cron-only:
    needs: pod_lib_lint
    uses: ./.github/workflows/common_cocoapods_cron.yml
    with:
      product: FirebaseInstallations
      platforms: '[ "ios", "tvos", "macos" ]'
      flags: '[ "--use-static-frameworks" ]'
      setup_command: |
        scripts/configure_test_keychain.sh
        mkdir -p FirebaseInstallations/Source/Tests/Resources
        scripts/decrypt_gha_secret.sh scripts/gha-encrypted/Installations/GoogleService-Info.plist.gpg \
          FirebaseInstallations/Source/Tests/Resources/GoogleService-Info.plist "$plist_secret"
        echo "FIS_INTEGRATION_TESTS_REQUIRED=1" >> $GITHUB_ENV
    secrets:
      plist_secret: ${{ secrets.GHASecretsGPGPassphrase1 }}
