Skip to content

Commit

Permalink
Splitting platform
Browse files Browse the repository at this point in the history
  • Loading branch information
ruisebas committed Nov 1, 2023
1 parent de213a2 commit e98b33c
Show file tree
Hide file tree
Showing 3 changed files with 213 additions and 103 deletions.
68 changes: 68 additions & 0 deletions .github/workflows/build_amplify_swift_for_testing.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: Build the Amplify Package for Testing
on:
workflow_call:
inputs:
platform:
type: string
required: true

permissions:
contents: read
actions: write

jobs:
build-amplify-swift:
name: Build for ${{ inputs.platform }}
runs-on: macos-13
steps:
- name: Checkout repository
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 #v3.5.3
with:
persist-credentials: false

- name: Get build parameters for ${{ inputs.platform }}
id: platform
uses: ./.github/composite_actions/get_platform_parameters
with:
platform: ${{ inputs.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-${{ inputs.platform }}-cache-main

- name: Build Amplify-Package for Testing
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 }}
build_for_testing: true

- name: Save the build cache
uses: actions/cache/save@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1
with:
path: ${{ github.workspace }}/Build
key: Amplify-${{ inputs.platform }}-cache-${{ github.ref_name }}
233 changes: 139 additions & 94 deletions .github/workflows/build_and_test_amplify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,100 +7,157 @@ permissions:
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
build-amplify-swift-iOS:
name: Build for iOS
uses: ./.github/workflows/build_amplify_swift_for_testing.yml
with:
platform: iOS

- 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-
build-amplify-swift-macOS:
name: Build for macOS
uses: ./.github/workflows/build_amplify_swift_for_testing.yml
with:
platform: macOS

build-amplify-swift-tvOS:
name: Build for tvOS
uses: ./.github/workflows/build_amplify_swift_for_testing.yml
with:
platform: tvOS

- 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
build-amplify-swift-watchOS:
name: Build for watchOS
uses: ./.github/workflows/build_amplify_swift_for_testing.yml
with:
platform: watchOS

- name: Build Amplify-Package for Testing
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 }}
build_for_testing: true

- 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-iOS:
name: ${{ matrix.scheme.name }} Unit Tests
needs: [build-amplify-swift-iOS]
strategy:
fail-fast: false
matrix:
scheme: [
Amplify,
AWSPluginsCore,
AWSAPIPlugin,
AWSCloudWatchLoggingPlugin,
AWSCognitoAuthPlugin,
AWSDataStorePlugin,
AWSLocationGeoPlugin,
AWSPredictionsPlugin,
AWSPinpointAnalyticsPlugin,
AWSPinpointPushNotificationsPlugin,
AWSS3StoragePlugin,
CoreMLPredictionsPlugin,
InternalAWSPinpointUnitTests
]
uses: ./.github/workflows/run_unit_tests.yml
with:
scheme: ${{ matrix.scheme.name }}
platform: iOS
xcode_version: '14.3'
generate_coverage_report: ${{ matrix.scheme != 'InternalAWSPinpointUnitTests' }}
build_cache_key: Amplify-iOS-cache-${{ github.ref_name }}
test_without_building: true
delete_build_cache_on_success: ${{ github.ref_name != 'main'}}

run-unit-tests:
run-unit-tests-macOS:
name: ${{ matrix.scheme.name }} Unit Tests
needs: [build-amplify-swift]
needs: [build-amplify-swift-macOS]
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 },
Amplify,
AWSPluginsCore,
AWSAPIPlugin,
AWSCloudWatchLoggingPlugin,
AWSCognitoAuthPlugin,
AWSDataStorePlugin,
AWSLocationGeoPlugin,
AWSPredictionsPlugin,
AWSPinpointAnalyticsPlugin,
AWSPinpointPushNotificationsPlugin,
AWSS3StoragePlugin,
CoreMLPredictionsPlugin,
InternalAWSPinpointUnitTests
]
uses: ./.github/workflows/run_unit_tests.yml
with:
scheme: ${{ matrix.scheme.name }}
platform: ${{ matrix.platform }}
platform: macOS
xcode_version: '14.3'
generate_coverage_report: ${{ matrix.platform == 'iOS' && matrix.scheme.reportCoverage }}
build_cache_key: Amplify-${{ matrix.platform }}-cache-${{ github.ref_name }}
generate_coverage_report: false
build_cache_key: Amplify-macOS-cache-${{ github.ref_name }}
test_without_building: true
delete_build_cache_on_success: ${{ github.ref_name != 'main'}}

