Skip to content

Commit 20e1443

Browse files
authored
chore(Coverage): Submitting all reports together (#3156)
1 parent eb9c0cc commit 20e1443

File tree

4 files changed

+90
-31
lines changed

4 files changed

+90
-31
lines changed

.github/composite_actions/run_xcodebuild_test/action.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,6 @@ runs:
6161
cd Build/Build/ProfileData
6262
cd $(ls -d */|head -n 1)
6363
pathCoverage=Build/Build/ProfileData/${PWD##*/}/Coverage.profdata
64-
cd ../../../../
65-
xcrun llvm-cov export -format="lcov" -instr-profile $pathCoverage Build/Build/Products/Debug-${{ inputs.sdk }}/$SCHEME.o > Coverage.lcov
64+
cd ${{ github.workspace }}
65+
xcrun llvm-cov export -format="lcov" -instr-profile $pathCoverage Build/Build/Products/Debug-${{ inputs.sdk }}/$SCHEME.o > $SCHEME-Coverage.lcov
6666
shell: bash

.github/workflows/run_xcodebuild_test_platforms.yml

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,11 @@ on:
1111
required: false
1212
type: number
1313
default: 30
14-
submit_coverage_report:
14+
generate_coverage_report:
1515
description: 'Whether to generate and report code coverage'
1616
required: false
1717
type: boolean
1818
default: false
19-
coverage_flags:
20-
description: 'What flag to include in the coverage report, separated by commas'
21-
required: false
22-
type: string
23-
default: 'tests'
2419

2520
env:
2621
SCHEME: ${{ inputs.scheme }}
@@ -43,12 +38,16 @@ jobs:
4338
scheme: ${{ env.SCHEME }}
4439
destination: 'platform=iOS Simulator,name=iPhone 14,OS=16.4'
4540
xcode_path: '/Applications/Xcode_14.3.app'
46-
generate_coverage: ${{ inputs.submit_coverage_report }}
47-
- name: Upload Coverage report to Codecov
48-
if: ${{ inputs.submit_coverage_report == true }}
49-
shell: bash
50-
run: |
51-
build-support/codecov.sh -F '${{ inputs.coverage_flags }}'
41+
generate_coverage: ${{ inputs.generate_coverage_report }}
42+
- name: Upload Report File
43+
if: ${{ inputs.generate_coverage_report == true }}
44+
uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce #v3.1.2
45+
with:
46+
name: ${{ env.SCHEME }}-Coverage-${{ github.sha }}
47+
path: ${{ github.workspace }}/${{ env.SCHEME }}-Coverage.lcov
48+
if-no-files-found: error
49+
retention-days: 1
50+
5251

5352
test-macOS:
5453
name: ${{ inputs.scheme }} macOS Tests

.github/workflows/unit_test.yml

Lines changed: 41 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -26,29 +26,53 @@ jobs:
2626
uses: ./.github/workflows/run_xcodebuild_test_platforms.yml
2727
with:
2828
scheme: ${{ matrix.scheme }}
29-
submit_coverage_report: false
29+
generate_coverage_report: false
3030

3131
unit-tests-with-coverage:
32-
name: ${{ matrix.scheme.name }} Unit Tests
32+
name: ${{ matrix.scheme }} Unit Tests
3333
strategy:
3434
fail-fast: false
3535
matrix:
3636
scheme: [
37-
{ name: Amplify, flags: 'Amplify,unit_tests' },
38-
{ name: AWSPluginsCore, flags: 'AWSPluginsCore,unit_tests' },
39-
{ name: AWSAPIPlugin, flags: 'API_plugin_unit_test,unit_tests' },
40-
{ name: AWSCloudWatchLoggingPlugin, flags: 'Logging_plugin_unit_test,unit_tests' },
41-
{ name: AWSCognitoAuthPlugin, flags: 'Auth_plugin_unit_test,unit_tests' },
42-
{ name: AWSDataStorePlugin, flags: 'DataStore_plugin_unit_test,unit_tests' },
43-
{ name: AWSLocationGeoPlugin, flags: 'Geo_plugin_unit_test,unit_tests' },
44-
{ name: AWSPredictionsPlugin, flags: 'Predictions_plugin_unit_test,unit_tests' },
45-
{ name: AWSPinpointAnalyticsPlugin, flags: 'Analytics_plugin_unit_test,unit_tests' },
46-
{ name: AWSPinpointPushNotificationsPlugin, flags: 'PushNotifications_plugin_unit_test,unit_tests' },
47-
{ name: AWSS3StoragePlugin, flags: 'Storage_plugin_unit_test,unit_tests' },
48-
{ name: CoreMLPredictionsPlugin, flags: 'CoreMLPredictions_plugin_unit_test,unit_tests' }
37+
Amplify,
38+
AWSPluginsCore,
39+
AWSAPIPlugin,
40+
AWSCloudWatchLoggingPlugin,
41+
AWSCognitoAuthPlugin,
42+
AWSDataStorePlugin,
43+
AWSLocationGeoPlugin,
44+
AWSPredictionsPlugin,
45+
AWSPinpointAnalyticsPlugin,
46+
AWSPinpointPushNotificationsPlugin,
47+
AWSS3StoragePlugin,
48+
CoreMLPredictionsPlugin
4949
]
5050
uses: ./.github/workflows/run_xcodebuild_test_platforms.yml
5151
with:
52-
scheme: ${{ matrix.scheme.name }}
53-
submit_coverage_report: true
54-
coverage_flags: ${{ matrix.scheme.flags }}
52+
scheme: ${{ matrix.scheme }}
53+
generate_coverage_report: true
54+
55+
report-coverage:
56+
name: ${{ matrix.file.scheme }} Coverage Report
57+
needs: [unit-tests-with-coverage]
58+
strategy:
59+
fail-fast: false
60+
matrix:
61+
file: [
62+
{ scheme: Amplify, flags: 'Amplify,unit_tests' },
63+
{ scheme: AWSPluginsCore, flags: 'AWSPluginsCore,unit_tests' },
64+
{ scheme: AWSAPIPlugin, flags: 'API_plugin_unit_test,unit_tests' },
65+
{ scheme: AWSCloudWatchLoggingPlugin, flags: 'Logging_plugin_unit_test,unit_tests' },
66+
{ scheme: AWSCognitoAuthPlugin, flags: 'Auth_plugin_unit_test,unit_tests' },
67+
{ scheme: AWSDataStorePlugin, flags: 'DataStore_plugin_unit_test,unit_tests' },
68+
{ scheme: AWSLocationGeoPlugin, flags: 'Geo_plugin_unit_test,unit_tests' },
69+
{ scheme: AWSPredictionsPlugin, flags: 'Predictions_plugin_unit_test,unit_tests' },
70+
{ scheme: AWSPinpointAnalyticsPlugin, flags: 'Analytics_plugin_unit_test,unit_tests' },
71+
{ scheme: AWSPinpointPushNotificationsPlugin, flags: 'PushNotifications_plugin_unit_test,unit_tests' },
72+
{ scheme: AWSS3StoragePlugin, flags: 'Storage_plugin_unit_test,unit_tests' },
73+
{ scheme: CoreMLPredictionsPlugin, flags: 'CoreMLPredictions_plugin_unit_test,unit_tests' }
74+
]
75+
uses: ./.github/workflows/upload_coverage_report.yml
76+
with:
77+
scheme: ${{ matrix.file.scheme }}
78+
flags: ${{ matrix.file.flags }}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Uploads the coverage report file to Codecov
2+
on:
3+
workflow_call:
4+
inputs:
5+
scheme:
6+
description: 'The name of the scheme whose coverage needs to be uploaded.'
7+
required: true
8+
type: string
9+
flags:
10+
description: 'What flags to include in the coverage report, separated by commas'
11+
required: false
12+
type: string
13+
default: 'tests'
14+
15+
permissions:
16+
contents: read
17+
18+
jobs:
19+
upload-coverage:
20+
name: ${{ inputs.scheme }} Coverage Report
21+
runs-on: macos-13
22+
steps:
23+
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 #v3.5.3
24+
with:
25+
persist-credentials: false
26+
27+
- name: Retrieve Coverage report
28+
uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a #v3.0.2
29+
with:
30+
name: ${{ inputs.scheme }}-Coverage-${{ github.sha }}
31+
path: ${{ github.workspace }}
32+
33+
- name: Upload report to Codecov
34+
shell: bash
35+
run: |
36+
build-support/codecov.sh -F '${{ inputs.flags }}'

0 commit comments

Comments
 (0)