1
1
name : test_coverage
2
2
3
- on : [pull_request]
4
- # run specific jobs when specific files are updated.
5
- # https://github.community/t/how-to-execute-jobs-if-folder-updated-recursive/117344/5
3
+ on :
4
+ pull_request :
5
+ # synchronize will be triggered when a pull request has new commits.
6
+ # closed will be triggered when a pull request is closed.
7
+ types : [synchronize, closed]
6
8
7
9
jobs :
8
10
check :
11
+ if : github.repository == 'Firebase/firebase-ios-sdk' && github.event.action == 'synchronize'
9
12
name : Check changed files
10
13
outputs :
11
14
database_run_job : ${{ steps.check_files.outputs.database_run_job }}
12
15
functions_run_job : ${{ steps.check_files.outputs.functions_run_job }}
16
+ base_commit : ${{ steps.check_files.outputs.base_commit }}
13
17
runs-on : ubuntu-latest
14
18
steps :
15
19
- name : Checkout code
@@ -21,37 +25,34 @@ jobs:
21
25
env :
22
26
pr_branch : ${{ github.event.pull_request.head.ref }}
23
27
run : ./scripts/code_coverage_report/get_updated_files.sh
28
+
24
29
pod-lib-lint-database :
25
30
# Don't run on private repo unless it is a PR.
31
+ if : github.repository == 'Firebase/firebase-ios-sdk' && (needs.check.outputs.database_run_job == 'true' || github.event.pull_request.merged == true)
26
32
needs : check
27
- if : github.repository == 'Firebase/firebase-ios-sdk' && needs.check.outputs.database_run_job == 'true'
28
33
runs-on : macOS-latest
29
-
30
34
strategy :
31
35
matrix :
32
- target : [ios, tvos, macos ]
36
+ target : [ios]
33
37
steps :
34
38
- uses : actions/checkout@v2
35
39
- name : Setup Bundler
36
40
run : scripts/setup_bundler.sh
37
41
- name : Build and test
38
- env :
39
- SDK : database
40
42
run : ./scripts/code_coverage_report/pod_test_code_coverage_report.sh FirebaseDatabase "${{ matrix.target }}"
41
43
- uses : actions/upload-artifact@v2
42
44
with :
43
- name : database- codecoverage
45
+ name : codecoverage
44
46
path : /Users/runner/*.xcresult
45
47
46
48
pod-lib-lint-functions :
47
49
# Don't run on private repo unless it is a PR.
50
+ if : github.repository == 'Firebase/firebase-ios-sdk' && (needs.check.outputs.functions_run_job == 'true' || github.event.pull_request.merged == true)
48
51
needs : check
49
- if : github.repository == 'Firebase/firebase-ios-sdk' && needs.check.outputs.functions_run_job == 'true'
50
52
runs-on : macOS-latest
51
-
52
53
strategy :
53
54
matrix :
54
- target : [ios, tvos, macos ]
55
+ target : [ios]
55
56
steps :
56
57
- uses : actions/checkout@v2
57
58
- name : Setup Bundler
@@ -60,20 +61,48 @@ jobs:
60
61
run : ./scripts/code_coverage_report/pod_test_code_coverage_report.sh FirebaseFunctions "${{ matrix.target }}"
61
62
- uses : actions/upload-artifact@v2
62
63
with :
63
- name : functions- codecoverage
64
+ name : codecoverage
64
65
path : /Users/runner/*.xcresult
65
66
66
67
create_report :
67
- needs : [pod-lib-lint-functions, pod-lib-lint-database]
68
+ needs : [check, pod-lib-lint-functions, pod-lib-lint-database]
69
+ env :
70
+ metrics_service_secret : ${{ secrets.GHASecretsGPGPassphrase1 }}
68
71
if : always()
69
72
runs-on : macOS-latest
70
73
steps :
74
+ - uses : actions/checkout@v2
75
+ - name : Access to Metrics Service
76
+ run : |
77
+ # Install gcloud sdk
78
+ curl https://sdk.cloud.google.com > install.sh
79
+ bash install.sh --disable-prompts
80
+ echo "${HOME}/google-cloud-sdk/bin/" >> $GITHUB_PATH
81
+ export PATH="${HOME}/google-cloud-sdk/bin/:${PATH}"
82
+
83
+ # Activate the service account for Metrics Service.
84
+ scripts/decrypt_gha_secret.sh scripts/gha-encrypted/metrics_service_access.json.gpg \
85
+ metrics-access.json "$metrics_service_secret"
86
+ gcloud auth activate-service-account --key-file metrics-access.json
71
87
- uses : actions/download-artifact@v2
72
88
id : download
73
89
with :
74
90
path : /Users/runner/test
75
- - name : display results
91
+ - name : Compare Diff and Post a Report
92
+ if : github.event_name == 'pull_request'
93
+ env :
94
+ base_commit : ${{ needs.check.outputs.base_commit }}
95
+ run : |
96
+ # Get Head commit of the branch, instead of a merge commit created by actions/checkout.
97
+ GITHUB_SHA=$(cat $GITHUB_EVENT_PATH | jq -r .pull_request.head.sha)
98
+ if [ -d "${{steps.download.outputs.download-path}}" ]; then
99
+ cd scripts/code_coverage_report/generate_code_coverage_report
100
+ swift run CoverageReportGenerator --presubmit "firebase/firebase-ios-sdk" --commit "${GITHUB_SHA}" --token $(gcloud auth print-identity-token) --xcresult-dir "/Users/runner/test/codecoverage" --log-link "https://github.com/firebase/firebase-ios-sdk/actions/runs/${GITHUB_RUN_ID}" --pull-request-num ${{github.event.pull_request.number}} --base-commit "$base_commit"
101
+ fi
102
+ - name : Update New Coverage Data
103
+ if : github.event.pull_request.merged == true
76
104
run : |
77
105
if [ -d "${{steps.download.outputs.download-path}}" ]; then
78
- find "/Users/runner/test" -print -regex ".*/.*\.xcresult" -exec xcrun xccov view --report {} \;
106
+ cd scripts/code_coverage_report/generate_code_coverage_report
107
+ swift run CoverageReportGenerator --merge "firebase/firebase-ios-sdk" --commit "${GITHUB_SHA}" --token $(gcloud auth print-identity-token) --xcresult-dir "/Users/runner/test/codecoverage" --log-link "https://github.com/firebase/firebase-ios-sdk/actions/runs/${GITHUB_RUN_ID}" --branch "${GITHUB_REF##*/}"
79
108
fi
0 commit comments