Skip to content

Commit a8fbda0

Browse files
feat: add new reusable workflow, _build.yml (#15762)
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
1 parent 26ecb4b commit a8fbda0

17 files changed

+349
-444
lines changed

.github/workflows/_build.yml

Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
name: _build
2+
3+
permissions:
4+
contents: read
5+
6+
on:
7+
workflow_call:
8+
inputs:
9+
product:
10+
required: true
11+
type: string
12+
platform:
13+
required: true
14+
type: string
15+
method:
16+
required: true
17+
type: string
18+
sanitizers:
19+
required: false
20+
type: string
21+
description: "Space-separated list of sanitizers (asan, tsan, ubsan)"
22+
setup_command:
23+
required: false
24+
type: string
25+
description: "Command to run before build (e.g., for setting up secrets or prerequisites)"
26+
xcode:
27+
required: false
28+
type: string
29+
default: 'Xcode_16.4'
30+
os:
31+
required: false
32+
type: string
33+
default: 'macos-15'
34+
timeout_minutes:
35+
required: false
36+
type: number
37+
default: 120
38+
max_attempts:
39+
required: false
40+
type: number
41+
default: 3
42+
43+
# IMPORTANT: When adding new secrets to this workflow, update the
44+
# 'has_secrets' logic in the 'check_secrets' job to include the new secret.
45+
secrets:
46+
plist_secret:
47+
required: false
48+
49+
jobs:
50+
check_secrets:
51+
runs-on: ubuntu-latest
52+
outputs:
53+
should_run: ${{ steps.determine_run.outputs.should_run }}
54+
has_secrets: ${{ steps.determine_run.outputs.has_secrets }}
55+
env:
56+
plist_secret: ${{ secrets.plist_secret }}
57+
steps:
58+
- name: Determine if build should run and if secrets are present
59+
id: determine_run
60+
run: |
61+
# 1. Check for secrets.
62+
# - IMPORTANT: Extend this logic if adding new secrets.
63+
if [[ -n "$plist_secret" ]]; then
64+
has_secrets="true"
65+
else
66+
has_secrets="false"
67+
fi
68+
echo "has_secrets=$has_secrets" >> $GITHUB_OUTPUT
69+
70+
# 2. Determine if the build job should run.
71+
# - Skip if on a fork AND secrets are present.
72+
repo_full_name=$(echo "${{ github.repository }}" | tr '[:upper:]' '[:lower:]')
73+
if [[ "$repo_full_name" != "firebase/firebase-ios-sdk" && "$has_secrets" == "true" ]]; then
74+
echo "should_run=false" >> $GITHUB_OUTPUT
75+
else
76+
echo "should_run=true" >> $GITHUB_OUTPUT
77+
fi
78+
79+
build:
80+
needs: check_secrets
81+
# Run on the main repo's scheduled jobs or pull requests and manual workflow invocations.
82+
if: |
83+
needs.check_secrets.outputs.should_run == 'true' &&
84+
(
85+
(github.repository == 'firebase/firebase-ios-sdk' && github.event_name == 'schedule') ||
86+
contains(fromJSON('["pull_request", "workflow_dispatch"]'), github.event_name)
87+
)
88+
runs-on: ${{ inputs.os }}
89+
env:
90+
SANITIZERS: ${{ inputs.sanitizers }}
91+
plist_secret: ${{ secrets.plist_secret }}
92+
FIREBASECI_SECRETS_PRESENT: ${{ needs.check_secrets.outputs.has_secrets }}
93+
FIREBASECI_IS_TRUSTED_ENV: ${{ github.repository == 'firebase/firebase-ios-sdk' && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository) }}
94+
FIREBASECI_USE_LATEST_GOOGLEAPPMEASUREMENT: 1
95+
steps:
96+
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
97+
- uses: ruby/setup-ruby@354a1ad156761f5ee2b7b13fa8e09943a5e8d252 # v1
98+
if: inputs.method != 'spm' && inputs.method != 'spmbuildonly' && inputs.method != 'cmake'
99+
- name: Setup Bundler
100+
if: inputs.method != 'spm' && inputs.method != 'spmbuildonly' && inputs.method != 'cmake'
101+
uses: nick-fields/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08 # v3
102+
with:
103+
timeout_minutes: 10
104+
max_attempts: 5
105+
retry_wait_seconds: 300
106+
command: scripts/setup_bundler.sh
107+
- name: Xcode
108+
run: sudo xcode-select -s /Applications/${{ inputs.xcode }}.app/Contents/Developer
109+
- name: Install simulators
110+
if: inputs.platform != 'macOS' && inputs.platform != 'catalyst'
111+
uses: nick-fields/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08 # v3
112+
with:
113+
timeout_minutes: 15
114+
max_attempts: 5
115+
retry_wait_seconds: 120
116+
continue_on_error: true
117+
command: |
118+
if [[ "${{ inputs.platform }}" == "all" ]]; then
119+
xcodebuild -downloadAllPlatforms
120+
else
121+
xcodebuild -downloadPlatform ${{ inputs.platform }}
122+
fi
123+
- name: Run setup command
124+
if: inputs.setup_command != ''
125+
run: ${{ inputs.setup_command }}
126+
- name: Build
127+
uses: nick-fields/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08 # v3
128+
with:
129+
timeout_minutes: ${{ inputs.timeout_minutes }}
130+
max_attempts: ${{ inputs.max_attempts }}
131+
retry_wait_seconds: 120
132+
command: |
133+
scripts/build.sh "${{ inputs.product }}" "${{ inputs.platform }}" "${{ inputs.method }}"
134+
- uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
135+
if: ${{ failure() }}
136+
with:
137+
name: xcodebuild-logs-${{ inputs.product }}-${{ inputs.platform }}-${{ inputs.method }}
138+
path: xcodebuild-*.log
139+
if-no-files-found: error
Lines changed: 37 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
name: infra.samples.client_app
22

