From bb7f7475dee0db808842ac707963a3ed12ad85c5 Mon Sep 17 00:00:00 2001 From: Sebastian Villena <97059974+ruisebas@users.noreply.github.com> Date: Fri, 26 Apr 2024 13:25:00 -0400 Subject: [PATCH] chore: Adding workflow to build Amplify for minimum Xcode (#3633) --- .../get_platform_parameters/action.yml | 17 +- .../build_amplify_swift_platforms.yml | 3 +- ...uild_minimum_supported_swift_platforms.yml | 19 +- ...ild_amplify_swift.yml => build_scheme.yml} | 31 +-- .../xcschemes/Amplify-Build.xcscheme | 211 ++++++++++++++++++ 5 files changed, 256 insertions(+), 25 deletions(-) rename .github/workflows/{build_amplify_swift.yml => build_scheme.yml} (78%) create mode 100644 .swiftpm/xcode/xcshareddata/xcschemes/Amplify-Build.xcscheme diff --git a/.github/composite_actions/get_platform_parameters/action.yml b/.github/composite_actions/get_platform_parameters/action.yml index 35353e4c98..c9e8e61e07 100644 --- a/.github/composite_actions/get_platform_parameters/action.yml +++ b/.github/composite_actions/get_platform_parameters/action.yml @@ -39,7 +39,8 @@ runs: - id: get-xcode-version run: | LATEST_XCODE_VERSION=14.3.1 - MINIMUM_XCODE_VERSION=14.0.1 + MINIMUM_XCODE_VERSION_IOS_MAC=14.1.0 + MINIMUM_XCODE_VERSION_WATCH_TV=14.3.1 INPUT_XCODE_VERSION=${{ inputs.xcode_version }} @@ -47,7 +48,13 @@ runs: latest) XCODE_VERSION=$LATEST_XCODE_VERSION ;; minimum) - XCODE_VERSION=$MINIMUM_XCODE_VERSION ;; + INPUT_PLATFORM=${{ inputs.platform }} + case $INPUT_PLATFORM in + iOS|macOS) + XCODE_VERSION=$MINIMUM_XCODE_VERSION_IOS_MAC ;; + tvOS|watchOS) + XCODE_VERSION=$MINIMUM_XCODE_VERSION_WATCH_TV ;; + esac ;; *) XCODE_VERSION=$INPUT_XCODE_VERSION ;; esac @@ -63,9 +70,9 @@ runs: DESTINATION_MAPPING='{ "minimum": { - "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", + "iOS": "platform=iOS Simulator,name=iPhone 14,OS=16.1", + "tvOS": "platform=tvOS Simulator,name=Apple TV 4K (2nd generation),OS=16.1", + "watchOS": "platform=watchOS Simulator,name=Apple Watch Series 8 (45mm),OS=9.1", "macOS": "platform=macOS,arch=x86_64" }, "latest": { diff --git a/.github/workflows/build_amplify_swift_platforms.yml b/.github/workflows/build_amplify_swift_platforms.yml index 54fc16d50e..2d8c6ce5c5 100644 --- a/.github/workflows/build_amplify_swift_platforms.yml +++ b/.github/workflows/build_amplify_swift_platforms.yml @@ -52,8 +52,9 @@ jobs: - platform: ${{ github.event.inputs.macos == 'false' && 'macOS' || 'None' }} - platform: ${{ github.event.inputs.tvos == 'false' && 'tvOS' || 'None' }} - platform: ${{ github.event.inputs.watchos == 'false' && 'watchOS' || 'None' }} - uses: ./.github/workflows/build_amplify_swift.yml + uses: ./.github/workflows/build_scheme.yml with: + scheme: Amplify-Package platform: ${{ matrix.platform }} confirm-pass: diff --git a/.github/workflows/build_minimum_supported_swift_platforms.yml b/.github/workflows/build_minimum_supported_swift_platforms.yml index 1b3c1cadfd..0e0522a479 100644 --- a/.github/workflows/build_minimum_supported_swift_platforms.yml +++ b/.github/workflows/build_minimum_supported_swift_platforms.yml @@ -1,11 +1,21 @@ -name: Build with Minimum Supported Xcode Versions +name: Build with minimum Xcode version | Amplify Swift on: workflow_dispatch: + pull_request: + branches: + - main + push: + branches: + - main permissions: contents: read actions: write +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: ${{ github.ref_name != 'main'}} + jobs: build-amplify-with-minimum-supported-xcode: name: Build Amplify Swift for ${{ matrix.platform }} @@ -14,12 +24,13 @@ jobs: matrix: platform: [iOS, macOS, tvOS, watchOS] - uses: ./.github/workflows/build_amplify_swift.yml + uses: ./.github/workflows/build_scheme.yml with: - os-runner: macos-12 + scheme: Amplify-Build + os-runner: ${{ (matrix.platform == 'tvOS' || matrix.platform == 'watchOS') && 'macos-13' || 'macos-12' }} xcode-version: 'minimum' platform: ${{ matrix.platform }} - cacheable: false + save_build_cache: false confirm-pass: runs-on: ubuntu-latest diff --git a/.github/workflows/build_amplify_swift.yml b/.github/workflows/build_scheme.yml similarity index 78% rename from .github/workflows/build_amplify_swift.yml rename to .github/workflows/build_scheme.yml index 095edbcfab..1ec3b433fc 100644 --- a/.github/workflows/build_amplify_swift.yml +++ b/.github/workflows/build_scheme.yml @@ -1,7 +1,11 @@ -name: Build Amplify-Package for the given platform +name: Build scheme for the given platform and other parameters on: workflow_call: inputs: + scheme: + type: string + required: true + platform: type: string required: true @@ -14,7 +18,7 @@ on: type: string default: 'macos-13' - cacheable: + save_build_cache: type: boolean default: true @@ -23,8 +27,8 @@ permissions: actions: write jobs: - build-amplify-swift: - name: Build Amplify-Package | ${{ inputs.platform }} + build-scheme: + name: Build ${{ inputs.scheme }} | ${{ inputs.platform }} runs-on: ${{ inputs.os-runner }} steps: - name: Checkout repository @@ -41,9 +45,8 @@ jobs: - name: Attempt to use the dependencies cache id: dependencies-cache - if: inputs.cacheable timeout-minutes: 4 - continue-on-error: ${{ inputs.cacheable }} + continue-on-error: true uses: actions/cache/restore@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1 with: path: ~/Library/Developer/Xcode/DerivedData/Amplify @@ -53,20 +56,18 @@ jobs: - name: Attempt to restore the build cache from main id: build-cache - if: inputs.cacheable timeout-minutes: 4 - continue-on-error: ${{ inputs.cacheable }} + continue-on-error: true uses: actions/cache/restore@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1 with: path: ${{ github.workspace }}/Build key: Amplify-${{ inputs.platform }}-build-cache - - name: Build Amplify for Swift + - name: Build ${{ inputs.scheme }} id: build-package - continue-on-error: ${{ inputs.cacheable }} uses: ./.github/composite_actions/run_xcodebuild with: - scheme: Amplify-Package + scheme: ${{ inputs.scheme }} destination: ${{ steps.platform.outputs.destination }} sdk: ${{ steps.platform.outputs.sdk }} xcode_path: /Applications/Xcode_${{ steps.platform.outputs.xcode-version }}.app @@ -75,22 +76,22 @@ jobs: disable_package_resolution: ${{ steps.dependencies-cache.outputs.cache-hit }} - name: Save the dependencies cache in main - if: inputs.cacheable && steps.dependencies-cache.outputs.cache-hit != 'true' && github.ref_name == 'main' + if: inputs.save_build_cache && 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.cacheable && steps.build-cache.outputs.cache-hit && github.ref_name == 'main' + if: inputs.save_build_cache && steps.build-cache.outputs.cache-hit && github.ref_name == 'main' env: GH_TOKEN: ${{ github.token }} - continue-on-error: ${{ inputs.cacheable }} + continue-on-error: true run: | gh cache delete ${{ steps.build-cache.outputs.cache-primary-key }} - name: Save the build cache - if: inputs.cacheable && github.ref_name == 'main' + if: inputs.save_build_cache && github.ref_name == 'main' uses: actions/cache/save@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1 with: path: ${{ github.workspace }}/Build diff --git a/.swiftpm/xcode/xcshareddata/xcschemes/Amplify-Build.xcscheme b/.swiftpm/xcode/xcshareddata/xcschemes/Amplify-Build.xcscheme new file mode 100644 index 0000000000..dd2eea7c5b --- /dev/null +++ b/.swiftpm/xcode/xcshareddata/xcschemes/Amplify-Build.xcscheme @@ -0,0 +1,211 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +