-
Notifications
You must be signed in to change notification settings - Fork 199
150 lines (139 loc) · 5.81 KB
/
build_and_test_amplify.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
name: Build and Test the Amplify Package
on:
- push
permissions:
contents: read
actions: write
jobs:
build-amplify-swift:
name: Build for ${{ matrix.platform }}
runs-on: macos-13
strategy:
fail-fast: false
matrix:
platform: [iOS, macOS, tvOS, watchOS]
steps:
- name: Checkout repository
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 #v3.5.3
with:
persist-credentials: false
- name: Get build parameters for ${{ matrix.platform }}
id: platform
uses: ./.github/composite_actions/get_platform_parameters
with:
platform: ${{ matrix.platform }}
xcode_version: '14.3'
- name: Attempt to use the dependencies cache
id: dependencies-cache
timeout-minutes: 4
continue-on-error: true
uses: actions/cache/restore@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1
with:
path: ~/Library/Developer/Xcode/DerivedData/Amplify
key: amplify-packages-${{ hashFiles('Package.resolved') }}
restore-keys: |
amplify-packages-
- name: Attempt to restore the build cache from main
id: build-cache
timeout-minutes: 4
continue-on-error: true
uses: actions/cache/restore@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1
with:
path: ${{ github.workspace }}/Build
key: Amplify-${{ matrix.platform }}-cache-main
- name: Build Amplify-Package
id: build-package
continue-on-error: true
uses: ./.github/composite_actions/run_xcodebuild
with:
scheme: Amplify-Package
destination: ${{ steps.platform.outputs.destination }}
sdk: ${{ steps.platform.outputs.sdk }}
xcode_path: /Applications/Xcode_14.3.app
cloned_source_packages_path: ~/Library/Developer/Xcode/DerivedData/Amplify
derived_data_path: ${{ github.workspace }}/Build
disable_package_resolution: ${{ steps.dependencies-cache.outputs.cache-hit }}
- name: Save the build cache
uses: actions/cache/save@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1
with:
path: ${{ github.workspace }}/Build
key: Amplify-${{ matrix.platform }}-cache-${{ github.ref_name }}
run-unit-tests:
name: ${{ matrix.scheme }} Unit Tests
needs: [build-amplify-swift]
strategy:
fail-fast: false
matrix:
platform: [iOS, macOS, tvOS, watchOS]
scheme: [
{ name: Amplify, reportCoverage: true },
{ name: AWSPluginsCore, reportCoverage: true },
{ name: AWSAPIPlugin, reportCoverage: true },
{ name: AWSCloudWatchLoggingPlugin, reportCoverage: true },
{ name: AWSCognitoAuthPlugin, reportCoverage: true },
{ name: AWSDataStorePlugin, reportCoverage: true },
{ name: AWSLocationGeoPlugin, reportCoverage: true },
{ name: AWSPredictionsPlugin, reportCoverage: true },
{ name: AWSPinpointAnalyticsPlugin, reportCoverage: true },
{ name: AWSPinpointPushNotificationsPlugin, reportCoverage: true },
{ name: AWSS3StoragePlugin, reportCoverage: true },
{ name: CoreMLPredictionsPlugin, reportCoverage: true },
{ name: InternalAWSPinpointUnitTests, reportCoverage: false },
]
uses: ./.github/workflows/run_unit_tests.yml
with:
scheme: ${{ matrix.scheme.name }}
platform: ${{ matrix.platform }}
xcode_version: '14.3'
generate_coverage_report: ${{ matrix.platform == 'iOS' && matrix.scheme.reportCoverage }}
build_cache_key: Amplify-${{ matrix.platform }}-cache-${{ github.ref_name }}
test_without_building: true
report-coverage:
name: ${{ matrix.file.scheme }} Coverage Report
needs: [run-unit-tests]
strategy:
fail-fast: false
matrix:
file: [
{ scheme: Amplify, flags: 'Amplify,unit_tests' },
{ scheme: AWSPluginsCore, flags: 'AWSPluginsCore,unit_tests' },
{ scheme: AWSAPIPlugin, flags: 'API_plugin_unit_test,unit_tests' },
{ scheme: AWSCloudWatchLoggingPlugin, flags: 'Logging_plugin_unit_test,unit_tests' },
{ scheme: AWSCognitoAuthPlugin, flags: 'Auth_plugin_unit_test,unit_tests' },
{ scheme: AWSDataStorePlugin, flags: 'DataStore_plugin_unit_test,unit_tests' },
{ scheme: AWSLocationGeoPlugin, flags: 'Geo_plugin_unit_test,unit_tests' },
{ scheme: AWSPredictionsPlugin, flags: 'Predictions_plugin_unit_test,unit_tests' },
{ scheme: AWSPinpointAnalyticsPlugin, flags: 'Analytics_plugin_unit_test,unit_tests' },
{ scheme: AWSPinpointPushNotificationsPlugin, flags: 'PushNotifications_plugin_unit_test,unit_tests' },
{ scheme: AWSS3StoragePlugin, flags: 'Storage_plugin_unit_test,unit_tests' },
{ scheme: CoreMLPredictionsPlugin, flags: 'CoreMLPredictions_plugin_unit_test,unit_tests' }
]
uses: ./.github/workflows/upload_coverage_report.yml
with:
scheme: ${{ matrix.file.scheme }}
flags: ${{ matrix.file.flags }}
delete-package-cache:
if: github.ref_name != 'main'
name: Delete ${{ matrix.platform }} cache
runs-on: ubuntu-latest
needs: [run-unit-tests]
continue-on-error: true
env:
GH_TOKEN: ${{ github.token }}
strategy:
fail-fast: false
matrix:
platform: [iOS, macOS, tvOS, watchOS]
steps:
- run: |
gh cache delete Amplify-${{ matrix.platform }}-cache-${{ github.ref_name }}
shell: bash
unit-test-pass-confirmation:
runs-on: ubuntu-latest
name: Confirm Passing Unit Tests
if: ${{ !cancelled() }}
needs: [ run-unit-tests ]
env:
EXIT_CODE: ${{ contains(needs.*.result, 'failure') && 1 || 0 }}
steps:
- run: exit $EXIT_CODE