3+
permissions:
4+
contents: read
5+
36
on:
47
workflow_dispatch:
58
pull_request:
@@ -25,7 +28,6 @@ concurrency:
2528

2629
jobs:
2730
client-app-spm:
28-
if: (github.repository == 'Firebase/firebase-ios-sdk' && github.event_name == 'schedule') || github.event_name == 'pull_request'
2931
strategy:
3032
matrix:
3133
#TODO(ncooke3): Add multi-platform support: tvOS, macOS, catalyst
@@ -37,41 +39,36 @@ jobs:
3739
xcode: Xcode_16.2
3840
- os: macos-15
3941
xcode: Xcode_16.4
40-
runs-on: ${{ matrix.os }}
41-
steps:
42-
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
43-
- name: Xcode
44-
run: sudo xcode-select -s /Applications/${{ matrix.xcode }}.app/Contents/Developer
45-
- name: Build Client App - ${{ matrix.platform }}
46-
run: scripts/third_party/travis/retry.sh ./scripts/build.sh ${{ matrix.scheme }} ${{ matrix.platform }} xcodebuild
42+
uses: ./.github/workflows/_build.yml
43+
with:
44+
product: ${{ matrix.scheme }}
45+
platform: ${{ matrix.platform }}
46+
method: xcodebuild
47+
os: ${{ matrix.os }}
48+
xcode: ${{ matrix.xcode }}
4749

4850
client-app-spm-source-firestore:
49-
if: (github.repository == 'Firebase/firebase-ios-sdk' && github.event_name == 'schedule') || github.event_name == 'pull_request'
50-
env:
51-
FIREBASECI_USE_LATEST_GOOGLEAPPMEASUREMENT: 1
52-
FIREBASE_SOURCE_FIRESTORE: 1
53-
strategy:
54-
matrix:
55-
#TODO(ncooke3): Add multi-platform support: tvOS, macOS, catalyst
56-
platform: [iOS]
57-
scheme: [ClientApp]
58-
os: [macos-14, macos-15]
59-
include:
60-
- os: macos-14
61-
xcode: Xcode_16.2
62-
- os: macos-15
63-
xcode: Xcode_16.4
64-
runs-on: ${{ matrix.os }}
65-
steps:
66-
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
67-
- name: Xcode
68-
run: sudo xcode-select -s /Applications/${{ matrix.xcode }}.app/Contents/Developer
69-
- name: Build Client App - ${{ matrix.platform }}
70-
run: scripts/third_party/travis/retry.sh ./scripts/build.sh ${{ matrix.scheme }} ${{ matrix.platform }} xcodebuild
51+
strategy:
52+
matrix:
53+
#TODO(ncooke3): Add multi-platform support: tvOS, macOS, catalyst
54+
platform: [iOS]
55+
scheme: [ClientApp]
56+
os: [macos-14, macos-15]
57+
include:
58+
- os: macos-14
59+
xcode: Xcode_16.2
60+
- os: macos-15
61+
xcode: Xcode_16.4
62+
uses: ./.github/workflows/_build.yml
63+
with:
64+
product: ${{ matrix.scheme }}
65+
platform: ${{ matrix.platform }}
66+
method: xcodebuild
67+
os: ${{ matrix.os }}
68+
xcode: ${{ matrix.xcode }}
69+
setup_command: echo "FIREBASE_SOURCE_FIRESTORE=1" >> $GITHUB_ENV
7170

