|
| 1 | +name: common_cocoapods |
| 2 | + |
| 3 | +permissions: |
| 4 | + contents: read |
| 5 | + |
| 6 | +on: |
| 7 | + workflow_call: |
| 8 | + inputs: |
| 9 | + # The product to test be tested (e.g. `FirebaseABTesting`). |
| 10 | + product: |
| 11 | + type: string |
| 12 | + required: true |
| 13 | + |
| 14 | + # The platforms to build on. Defaults to all. |
| 15 | + # To target specific platforms, pass a comma or space separated string of |
| 16 | + # platforms. |
| 17 | + # |
| 18 | + # Examples: |
| 19 | + # - build/test only for macOS: `macOS` |
| 20 | + # - build/test only for macOS and tvOS: `macOS, tvOS` |
| 21 | + platforms: |
| 22 | + type: string |
| 23 | + required: false |
| 24 | + default: "iOS, tvOS, macOS, watchOS" |
| 25 | + |
| 26 | + # By default, all platforms will be tested (see matrix in `spm` job). |
| 27 | + # To build instead of test, pass a comma or space separated string of |
| 28 | + # platforms. |
| 29 | + # |
| 30 | + # Platform options: [iOS, tvOS, macOS, watchOS, catalyst, visionOS] |
| 31 | + # |
| 32 | + # Note: Build-only platforms must be represented in the `platforms` input |
| 33 | + # (which defaults to all platforms) in order to take effect. |
| 34 | + # |
| 35 | + # Examples: |
| 36 | + # - build only for macOS: `macOS` |
| 37 | + # - build only for macOS and tvOS: `macOS, tvOS` |
| 38 | + # - build only for all platforms: `all` |
| 39 | + buildonly_platforms: |
| 40 | + type: string |
| 41 | + required: false |
| 42 | + default: "" |
| 43 | + |
| 44 | + # Whether to lint with `--allow-warnings`. Defaults to false. |
| 45 | + allow_warnings: |
| 46 | + type: boolean |
| 47 | + required: false |
| 48 | + default: false |
| 49 | + |
| 50 | + # Whether to additionally build with Swift 6. Defaults to false. |
| 51 | + supports_swift6: |
| 52 | + type: boolean |
| 53 | + required: false |
| 54 | + default: false |
| 55 | + |
| 56 | + # A comma separated (no spaces) string that will be passed to |
| 57 | + # pod lib lint's `--test-specs=` argument. By default, all |
| 58 | + # test specs will be tested. |
| 59 | + test_specs: |
| 60 | + type: string |
| 61 | + required: false |
| 62 | + default: "" |
| 63 | + |
| 64 | + # A command to execute before testing. |
| 65 | + # |
| 66 | + # This is useful for additional set up, like starting an emulator or |
| 67 | + # downloading test data. |
| 68 | + # |
| 69 | + # Example: `FirebaseFunctions/Backend/start.sh synchronous` |
| 70 | + setup_command: |
| 71 | + type: string |
| 72 | + required: false |
| 73 | + default: "" |
| 74 | + |
| 75 | +jobs: |
| 76 | + pod-lib-lint: |
| 77 | + # Run on the main repo's scheduled jobs or pull requests and manual workflow invocations. |
| 78 | + if: (github.repository == 'firebase/firebase-ios-sdk' && github.event_name == 'schedule') || contains(fromJSON('["pull_request", "workflow_dispatch"]'), github.event_name) |
| 79 | + strategy: |
| 80 | + matrix: |
| 81 | + os: [macos-15] |
| 82 | + xcode: [Xcode_16.3] |
| 83 | + platform: [iOS, tvOS, macOS, watchOS] |
| 84 | + include: |
| 85 | + - os: macos-14 |
| 86 | + xcode: Xcode_16.2 |
| 87 | + platform: iOS |
| 88 | + runs-on: ${{ matrix.os }} |
| 89 | + steps: |
| 90 | + - uses: actions/checkout@v4 |
| 91 | + - uses: ruby/setup-ruby@354a1ad156761f5ee2b7b13fa8e09943a5e8d252 # v1 |
| 92 | + - name: Setup Bundler |
| 93 | + run: scripts/setup_bundler.sh |
| 94 | + - name: Xcode |
| 95 | + run: sudo xcode-select -s /Applications/${{ matrix.xcode }}.app/Contents/Developer |
| 96 | + - name: Set conditional environment variable, if needed. |
| 97 | + if: inputs.product == 'FirebaseAuth' |
| 98 | + run: echo "FIREBASE_CI=true" >> $GITHUB_ENV |
| 99 | + - name: Set podspec Swift version to 6.0, if supported. |
| 100 | + if: inputs.supports_swift6 == true && matrix.os != 'macos-14' |
| 101 | + run: sed -i "" "s/s.swift_version[[:space:]]*=[[:space:]]*'5.9'/s.swift_version = '6.0'/" ${{ inputs.product }}.podspec |
| 102 | + - name: Run setup command, if needed. |
| 103 | + if: inputs.setup_command != '' |
| 104 | + run: ${{ inputs.setup_command }} |
| 105 | + - uses: nick-fields/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08 # v3 |
| 106 | + if: contains(join(inputs.platforms), matrix.platform) || matrix.os == 'macos-14' |
| 107 | + with: |
| 108 | + timeout_minutes: 120 |
| 109 | + max_attempts: 3 |
| 110 | + retry_on: error |
| 111 | + retry_wait_seconds: 120 |
| 112 | + command: | |
| 113 | + scripts/pod_lib_lint.rb ${{ inputs.product }}.podspec --platforms=${{ matrix.platform }} \ |
| 114 | + ${{ inputs.allow_warnings == true && '--allow-warnings' || '' }} \ |
| 115 | + ${{ inputs.test_specs != '' && format('--test-specs={0}', inputs.test_specs) || '' }} \ |
| 116 | + ${{ (contains(inputs.buildonly_platforms, matrix.platform) || contains(inputs.buildonly_platforms, 'all')) && '--skip-tests' || '' }} |
0 commit comments