Skip to content

Commit 0d85950

Browse files
granluoleotianlizhan
authored andcommitted
Exclude specs in spec testing. (#9240)
* Exclude specs in spec testing.
1 parent 7f3a5af commit 0d85950

File tree

3 files changed

+19
-5
lines changed

3 files changed

+19
-5
lines changed

.github/workflows/spectesting.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ jobs:
3131
# The final matrix will be set as an env var in the GHA workflow,
3232
# This env var, matrix, will be passed as a matrix in the next job of
3333
# the workflow.
34-
./scripts/health_metrics/get_updated_files.sh -p output.json
34+
# If multiple podspecs need to be excluded, escaping space is required
35+
# to split podspecs, e.g. get_updated_files.sh ... -e Firebase.podspec\ FirebaseABTesting.podspec
36+
./scripts/health_metrics/get_updated_files.sh -p output.json -e Firebase.podspec
3537
echo "::set-output name=matrix::{\"include\":$( cat output.json )}"
3638
# `podspecs` is to help determine if specs_testing job should be run.
3739
echo "::set-output name=podspecs::$(cat output.json)"

scripts/health_metrics/generate_code_coverage_report/Sources/UpdatedFilesCollector/main.swift

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ struct UpdatedFilesCollector: ParsableCommand {
5656
})
5757
var outputSDKFileURL: URL?
5858

59+
/// Exclude pods from spec testings.
60+
@Option(parsing: .upToNextOption, help: "Podspecs that will be excluded in the testings.")
61+
var excludePodspecs: [String] = []
62+
5963
func run() throws {
6064
var podspecsWithChangedFiles: [SDKPodspec] = []
6165
print("=============== list changed files ===============")
@@ -78,7 +82,13 @@ struct UpdatedFilesCollector: ParsableCommand {
7882
print("=============== paths of changed files ===============")
7983
print("::set-output name=\(sdkPatterns.sdk)_run_job::true")
8084
for podspec in sdkPatterns.podspecs {
81-
podspecsWithChangedFiles.append(SDKPodspec(podspec: podspec))
85+
if !excludePodspecs.contains(podspec) {
86+
podspecsWithChangedFiles.append(SDKPodspec(podspec: podspec))
87+
} else if let outputPath = outputSDKFileURL {
88+
print(
89+
"\(podspec) was excluded and will not be written in \(outputPath.absoluteString) "
90+
)
91+
}
8292
}
8393
print("\(sdkPatterns.sdk): \(changedFilePath) is updated under the pattern, \(pattern)")
8494
trigger_pod_test_for_coverage_report = true

scripts/health_metrics/get_updated_files.sh

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,12 @@
1515
set -ex
1616
# Updated files in paths in file_patterns.json will trigger code coverage workflows.
1717
# Updates in a pull request will generate a code coverage report in a PR.
18-
19-
while getopts p: flag
18+
exclude_specs=""
19+
while getopts "p:e:" flag
2020
do
2121
case "${flag}" in
2222
p) spec_output_file=${OPTARG};;
23+
e) exclude_specs=${OPTARG[*]};;
2324
esac
2425
done
2526

@@ -39,6 +40,7 @@ git diff --name-only remotes/origin/${GITHUB_BASE_REF} ${GITHUB_SHA} > updated_f
3940
if [ -z $spec_output_file] ; then
4041
swift run UpdatedFilesCollector --changed-file-paths updated_files.txt --code-coverage-file-patterns ../file_patterns.json
4142
else
42-
swift run UpdatedFilesCollector --changed-file-paths updated_files.txt --code-coverage-file-patterns ../file_patterns.json --output-sdk-file-url "${spec_output_file}"
43+
swift run UpdatedFilesCollector --changed-file-paths updated_files.txt --code-coverage-file-patterns ../file_patterns.json --output-sdk-file-url "${spec_output_file}" --exclude-podspecs ${exclude_specs}
44+
4345
mv "${spec_output_file}" "${dir}"
4446
fi

0 commit comments

Comments
 (0)