Skip to content

Commit

Permalink
Add multiple workflows for coverage tests. (#7470)
Browse files Browse the repository at this point in the history
Add all SDKs to code coverage workflows.
Limit report to only frameworks and exclude xctest etc.
  • Loading branch information
granluo authored Feb 8, 2021
1 parent 9fadbaf commit 025eecd
Show file tree
Hide file tree
Showing 3 changed files with 320 additions and 7 deletions.
202 changes: 201 additions & 1 deletion .github/workflows/test_coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,18 @@ jobs:
if: github.repository == 'Firebase/firebase-ios-sdk' && (github.event.action == 'opened' || github.event.action == 'synchronize')
name: Check changed files
outputs:
abtesting_run_job: ${{ steps.check_files.outputs.abtesting_run_job }}
auth_run_job: ${{ steps.check_files.outputs.auth_run_job }}
database_run_job: ${{ steps.check_files.outputs.database_run_job }}
dynamiclinks_run_job: ${{ steps.check_files.outputs.dynamiclinks_run_job }}
firestore_run_job: ${{ steps.check_files.outputs.firestore_run_job }}
functions_run_job: ${{ steps.check_files.outputs.functions_run_job }}
inappmessaging_run_job: ${{ steps.check_files.outputs.inappmessaging_run_job }}
instanceid_run_job: ${{ steps.check_files.outputs.instanceid_run_job }}
messaging_run_job: ${{ steps.check_files.outputs.messaging_run_job }}
performance_run_job: ${{ steps.check_files.outputs.performance_run_job }}
remoteconfig_run_job: ${{ steps.check_files.outputs.remoteconfig_run_job }}
storage_run_job: ${{ steps.check_files.outputs.storage_run_job }}
base_commit: ${{ steps.check_files.outputs.base_commit }}
runs-on: ubuntu-latest
steps:
Expand Down Expand Up @@ -66,8 +76,198 @@ jobs:
name: codecoverage
path: /Users/runner/*.xcresult

pod-lib-lint-abtesting:
needs: check
# Don't run on private repo unless it is a PR.
if: always() && github.repository == 'Firebase/firebase-ios-sdk' && (needs.check.outputs.abtesting_run_job == 'true'|| github.event.pull_request.merged)
runs-on: macOS-latest
strategy:
matrix:
target: [ios]
steps:
- uses: actions/checkout@v2
- name: Setup Bundler
run: scripts/setup_bundler.sh
- name: Build and test
run: ./scripts/code_coverage_report/pod_test_code_coverage_report.sh FirebaseABTesting "${{ matrix.target }}"
- uses: actions/upload-artifact@v2
with:
name: codecoverage
path: /Users/runner/*.xcresult

pod-lib-lint-auth:
needs: check
# Don't run on private repo unless it is a PR.
if: always() && github.repository == 'Firebase/firebase-ios-sdk' && (needs.check.outputs.auth_run_job == 'true'|| github.event.pull_request.merged)
runs-on: macOS-latest
strategy:
matrix:
target: [ios]
steps:
- uses: actions/checkout@v2
- name: Setup Bundler
run: scripts/setup_bundler.sh
- name: Build and test
run: ./scripts/code_coverage_report/pod_test_code_coverage_report.sh FirebaseAuth "${{ matrix.target }}"
- uses: actions/upload-artifact@v2
with:
name: codecoverage
path: /Users/runner/*.xcresult

pod-lib-lint-dynamiclinks:
needs: check
# Don't run on private repo unless it is a PR.
if: always() && github.repository == 'Firebase/firebase-ios-sdk' && (needs.check.outputs.dynamiclinks_run_job == 'true'|| github.event.pull_request.merged)
runs-on: macOS-latest
strategy:
matrix:
target: [ios]
steps:
- uses: actions/checkout@v2
- name: Setup Bundler
run: scripts/setup_bundler.sh
- name: Build and test
run: ./scripts/code_coverage_report/pod_test_code_coverage_report.sh FirebaseDynamicLinks "${{ matrix.target }}"
- uses: actions/upload-artifact@v2
with:
name: codecoverage
path: /Users/runner/*.xcresult

pod-lib-lint-firestore:
needs: check
# Don't run on private repo unless it is a PR.
if: always() && github.repository == 'Firebase/firebase-ios-sdk' && (needs.check.outputs.firestore_run_job == 'true'|| github.event.pull_request.merged)
runs-on: macOS-latest
strategy:
matrix:
target: [ios]
steps:
- uses: actions/checkout@v2
- name: Setup Bundler
run: scripts/setup_bundler.sh
- name: Build and test
run: ./scripts/code_coverage_report/pod_test_code_coverage_report.sh FirebaseFirestore "${{ matrix.target }}"
- uses: actions/upload-artifact@v2
with:
name: codecoverage
path: /Users/runner/*.xcresult

pod-lib-lint-inappmessaging:
needs: check
# Don't run on private repo unless it is a PR.
if: always() && github.repository == 'Firebase/firebase-ios-sdk' && (needs.check.outputs.inappmessaging_run_job == 'true'|| github.event.pull_request.merged)
runs-on: macOS-latest
strategy:
matrix:
target: [ios]
steps:
- uses: actions/checkout@v2
- name: Setup Bundler
run: scripts/setup_bundler.sh
- name: Build and test
run: ./scripts/code_coverage_report/pod_test_code_coverage_report.sh FirebaseInAppMessaging "${{ matrix.target }}"
- uses: actions/upload-artifact@v2
with:
name: codecoverage
path: /Users/runner/*.xcresult

pod-lib-lint-instanceid:
needs: check
# Don't run on private repo unless it is a PR.
if: always() && github.repository == 'Firebase/firebase-ios-sdk' && (needs.check.outputs.instanceid_run_job == 'true'|| github.event.pull_request.merged)
runs-on: macOS-latest
strategy:
matrix:
target: [ios]
steps:
- uses: actions/checkout@v2
- name: Setup Bundler
run: scripts/setup_bundler.sh
- name: Build and test
run: ./scripts/code_coverage_report/pod_test_code_coverage_report.sh FirebaseInstanceID "${{ matrix.target }}"
- uses: actions/upload-artifact@v2
with:
name: codecoverage
path: /Users/runner/*.xcresult

pod-lib-lint-messaging:
needs: check
# Don't run on private repo unless it is a PR.
if: always() && github.repository == 'Firebase/firebase-ios-sdk' && (needs.check.outputs.messaging_run_job == 'true'|| github.event.pull_request.merged)
runs-on: macOS-latest
strategy:
matrix:
target: [ios]
steps:
- uses: actions/checkout@v2
- name: Setup Bundler
run: scripts/setup_bundler.sh
- name: Build and test
run: ./scripts/code_coverage_report/pod_test_code_coverage_report.sh FirebaseMessaging "${{ matrix.target }}"
- uses: actions/upload-artifact@v2
with:
name: codecoverage
path: /Users/runner/*.xcresult

pod-lib-lint-performance:
needs: check
# Don't run on private repo unless it is a PR.
if: always() && github.repository == 'Firebase/firebase-ios-sdk' && (needs.check.outputs.performance_run_job == 'true'|| github.event.pull_request.merged)
runs-on: macOS-latest
strategy:
matrix:
target: [ios]
steps:
- uses: actions/checkout@v2
- name: Setup Bundler
run: scripts/setup_bundler.sh
- name: Build and test
run: ./scripts/code_coverage_report/pod_test_code_coverage_report.sh FirebasePerformance "${{ matrix.target }}"
- uses: actions/upload-artifact@v2
with:
name: codecoverage
path: /Users/runner/*.xcresult

pod-lib-lint-remoteconfig:
needs: check
# Don't run on private repo unless it is a PR.
if: always() && github.repository == 'Firebase/firebase-ios-sdk' && (needs.check.outputs.remoteconfig_run_job == 'true'|| github.event.pull_request.merged)
runs-on: macOS-latest
strategy:
matrix:
target: [ios]
steps:
- uses: actions/checkout@v2
- name: Setup Bundler
run: scripts/setup_bundler.sh
- name: Build and test
run: ./scripts/code_coverage_report/pod_test_code_coverage_report.sh FirebaseRemoteConfig "${{ matrix.target }}"
- uses: actions/upload-artifact@v2
with:
name: codecoverage
path: /Users/runner/*.xcresult

pod-lib-lint-storage:
needs: check
# Don't run on private repo unless it is a PR.
if: always() && github.repository == 'Firebase/firebase-ios-sdk' && (needs.check.outputs.storage_run_job == 'true'|| github.event.pull_request.merged)
runs-on: macOS-latest
strategy:
matrix:
target: [ios]
steps:
- uses: actions/checkout@v2
- name: Setup Bundler
run: scripts/setup_bundler.sh
- name: Build and test
run: ./scripts/code_coverage_report/pod_test_code_coverage_report.sh FirebaseStorage "${{ matrix.target }}"
- uses: actions/upload-artifact@v2
with:
name: codecoverage
path: /Users/runner/*.xcresult

create_report:
needs: [check, pod-lib-lint-functions, pod-lib-lint-database]
needs: [check, pod-lib-lint-abtesting, pod-lib-lint-auth, pod-lib-lint-database, pod-lib-lint-dynamiclinks, pod-lib-lint-firestore, pod-lib-lint-functions, pod-lib-lint-inappmessaging, pod-lib-lint-instanceid, pod-lib-lint-messaging, pod-lib-lint-performance, pod-lib-lint-remoteconfig, pod-lib-lint-storage]
env:
metrics_service_secret: ${{ secrets.GHASecretsGPGPassphrase1 }}
if: always()
Expand Down
114 changes: 112 additions & 2 deletions scripts/code_coverage_report/code_coverage_file_list.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,63 @@
[
{
"sdk": "abtesting",
"filePatterns": [
"FirebaseABTesting.*",
"Interop/Analytics/Public/[^/]+\\.h",
"\\.github/workflows/abtesting\\.yml",
"Gemfile"
]
},
{
"sdk": "auth",
"filePatterns": [
"FirebaseAuth.*",
"Interop/Auth/Public/[^/]+\\.h",
"\\.github/workflows/auth\\.yml",
"Gemfile"
]
},
{
"sdk": "database",
"filePatterns": [
"FirebaseDatabase.*",
"\\.github/workflows/database\\.yml",
"Example/Database/",
"Interop/Auth/Public/.*\\.h"
"Interop/Auth/Public/[^/]+\\.h",
"Gemfile"
]
},
{
"sdk": "dynamiclinks",
"filePatterns": [
"FirebaseDynamicLinks.*",
"\\.github/workflows/dynamiclinks\\.yml",
"Interop/Analytics/Public/[^/]+\\.h",
"Gemfile"
]
},
{
"sdk": "firestore",
"filePatterns": [
"Firestore/.*",
"Interop/Auth/Public/[^/]+\\.h",
"FirebaseCore/Sources/Private",
"FirebaseCore/Sources/Public",
"FirebaseFirestore\\.podspec",
"CMakeLists\\.txt",
"cmake/.*",
"scripts/binary_to_array\\.py",
"scripts/build\\.sh",
"scripts/install_prereqs\\.sh",
"scripts/localize_podfile\\.swift",
"scripts/pod_lib_lint\\.rb",
"scripts/run_firestore_emulator\\.sh",
"scripts/setup_[^/]+",
"scripts/sync_project\\.rb",
"scripts/test_quickstart\\.sh",
"scripts/xcresult_logs\\.py",
"\\.github/workflows/firestore\\.yml",
"Gemfile"
]
},
{
Expand All @@ -14,7 +66,65 @@
"Functions.*",
"\\.github/workflows/functions\\.yml",
"Interop/Auth/Public/.*\\.h",
"FirebaseMessaging/Sources/Interop/.*\\.h"
"FirebaseMessaging/Sources/Interop/[^/]+\\.h",
"Gemfile"
]
},
{
"sdk": "inappmessaging",
"filePatterns": [
"FirebaseInAppMessaging.*",
"Interop/Analytics/Public/[^/]+\\.h",
"\\.github/workflows/inappmessaging\\.yml",
"Gemfile"
]
},
{
"sdk": "instanceid",
"filePatterns": [
"FirebaseInstanceID.*",
"Firebase/InstanceID/.*",
"Example/InstanceID/.*",
"\\.github/workflows/instanceid\\.yml",
"Gemfile"
]
},
{
"sdk": "messaging",
"filePatterns": [
"FirebaseMessaging/.*",
"Interop/Analytics/Public/[^/]+\\.h",
"FirebaseMessaging\\.podspec",
"\\.github/workflows/messaging\\.yml",
"Gemfile"
]
},
{
"sdk": "performance",
"filePatterns": [
"FirebasePerformance/.*",
"FirebasePerformance\\.podspec",
"\\.github/workflows/performance\\.yml",
"Gemfile"
]
},
{
"sdk": "remoteconfig",
"filePatterns": [
"FirebaseRemoteConfig.*",
"Interop/Analytics/Public/[^/]+\\.h",
"\\.github/workflows/remoteconfig\\.yml",
"Gemfile",
"scripts/generate_access_token\\.sh"
]
},
{
"sdk": "storage",
"filePatterns": [
"FirebaseStorage.*",
"Interop/Auth/Public/[^/]+\\.h",
"\\.github/workflows/storage\\.yml",
"Gemfile"
]
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -63,26 +63,29 @@ extension CoverageReportRequestData {
// Get sdk name. resultBundle is like ${SDK}-${platform}. E.g. FirebaseDatabase-ios.
// To display only sdk related tests and exclude non related testing, e.g.
// FirebaseDatabase-ios-GoogleDataTransport.framework,
// FirebaseDatabase-ios-FirebaseCore-Unit-unit.xctest,
// FirebaseDatabase-ios-FirebaseCore.framework, a regex pattern will be
// used to exclude results that are not related in terms of the target names.
let sdk_name = resultBundle.components(separatedBy: "-")[0]
let range = NSRange(location: 0, length: target.name.utf16.count)
let target_pattern = ".*\(sdk_name).*framework"
let sdk_related_coverage_file_pattern = try! NSRegularExpression(
pattern: ".*\(sdk_name).*",
pattern: target_pattern,
options: NSRegularExpression.Options(rawValue: 0)
)
print("Target: \(target.name) is detected.")

if sdk_related_coverage_file_pattern.firstMatch(in: target.name, range: range) != nil {
print(
"Target, \(target.name), fit the pattern, \(target_pattern), and will be involved in the report."
)
results
.append(FileCoverage(sdk: resultBundle + "-" + target.name, type: "",
value: target.lineCoverage))
for file in target.files {
results
.append(FileCoverage(sdk: resultBundle + "-" + target.name, type: file.name,
value: file.lineCoverage))
results
.append(FileCoverage(sdk: resultBundle + "-" + target.name, type: file.name,
value: file.lineCoverage))
}
}
}
Expand Down

0 comments on commit 025eecd

Please sign in to comment.