run-unit-tests-tvOS:
name: ${{ matrix.scheme.name }} Unit Tests
needs: [build-amplify-swift-tvOS]
strategy:
fail-fast: false
matrix:
scheme: [
Amplify,
AWSPluginsCore,
AWSAPIPlugin,
AWSCloudWatchLoggingPlugin,
AWSCognitoAuthPlugin,
AWSDataStorePlugin,
AWSLocationGeoPlugin,
AWSPredictionsPlugin,
AWSPinpointAnalyticsPlugin,
AWSPinpointPushNotificationsPlugin,
AWSS3StoragePlugin,
CoreMLPredictionsPlugin,
InternalAWSPinpointUnitTests
]
uses: ./.github/workflows/run_unit_tests.yml
with:
scheme: ${{ matrix.scheme.name }}
platform: tvOS
xcode_version: '14.3'
generate_coverage_report: false
build_cache_key: Amplify-macOS-cache-${{ github.ref_name }}
test_without_building: true
delete_build_cache_on_success: ${{ github.ref_name != 'main'}}

run-unit-tests-watchOS:
name: ${{ matrix.scheme.name }} Unit Tests
needs: [build-amplify-swift-watchOS]
strategy:
fail-fast: false
matrix:
scheme: [
Amplify,
AWSPluginsCore,
AWSAPIPlugin,
AWSCloudWatchLoggingPlugin,
AWSCognitoAuthPlugin,
AWSDataStorePlugin,
AWSLocationGeoPlugin,
AWSPredictionsPlugin,
AWSPinpointAnalyticsPlugin,
AWSPinpointPushNotificationsPlugin,
AWSS3StoragePlugin,
CoreMLPredictionsPlugin,
InternalAWSPinpointUnitTests
]
uses: ./.github/workflows/run_unit_tests.yml
with:
scheme: ${{ matrix.scheme.name }}
platform: watchOS
xcode_version: '14.3'
generate_coverage_report: false
build_cache_key: Amplify-watchOS-cache-${{ github.ref_name }}
test_without_building: true
delete_build_cache_on_success: ${{ github.ref_name != 'main'}}

report-coverage:
name: ${{ matrix.file.scheme }} Coverage Report
needs: [run-unit-tests]
needs: [run-unit-tests-iOS]
strategy:
fail-fast: false
matrix:
Expand All @@ -123,28 +180,16 @@ jobs:
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 ]
needs: [
run-unit-tests-iOS,
run-unit-tests-macOS,
run-unit-tests-tvOS,
run-unit-tests-watchOS
]
env:
EXIT_CODE: ${{ contains(needs.*.result, 'failure') && 1 || 0 }}
steps:
Expand Down
15 changes: 6 additions & 9 deletions .github/workflows/run_unit_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ on:
type: boolean
required: false
default: false
delete_build_cache_on_success:
required: false
type: boolean
default: false

permissions:
contents: read
Expand Down Expand Up @@ -112,22 +116,15 @@ jobs:
test_without_building: ${{ inputs.test_without_building && steps.dependencies-cache.outputs.cache-hit}}
other_flags: -test-iterations 3 -retry-tests-on-failure

- name: Delete the old build cache on main
if: github.ref_name == 'main' && steps.build-cache.outputs.cache-hit
- name: Delete the build cache
if: ${{ inputs.delete_build_cache_on_success && steps.build-cache.outputs.cache-hit }}
env:
GH_TOKEN: ${{ github.token }}
continue-on-error: true
run: |
gh cache delete ${{ steps.build-cache.outputs.cache-primary-key }}
shell: bash

- name: Save the new build cache on main
if: github.ref_name == 'main'
uses: actions/cache/save@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1
with:
path: ${{ github.workspace }}/Build
key: ${{ steps.build-cache.outputs.cache-primary-key }}

- name: Store Coverage Report File
if: ${{ inputs.generate_coverage_report == true }}
uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce #v3.1.2
Expand Down

0 comments on commit e98b33c

Please sign in to comment.