Skip to content

Commit 588c023

Browse files
authored
[Infra] Common cocoapods pod lib lint job (#14876)
1 parent 45d327f commit 588c023

22 files changed

+357
-678
lines changed

.github/workflows/abtesting.yml

Lines changed: 10 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
name: abtesting
22

3+
permissions:
4+
contents: read
5+
36
on:
47
workflow_dispatch:
58
pull_request:
69
paths:
710
- 'FirebaseABTesting**'
811
- 'Interop/Analytics/Public/*.h'
912
- '.github/workflows/abtesting.yml'
13+
- '.github/workflows/common.yml'
14+
- '.github/workflows/common_cocoapods.yml'
1015
- 'Gemfile*'
1116
schedule:
1217
# Run every day at 1am(PST) - cron uses UTC times
@@ -28,43 +33,10 @@ jobs:
2833
product: FirebaseABTesting
2934
target: FirebaseABTesting-Unit-unit
3035

31-
pod-lib-lint:
32-
# Don't run on private repo unless it is a PR.
33-
if: (github.repository == 'Firebase/firebase-ios-sdk' && github.event_name == 'schedule') || github.event_name == 'pull_request'
34-
35-
strategy:
36-
matrix:
37-
include:
38-
- os: macos-14
39-
xcode: Xcode_16.2
40-
target: ios
41-
- os: macos-15
42-
xcode: Xcode_16.2
43-
target: ios
44-
- os: macos-15
45-
xcode: Xcode_16.2
46-
target: tvos
47-
- os: macos-15
48-
xcode: Xcode_16.2
49-
target: macos
50-
- os: macos-15
51-
xcode: Xcode_16.2
52-
target: watchos
53-
runs-on: ${{ matrix.os }}
54-
steps:
55-
- uses: actions/checkout@v4
56-
- uses: ruby/setup-ruby@354a1ad156761f5ee2b7b13fa8e09943a5e8d252 # v1
57-
- name: Setup Bundler
58-
run: scripts/setup_bundler.sh
59-
- name: Xcode
60-
run: sudo xcode-select -s /Applications/${{ matrix.xcode }}.app/Contents/Developer
61-
- uses: nick-fields/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08 # v3
62-
with:
63-
timeout_minutes: 120
64-
max_attempts: 3
65-
retry_on: error
66-
retry_wait_seconds: 120
67-
command: scripts/pod_lib_lint.rb FirebaseABTesting.podspec --platforms=${{ matrix.target }}
36+
pod_lib_lint:
37+
uses: ./.github/workflows/common_cocoapods.yml
38+
with:
39+
product: FirebaseABTesting
6840

6941
quickstart:
7042
# Don't run on private repo unless it is a PR.
@@ -136,7 +108,7 @@ jobs:
136108
flags: [
137109
'--use-static-frameworks'
138110
]
139-
needs: pod-lib-lint
111+
needs: pod_lib_lint
140112
steps:
141113
- uses: actions/checkout@v4
142114
- uses: ruby/setup-ruby@354a1ad156761f5ee2b7b13fa8e09943a5e8d252 # v1

.github/workflows/appdistribution.yml

Lines changed: 11 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
name: appdistribution
22

3+
permissions:
4+
contents: read
5+
36
on:
47
workflow_dispatch:
58
pull_request:
69
paths:
710
- 'FirebaseAppDistribution**'
811
- '.github/workflows/appdistribution.yml'
12+
- '.github/workflows/common.yml'
13+
- '.github/workflows/common_cocoapods.yml'
914
- 'Gemfile*'
1015
schedule:
1116
# Run every day at 1am (PST) - cron uses UTC times
@@ -28,29 +33,11 @@ jobs:
2833
product: FirebaseAppDistribution
2934
target: FirebaseAppDistribution-Unit-unit
3035

31-
pod-lib-lint:
32-
# Don't run on private repo unless it is a PR.
33-
if: (github.repository == 'Firebase/firebase-ios-sdk' && github.event_name == 'schedule') || github.event_name == 'pull_request'
34-
35-
strategy:
36-
matrix:
37-
include:
38-
- os: macos-14
39-
xcode: Xcode_16.2
40-
- os: macos-15
41-
xcode: Xcode_16.3
42-
runs-on: ${{ matrix.os }}
43-
steps:
44-
- uses: actions/checkout@v4
45-
- uses: ruby/setup-ruby@354a1ad156761f5ee2b7b13fa8e09943a5e8d252 # v1
46-
- name: Setup Bundler
47-
run: scripts/setup_bundler.sh
48-
- name: Xcode
49-
run: sudo xcode-select -s /Applications/${{ matrix.xcode }}.app/Contents/Developer
50-
- name: Build and test
51-
run: |
52-
scripts/third_party/travis/retry.sh scripts/pod_lib_lint.rb FirebaseAppDistribution.podspec \
53-
--platforms=ios
36+
pod_lib_lint:
37+
uses: ./.github/workflows/common_cocoapods.yml
38+
with:
39+
product: FirebaseAppDistribution
40+
platforms: iOS # App Distro only supports iOS.
5441

5542
appdistribution-cron-only:
5643
if: github.event_name == 'schedule' && github.repository == 'Firebase/firebase-ios-sdk'
@@ -62,7 +49,7 @@ jobs:
6249
flags: [
6350
'--use-static-frameworks'
6451
]
65-
needs: pod-lib-lint
52+
needs: pod_lib_lint
6653
steps:
6754
- uses: actions/checkout@v4
6855
- uses: ruby/setup-ruby@354a1ad156761f5ee2b7b13fa8e09943a5e8d252 # v1

.github/workflows/auth.yml

Lines changed: 12 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
name: auth
22

3+
permissions:
4+
contents: read
5+
36
on:
47
workflow_dispatch:
58
pull_request:
69
paths:
710
- 'FirebaseAuth**'
811
- 'FirebaseAuth/Interop/*.h'
912
- '.github/workflows/auth.yml'
13+
- '.github/workflows/common.yml'
14+
- '.github/workflows/common_cocoapods.yml'
1015
- 'scripts/gha-encrypted/AuthSample/SwiftApplication.plist.gpg'
1116
- 'Gemfile*'
1217
schedule:
@@ -34,33 +39,14 @@ jobs:
3439
target: FirebaseAuth-Unit-unit
3540
buildonly: true
3641

37-
pod-lib-lint:
38-
# Don't run on private repo unless it is a PR.
39-
if: (github.repository == 'Firebase/firebase-ios-sdk' && github.event_name == 'schedule') || github.event_name == 'pull_request'
40-
42+
pod_lib_lint:
4143
strategy:
4244
matrix:
43-
podspec: [FirebaseAuthInterop.podspec, FirebaseAuth.podspec]
44-
target: [ios, tvos, macos --skip-tests, watchos]
45-
os: [macos-15]
46-
xcode: [Xcode_16.3]
47-
runs-on: ${{ matrix.os }}
48-
steps:
49-
- uses: actions/checkout@v4
50-
- uses: ruby/setup-ruby@354a1ad156761f5ee2b7b13fa8e09943a5e8d252 # v1
51-
- name: Setup Bundler
52-
run: scripts/setup_bundler.sh
53-
- name: Configure test keychain
54-
run: scripts/configure_test_keychain.sh
55-
- name: Xcode
56-
run: sudo xcode-select -s /Applications/${{ matrix.xcode }}.app/Contents/Developer
57-
- uses: nick-fields/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08 # v3
58-
with:
59-
timeout_minutes: 120
60-
max_attempts: 3
61-
retry_on: error
62-
retry_wait_seconds: 120
63-
command: scripts/pod_lib_lint.rb ${{ matrix.podspec }} --platforms=${{ matrix.target }} ${{ matrix.tests }}
45+
product: [FirebaseAuthInterop, FirebaseAuth]
46+
uses: ./.github/workflows/common_cocoapods.yml
47+
with:
48+
product: ${{ matrix.product }}
49+
buildonly_platforms: macOS
6450

6551
spm-package-resolved:
6652
env:
@@ -190,7 +176,7 @@ jobs:
190176
flags: [
191177
'--use-static-frameworks'
192178
]
193-
needs: pod-lib-lint
179+
needs: pod_lib_lint
194180
steps:
195181
- uses: actions/checkout@v4
196182
- uses: ruby/setup-ruby@354a1ad156761f5ee2b7b13fa8e09943a5e8d252 # v1

.github/workflows/common.yml

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,22 @@ on:
4141
required: false
4242
default: ""
4343

44+
# A command to execute before testing.
45+
#
46+
# This is useful for additional set up, like starting an emulator or
47+
# downloading test data.
48+
#
49+
# Example: `FirebaseFunctions/Backend/start.sh synchronous`
50+
setup_command:
51+
type: string
52+
required: false
53+
default: ""
54+
55+
outputs:
56+
cache_key:
57+
description: "The cache key for the Swift package resolution."
58+
value: ${{ jobs.spm-package-resolved.outputs.cache_key }}
59+
4460
jobs:
4561
spm-package-resolved:
4662
env:
@@ -54,8 +70,7 @@ jobs:
5470
run: sudo xcode-select -s /Applications/Xcode_16.2.app/Contents/Developer
5571
- name: Generate Swift Package.resolved
5672
id: swift_package_resolve
57-
run: |
58-
swift package resolve
73+
run: swift package resolve
5974
- name: Generate cache key
6075
id: generate_cache_key
6176
run: |
@@ -92,6 +107,9 @@ jobs:
92107
- name: Install visionOS, if needed.
93108
if: matrix.platform == 'visionOS'
94109
run: xcodebuild -downloadPlatform visionOS
110+
- name: Run setup command, if needed.
111+
if: inputs.setup_command != ''
112+
run: ${{ inputs.setup_command }}
95113
- name: Initialize xcodebuild
96114
run: scripts/setup_spm_tests.sh
97115
- uses: nick-fields/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08 # v3
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
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

Comments
 (0)