Skip to content

Commit 4a1f698

Browse files
authored
Add test_spec parameters for podspecs with different test_spec name. (#7731)
* Add test_spec parameters for podspecs with different test_spec name.
1 parent e22c7a7 commit 4a1f698

File tree

2 files changed

+68
-37
lines changed

2 files changed

+68
-37
lines changed

.github/workflows/test_coverage.yml

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,11 @@ jobs:
4343
./scripts/code_coverage_report/get_updated_files.sh
4444
fi
4545
46-
pod-lib-lint-database:
46+
pod-lib-lint-abtesting:
4747
needs: check
4848
# Don't run on private repo unless it is a PR.
4949
# always() will trigger this job when `needs` are skipped in a `merge` pull_request event.
50-
if: always() && github.repository == 'Firebase/firebase-ios-sdk' && (needs.check.outputs.database_run_job == 'true' || github.event.pull_request.merged)
50+
if: always() && github.repository == 'Firebase/firebase-ios-sdk' && (needs.check.outputs.abtesting_run_job == 'true'|| github.event.pull_request.merged)
5151
runs-on: macOS-latest
5252
strategy:
5353
matrix:
@@ -57,16 +57,16 @@ jobs:
5757
- name: Setup Bundler
5858
run: scripts/setup_bundler.sh
5959
- name: Build and test
60-
run: ./scripts/code_coverage_report/pod_test_code_coverage_report.sh FirebaseDatabase "${{ matrix.target }}"
60+
run: ./scripts/code_coverage_report/pod_test_code_coverage_report.sh --sdk=FirebaseABTesting --platform=${{ matrix.target }}
6161
- uses: actions/upload-artifact@v2
6262
with:
6363
name: codecoverage
6464
path: /Users/runner/*.xcresult
6565

66-
pod-lib-lint-functions:
66+
pod-lib-lint-auth:
6767
needs: check
6868
# Don't run on private repo unless it is a PR.
69-
if: always() && github.repository == 'Firebase/firebase-ios-sdk' && (needs.check.outputs.functions_run_job == 'true'|| github.event.pull_request.merged)
69+
if: always() && github.repository == 'Firebase/firebase-ios-sdk' && (needs.check.outputs.auth_run_job == 'true'|| github.event.pull_request.merged)
7070
runs-on: macOS-latest
7171
strategy:
7272
matrix:
@@ -76,16 +76,16 @@ jobs:
7676
- name: Setup Bundler
7777
run: scripts/setup_bundler.sh
7878
- name: Build and test
79-
run: ./scripts/code_coverage_report/pod_test_code_coverage_report.sh FirebaseFunctions "${{ matrix.target }}"
79+
run: ./scripts/code_coverage_report/pod_test_code_coverage_report.sh --sdk=FirebaseAuth --platform=${{ matrix.target }}
8080
- uses: actions/upload-artifact@v2
8181
with:
8282
name: codecoverage
8383
path: /Users/runner/*.xcresult
8484

85-
pod-lib-lint-abtesting:
85+
pod-lib-lint-database:
8686
needs: check
8787
# Don't run on private repo unless it is a PR.
88-
if: always() && github.repository == 'Firebase/firebase-ios-sdk' && (needs.check.outputs.abtesting_run_job == 'true'|| github.event.pull_request.merged)
88+
if: always() && github.repository == 'Firebase/firebase-ios-sdk' && (needs.check.outputs.database_run_job == 'true' || github.event.pull_request.merged)
8989
runs-on: macOS-latest
9090
strategy:
9191
matrix:
@@ -95,16 +95,16 @@ jobs:
9595
- name: Setup Bundler
9696
run: scripts/setup_bundler.sh
9797
- name: Build and test
98-
run: ./scripts/code_coverage_report/pod_test_code_coverage_report.sh FirebaseABTesting "${{ matrix.target }}"
98+
run: ./scripts/code_coverage_report/pod_test_code_coverage_report.sh --sdk=FirebaseDatabase --platform=${{ matrix.target }}
9999
- uses: actions/upload-artifact@v2
100100
with:
101101
name: codecoverage
102102
path: /Users/runner/*.xcresult
103103

104-
pod-lib-lint-auth:
104+
pod-lib-lint-dynamiclinks:
105105
needs: check
106106
# Don't run on private repo unless it is a PR.
107-
if: always() && github.repository == 'Firebase/firebase-ios-sdk' && (needs.check.outputs.auth_run_job == 'true'|| github.event.pull_request.merged)
107+
if: always() && github.repository == 'Firebase/firebase-ios-sdk' && (needs.check.outputs.dynamiclinks_run_job == 'true'|| github.event.pull_request.merged)
108108
runs-on: macOS-latest
109109
strategy:
110110
matrix:
@@ -114,16 +114,17 @@ jobs:
114114
- name: Setup Bundler
115115
run: scripts/setup_bundler.sh
116116
- name: Build and test
117-
run: ./scripts/code_coverage_report/pod_test_code_coverage_report.sh FirebaseAuth "${{ matrix.target }}"
117+
run: ./scripts/code_coverage_report/pod_test_code_coverage_report.sh --sdk=FirebaseDynamicLinks --platform=${{ matrix.target }}
118118
- uses: actions/upload-artifact@v2
119119
with:
120120
name: codecoverage
121121
path: /Users/runner/*.xcresult
122122

123-
pod-lib-lint-dynamiclinks:
123+
pod-lib-lint-firestore:
124124
needs: check
125125
# Don't run on private repo unless it is a PR.
126-
if: always() && github.repository == 'Firebase/firebase-ios-sdk' && (needs.check.outputs.dynamiclinks_run_job == 'true'|| github.event.pull_request.merged)
126+
# Disable Firestore for now since Firestore currently does not have unit tests in podspecs.
127+
if: always() && github.repository == 'Firebase/firebase-ios-sdk' && (needs.check.outputs.firestore_run_job == 'true'|| github.event.pull_request.merged)
127128
runs-on: macOS-latest
128129
strategy:
129130
matrix:
@@ -133,17 +134,16 @@ jobs:
133134
- name: Setup Bundler
134135
run: scripts/setup_bundler.sh
135136
- name: Build and test
136-
run: ./scripts/code_coverage_report/pod_test_code_coverage_report.sh FirebaseDynamicLinks "${{ matrix.target }}"
137+
run: ./scripts/code_coverage_report/pod_test_code_coverage_report.sh --sdk=FirebaseFirestore --platform=${{ matrix.target }}
137138
- uses: actions/upload-artifact@v2
138139
with:
139140
name: codecoverage
140141
path: /Users/runner/*.xcresult
141142

142-
pod-lib-lint-firestore:
143+
pod-lib-lint-functions:
143144
needs: check
144145
# Don't run on private repo unless it is a PR.
145-
# Disable Firestore for now since Firestore currently does not have unit tests in podspecs.
146-
if: always() && github.repository == 'Firebase/firebase-ios-sdk' && (needs.check.outputs.firestore_run_job == 'true'|| github.event.pull_request.merged)
146+
if: always() && github.repository == 'Firebase/firebase-ios-sdk' && (needs.check.outputs.functions_run_job == 'true'|| github.event.pull_request.merged)
147147
runs-on: macOS-latest
148148
strategy:
149149
matrix:
@@ -153,7 +153,7 @@ jobs:
153153
- name: Setup Bundler
154154
run: scripts/setup_bundler.sh
155155
- name: Build and test
156-
run: ./scripts/code_coverage_report/pod_test_code_coverage_report.sh FirebaseFirestore "${{ matrix.target }}"
156+
run: ./scripts/code_coverage_report/pod_test_code_coverage_report.sh --sdk=FirebaseFunctions --platform=${{ matrix.target }}
157157
- uses: actions/upload-artifact@v2
158158
with:
159159
name: codecoverage
@@ -172,7 +172,7 @@ jobs:
172172
- name: Setup Bundler
173173
run: scripts/setup_bundler.sh
174174
- name: Build and test
175-
run: ./scripts/code_coverage_report/pod_test_code_coverage_report.sh FirebaseInAppMessaging "${{ matrix.target }}"
175+
run: ./scripts/code_coverage_report/pod_test_code_coverage_report.sh --sdk=FirebaseInAppMessaging --platform=${{ matrix.target }}
176176
- uses: actions/upload-artifact@v2
177177
with:
178178
name: codecoverage
@@ -191,7 +191,7 @@ jobs:
191191
- name: Setup Bundler
192192
run: scripts/setup_bundler.sh
193193
- name: Build and test
194-
run: ./scripts/code_coverage_report/pod_test_code_coverage_report.sh FirebaseInstanceID "${{ matrix.target }}"
194+
run: ./scripts/code_coverage_report/pod_test_code_coverage_report.sh --sdk=FirebaseInstanceID --platform=${{ matrix.target }}
195195
- uses: actions/upload-artifact@v2
196196
with:
197197
name: codecoverage
@@ -210,7 +210,7 @@ jobs:
210210
- name: Setup Bundler
211211
run: scripts/setup_bundler.sh
212212
- name: Build and test
213-
run: ./scripts/code_coverage_report/pod_test_code_coverage_report.sh FirebaseMessaging "${{ matrix.target }}"
213+
run: ./scripts/code_coverage_report/pod_test_code_coverage_report.sh --sdk=FirebaseMessaging --platform=${{ matrix.target }}
214214
- uses: actions/upload-artifact@v2
215215
with:
216216
name: codecoverage
@@ -229,7 +229,7 @@ jobs:
229229
- name: Setup Bundler
230230
run: scripts/setup_bundler.sh
231231
- name: Build and test
232-
run: ./scripts/code_coverage_report/pod_test_code_coverage_report.sh FirebasePerformance "${{ matrix.target }}"
232+
run: ./scripts/code_coverage_report/pod_test_code_coverage_report.sh --sdk=FirebasePerformance --platform=${{ matrix.target }}
233233
- uses: actions/upload-artifact@v2
234234
with:
235235
name: codecoverage
@@ -248,7 +248,7 @@ jobs:
248248
- name: Setup Bundler
249249
run: scripts/setup_bundler.sh
250250
- name: Build and test
251-
run: ./scripts/code_coverage_report/pod_test_code_coverage_report.sh FirebaseRemoteConfig "${{ matrix.target }}"
251+
run: ./scripts/code_coverage_report/pod_test_code_coverage_report.sh --sdk=FirebaseRemoteConfig --platform=${{ matrix.target }}
252252
- uses: actions/upload-artifact@v2
253253
with:
254254
name: codecoverage
@@ -267,7 +267,7 @@ jobs:
267267
- name: Setup Bundler
268268
run: scripts/setup_bundler.sh
269269
- name: Build and test
270-
run: ./scripts/code_coverage_report/pod_test_code_coverage_report.sh FirebaseStorage "${{ matrix.target }}"
270+
run: ./scripts/code_coverage_report/pod_test_code_coverage_report.sh --sdk=FirebaseStorage --platform=${{ matrix.target }}
271271
- uses: actions/upload-artifact@v2
272272
with:
273273
name: codecoverage

scripts/code_coverage_report/pod_test_code_coverage_report.sh

Lines changed: 43 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,27 +14,58 @@
1414

1515
set -ex
1616

17-
SDK="$1"
18-
platform="$2"
19-
default_output_path="/Users/runner/${SDK}-${platform}.xcresult"
20-
output_path="${3:-${default_output_path}}"
17+
# Loop through arguments and process them
18+
for arg in "$@"
19+
do
20+
case $arg in
21+
--sdk=*)
22+
SDK="${arg#*=}"
23+
shift # Remove --sdk= from processing
24+
;;
25+
--platform=*)
26+
PLATFORM="${arg#*=}"
27+
shift
28+
;;
29+
--test_spec=*)
30+
TEST_SPEC="${arg#*=}"
31+
shift
32+
;;
33+
--output_path=*)
34+
OUTPUT_PATH="${arg#*=}"
35+
shift
36+
;;
37+
esac
38+
done
39+
DEFAULT_OUTPUT_PATH="/Users/runner/${SDK}-${PLATFORM}.xcresult"
40+
DEFAULT_TEST_SPEC="unit"
41+
OUTPUT_PATH="${OUTPUT_PATH:-${DEFAULT_OUTPUT_PATH}}"
42+
TEST_SPEC="${TEST_SPEC:-${DEFAULT_TEST_SPEC}}"
43+
44+
[[ -z "$SDK" ]] && { echo "Parameter --sdk should be specified, e.g. --sdk=FirebaseStorage" ; exit 1; }
45+
[[ -z "$PLATFORM" ]] && { echo "Parameter --platform should be specified, e.g. --platform=ios" ; exit 1; }
46+
47+
echo "SDK: ${SDK}"
48+
echo "PLATFORM: ${PLATFORM}"
49+
echo "OUTPUT_PATH: ${OUTPUT_PATH}"
50+
echo "TEST_SPEC: ${TEST_SPEC}"
51+
2152
if [ -d "/Users/runner/Library/Developer/Xcode/DerivedData" ]; then
22-
rm -r /Users/runner/Library/Developer/Xcode/DerivedData/*
53+
rm -r /Users/runner/Library/Developer/Xcode/DerivedData/*
2354
fi
2455

2556
# Setup for pod unit tests
2657
if [ $SDK == "FirebasePerformance" ]; then
2758
scripts/setup_bundler.sh
28-
scripts/third_party/travis/retry.sh scripts/build.sh Performance ${platform} unit
59+
scripts/third_party/travis/retry.sh scripts/build.sh Performance ${PLATFORM} unit
2960
elif [ $SDK == "FirebaseFirestore" ]; then
30-
scripts/install_prereqs.sh Firestore ${platform} xcodebuild
31-
scripts/third_party/travis/retry.sh scripts/build.sh Firestore ${platform} xcodebuild
61+
scripts/install_prereqs.sh Firestore ${PLATFORM} xcodebuild
62+
scripts/third_party/travis/retry.sh scripts/build.sh Firestore ${PLATFORM} xcodebuild
3263
else
33-
# Run unit tests of pods and put xcresult bundles into output_path, which
64+
# Run unit tests of pods and put xcresult bundles into OUTPUT_PATH, which
3465
# should be a targeted dir of actions/upload-artifact in workflows.
35-
# In code coverage workflow, files under output_path will be uploaded to
66+
# In code coverage workflow, files under OUTPUT_PATH will be uploaded to
3667
# Github Actions.
37-
scripts/third_party/travis/retry.sh scripts/pod_lib_lint.rb "${SDK}".podspec --platforms="$(tr '[:upper:]' '[:lower:]'<<<${platform})" --test-specs=unit
68+
scripts/third_party/travis/retry.sh scripts/pod_lib_lint.rb "${SDK}".podspec --platforms="$(tr '[:upper:]' '[:lower:]'<<<${PLATFORM})" --test-specs="${TEST_SPEC}"
3869
fi
3970

40-
find /Users/runner/Library/Developer/Xcode/DerivedData -type d -regex ".*/.*\.xcresult" -execdir cp -R '{}' "${output_path}" \;
71+
find /Users/runner/Library/Developer/Xcode/DerivedData -type d -regex ".*/.*\.xcresult" -execdir cp -R '{}' "${OUTPUT_PATH}" \;

0 commit comments

Comments
 (0)