7271
client-app-cocoapods:
73-
# Don't run on private repo unless it is a PR.
74-
if: (github.repository == 'Firebase/firebase-ios-sdk' && github.event_name == 'schedule') || github.event_name == 'pull_request'
7572
strategy:
7673
matrix:
7774
scheme: [ClientApp-CocoaPods]
@@ -81,15 +78,11 @@ jobs:
8178
xcode: Xcode_16.2
8279
- os: macos-15
8380
xcode: Xcode_16.4
84-
runs-on: ${{ matrix.os }}
85-
steps:
86-
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
87-
- uses: ruby/setup-ruby@354a1ad156761f5ee2b7b13fa8e09943a5e8d252 # v1
88-
- name: Setup Bundler
89-
run: scripts/setup_bundler.sh
90-
- name: Xcode
91-
run: sudo xcode-select -s /Applications/${{ matrix.xcode }}.app/Contents/Developer
92-
- name: Prereqs
93-
run: scripts/install_prereqs.sh ClientApp iOS xcodebuild
94-
- name: Build
95-
run: scripts/build.sh ${{ matrix.scheme }} iOS xcodebuild
81+
uses: ./.github/workflows/_build.yml
82+
with:
83+
product: ${{ matrix.scheme }}
84+
platform: iOS
85+
method: xcodebuild
86+
os: ${{ matrix.os }}
87+
xcode: ${{ matrix.xcode }}
88+
setup_command: scripts/install_prereqs.sh ClientApp iOS xcodebuild
Lines changed: 9 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
name: infra.samples.symbolcollision
22

3+
permissions:
4+
contents: read
5+
36
# Tests the Pods listed in SymbolCollisionTest/Podfile for symbol collisions.
47

58
on:
@@ -19,25 +22,9 @@ concurrency:
1922

2023
jobs:
2124
installation-test:
22-
# Don't run on private repo unless it is a PR.
23-
if: github.repository == 'Firebase/firebase-ios-sdk' || github.event_name == 'pull_request'
24-
runs-on: macos-15
25-
26-
steps:
27-
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
28-
- uses: ruby/setup-ruby@354a1ad156761f5ee2b7b13fa8e09943a5e8d252 # v1
29-
- name: Setup Bundler
30-
run: scripts/setup_bundler.sh
31-
- name: Xcode
32-
run: sudo xcode-select -s /Applications/Xcode_16.4.app/Contents/Developer
33-
- name: Install simulators in case they are missing.
34-
uses: nick-fields/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08 # v3
35-
with:
36-
timeout_minutes: 15
37-
max_attempts: 5
38-
retry_wait_seconds: 120
39-
command: sudo xcodebuild -downloadPlatform iOS
40-
- name: Prereqs
41-
run: scripts/install_prereqs.sh SymbolCollision iOS
42-
- name: Build
43-
run: scripts/build.sh SymbolCollision iOS
25+
uses: ./.github/workflows/_build.yml
26+
with:
27+
product: SymbolCollision
28+
platform: iOS
29+
method: xcodebuild
30+
setup_command: scripts/install_prereqs.sh SymbolCollision iOS

.github/workflows/sdk.appcheck.yml

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -43,30 +43,20 @@ jobs:
4343
product: [FirebaseAppCheckInterop, FirebaseAppCheck]
4444
uses: ./.github/workflows/_cocoapods.yml
4545
with:
46-
product: ${{ matrix.product }}
46+
product: ${{ matrix.product }}
4747
buildonly_platforms: macOS
4848

4949
diagnostics:
50-
# Don't run on private repo unless it is a PR.
51-
if: (github.repository == 'Firebase/firebase-ios-sdk' && github.event_name == 'schedule') || github.event_name == 'pull_request'
52-
runs-on: macos-15
5350
strategy:
5451
matrix:
5552
diagnostic: [tsan, asan, ubsan]
56-
steps:
57-
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
58-
- name: Xcode
59-
run: sudo xcode-select -s /Applications/Xcode_16.4.app/Contents/Developer
60-
- name: Initialize xcodebuild
61-
run: scripts/setup_spm_tests.sh
62-
- name: iOS Unit Tests
63-
run: scripts/third_party/travis/retry.sh ./scripts/build.sh FirebaseAppCheckUnit iOS spm ${{ matrix.diagnostic }}
64-
- name: Upload raw logs if failed
65-
if: ${{ failure() }}
66-
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
67-
with:
68-
name: failure-xcodebuild-raw-logs
69-
path: xcodebuild.log
53+
uses: ./.github/workflows/_build.yml
54+
with:
55+
product: FirebaseAppCheckUnit
56+
platform: iOS
57+
method: spm
58+
sanitizers: ${{ matrix.diagnostic }}
59+
setup_command: scripts/setup_spm_tests.sh
7060

7161
app_check-cron-only:
7262
needs: pod_lib_lint

.github/workflows/sdk.auth.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ jobs:
9292
timeout_minutes: 15
9393
max_attempts: 5
9494
retry_wait_seconds: 120
95-
command: sudo xcodebuild -downloadPlatform iOS
95+
command: xcodebuild -downloadPlatform iOS
9696
- uses: nick-fields/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08 # v3
9797
with:
9898
timeout_minutes: 15

0 commit comments

Comments
 (0)