From 798504bcc020b031d91e634f733251bf2a0bfd4a Mon Sep 17 00:00:00 2001 From: Di Wu Date: Mon, 8 Jan 2024 13:25:19 -0800 Subject: [PATCH 1/3] ci: add action workflow for ensuring minimum xcode version support --- .../get_platform_parameters/action.yml | 8 ++- .github/workflows/build_amplify_swift.yml | 14 ++++-- ...uild_minimum_supported_swift_platforms.yml | 49 +++++++++++++++++++ 3 files changed, 67 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/build_minimum_supported_swift_platforms.yml diff --git a/.github/composite_actions/get_platform_parameters/action.yml b/.github/composite_actions/get_platform_parameters/action.yml index d007eca053..0fc0945e11 100644 --- a/.github/composite_actions/get_platform_parameters/action.yml +++ b/.github/composite_actions/get_platform_parameters/action.yml @@ -28,11 +28,17 @@ runs: XCODE_VERSION=${{ inputs.xcode_version }} case $XCODE_VERSION in - 14.3|15.0) ;; + 14.0.1|14.3|15.0) ;; *) echo "Unsupported Xcode version: $XCODE_VERSION"; exit 1 ;; esac DESTINATION_MAPPING='{ + "14.0.1": { + "iOS": "platform=iOS Simulator,name=iPhone 14,OS=16.0", + "tvOS": "platform=tvOS Simulator,name=Apple TV 4K (2nd generation),OS=16.0", + "watchOS": "platform=watchOS Simulator,name=Apple Watch Series 8 (45mm),OS=9.0", + "macOS": "platform=macOS,arch=x86_64" + }, "14.3": { "iOS": "platform=iOS Simulator,name=iPhone 14,OS=16.4", "tvOS": "platform=tvOS Simulator,name=Apple TV 4K (3rd generation),OS=16.4", diff --git a/.github/workflows/build_amplify_swift.yml b/.github/workflows/build_amplify_swift.yml index bfefc79014..d03a453913 100644 --- a/.github/workflows/build_amplify_swift.yml +++ b/.github/workflows/build_amplify_swift.yml @@ -5,6 +5,14 @@ on: platform: type: string required: true + + xcode-version: + type: string + default: '14.3' + + os-runner: + type: string + default: 'macos-13' permissions: contents: read @@ -13,7 +21,7 @@ permissions: jobs: build-amplify-swift: name: Build Amplify-Package | ${{ inputs.platform }} - runs-on: macos-13 + runs-on: ${{ inputs.os-runner }} steps: - name: Checkout repository uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 #v4.1.1 @@ -25,7 +33,7 @@ jobs: uses: ./.github/composite_actions/get_platform_parameters with: platform: ${{ inputs.platform }} - xcode_version: '14.3' + xcode_version: ${{ inputs.xcode-version }} - name: Attempt to use the dependencies cache id: dependencies-cache @@ -55,7 +63,7 @@ jobs: scheme: Amplify-Package destination: ${{ steps.platform.outputs.destination }} sdk: ${{ steps.platform.outputs.sdk }} - xcode_path: /Applications/Xcode_14.3.app + xcode_path: /Applications/Xcode_${{ inputs.xcode-version }}.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 }} diff --git a/.github/workflows/build_minimum_supported_swift_platforms.yml b/.github/workflows/build_minimum_supported_swift_platforms.yml new file mode 100644 index 0000000000..cac1600011 --- /dev/null +++ b/.github/workflows/build_minimum_supported_swift_platforms.yml @@ -0,0 +1,49 @@ +name: Build with Minimum Supported Xcode Versions +on: + workflow_dispatch: + push: + branches: + - main + +permissions: + contents: read + actions: write + +jobs: + build-amplify-with-minimum-supported-xcode: + name: Build Amplify Swift for ${{ matrix.platform }} + strategy: + fail-fast: false + matrix: + include: + - os-runner: macos-12 + xcode-version: 14.0.1 + platform: iOS + + - os-runner: macos-12 + xcode-version: 14.0.1 + platform: macOS + + - os-runner: macos-12 + xcode-version: 14.0.1 + platform: tvOS + + - os-runner: macos-12 + xcode-version: 14.0.1 + platform: watchOS + + uses: ./.github/workflows/build_amplify_swift.yml + with: + os-runner: ${{ matrix.os-runner }} + xcode-version: ${{ matrix.xcode-version }} + platform: ${{ matrix.platform }} + + confirm-pass: + runs-on: ubuntu-latest + name: Confirm Passing Build Steps + if: ${{ !cancelled() }} + needs: [ build-amplify-with-minimum-supported-xcode ] + env: + EXIT_CODE: ${{ contains(needs.*.result, 'failure') && 1 || 0 }} + steps: + - run: exit $EXIT_CODE From caaa159663aebeaa1a5205d495236196fe23363b Mon Sep 17 00:00:00 2001 From: Di Wu Date: Tue, 9 Jan 2024 12:45:13 -0800 Subject: [PATCH 2/3] resolve comment --- .github/workflows/build_amplify_swift.yml | 18 ++++++++++++------ ...build_minimum_supported_swift_platforms.yml | 1 + 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build_amplify_swift.yml b/.github/workflows/build_amplify_swift.yml index d03a453913..6330472628 100644 --- a/.github/workflows/build_amplify_swift.yml +++ b/.github/workflows/build_amplify_swift.yml @@ -5,7 +5,7 @@ on: platform: type: string required: true - + xcode-version: type: string default: '14.3' @@ -14,6 +14,10 @@ on: type: string default: 'macos-13' + cachable: + type: boolean + default: true + permissions: contents: read actions: write @@ -34,9 +38,10 @@ jobs: with: platform: ${{ inputs.platform }} xcode_version: ${{ inputs.xcode-version }} - + - name: Attempt to use the dependencies cache id: dependencies-cache + if: inputs.cachable timeout-minutes: 4 continue-on-error: true uses: actions/cache/restore@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1 @@ -48,6 +53,7 @@ jobs: - name: Attempt to restore the build cache from main id: build-cache + if: inputs.cachable timeout-minutes: 4 continue-on-error: true uses: actions/cache/restore@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1 @@ -69,14 +75,14 @@ jobs: disable_package_resolution: ${{ steps.dependencies-cache.outputs.cache-hit }} - name: Save the dependencies cache in main - if: steps.dependencies-cache.outputs.cache-hit != 'true' && github.ref_name == 'main' + if: inputs.cachable && steps.dependencies-cache.outputs.cache-hit != 'true' && github.ref_name == 'main' uses: actions/cache/save@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1 with: path: ~/Library/Developer/Xcode/DerivedData/Amplify key: ${{ steps.dependencies-cache.outputs.cache-primary-key }} - + - name: Delete the old build cache - if: steps.build-cache.outputs.cache-hit && github.ref_name == 'main' + if: inputs.cachable && steps.build-cache.outputs.cache-hit && github.ref_name == 'main' env: GH_TOKEN: ${{ github.token }} continue-on-error: true @@ -84,7 +90,7 @@ jobs: gh cache delete ${{ steps.build-cache.outputs.cache-primary-key }} - name: Save the build cache - if: github.ref_name == 'main' + if: inputs.cachable && github.ref_name == 'main' uses: actions/cache/save@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1 with: path: ${{ github.workspace }}/Build diff --git a/.github/workflows/build_minimum_supported_swift_platforms.yml b/.github/workflows/build_minimum_supported_swift_platforms.yml index cac1600011..1943cef0d9 100644 --- a/.github/workflows/build_minimum_supported_swift_platforms.yml +++ b/.github/workflows/build_minimum_supported_swift_platforms.yml @@ -37,6 +37,7 @@ jobs: os-runner: ${{ matrix.os-runner }} xcode-version: ${{ matrix.xcode-version }} platform: ${{ matrix.platform }} + cachable: false confirm-pass: runs-on: ubuntu-latest From 333c775c614e5555ede61fb229409bce6318954f Mon Sep 17 00:00:00 2001 From: Di Wu Date: Tue, 9 Jan 2024 13:43:18 -0800 Subject: [PATCH 3/3] fix typo --- .github/workflows/build_amplify_swift.yml | 12 ++++++------ .../build_minimum_supported_swift_platforms.yml | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build_amplify_swift.yml b/.github/workflows/build_amplify_swift.yml index 6330472628..d2975c4a82 100644 --- a/.github/workflows/build_amplify_swift.yml +++ b/.github/workflows/build_amplify_swift.yml @@ -14,7 +14,7 @@ on: type: string default: 'macos-13' - cachable: + cacheable: type: boolean default: true @@ -41,7 +41,7 @@ jobs: - name: Attempt to use the dependencies cache id: dependencies-cache - if: inputs.cachable + if: inputs.cacheable timeout-minutes: 4 continue-on-error: true uses: actions/cache/restore@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1 @@ -53,7 +53,7 @@ jobs: - name: Attempt to restore the build cache from main id: build-cache - if: inputs.cachable + if: inputs.cacheable timeout-minutes: 4 continue-on-error: true uses: actions/cache/restore@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1 @@ -75,14 +75,14 @@ jobs: disable_package_resolution: ${{ steps.dependencies-cache.outputs.cache-hit }} - name: Save the dependencies cache in main - if: inputs.cachable && steps.dependencies-cache.outputs.cache-hit != 'true' && github.ref_name == 'main' + if: inputs.cacheable && steps.dependencies-cache.outputs.cache-hit != 'true' && github.ref_name == 'main' uses: actions/cache/save@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1 with: path: ~/Library/Developer/Xcode/DerivedData/Amplify key: ${{ steps.dependencies-cache.outputs.cache-primary-key }} - name: Delete the old build cache - if: inputs.cachable && steps.build-cache.outputs.cache-hit && github.ref_name == 'main' + if: inputs.cacheable && steps.build-cache.outputs.cache-hit && github.ref_name == 'main' env: GH_TOKEN: ${{ github.token }} continue-on-error: true @@ -90,7 +90,7 @@ jobs: gh cache delete ${{ steps.build-cache.outputs.cache-primary-key }} - name: Save the build cache - if: inputs.cachable && github.ref_name == 'main' + if: inputs.cacheable && github.ref_name == 'main' uses: actions/cache/save@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1 with: path: ${{ github.workspace }}/Build diff --git a/.github/workflows/build_minimum_supported_swift_platforms.yml b/.github/workflows/build_minimum_supported_swift_platforms.yml index 1943cef0d9..a86f8b99b0 100644 --- a/.github/workflows/build_minimum_supported_swift_platforms.yml +++ b/.github/workflows/build_minimum_supported_swift_platforms.yml @@ -37,7 +37,7 @@ jobs: os-runner: ${{ matrix.os-runner }} xcode-version: ${{ matrix.xcode-version }} platform: ${{ matrix.platform }} - cachable: false + cacheable: false confirm-pass: runs-on: ubuntu-latest