Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: add action workflow for ensuring minimum sdk version support #3462

Merged
merged 3 commits into from
Jan 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
30 changes: 22 additions & 8 deletions .github/workflows/build_amplify_swift.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,26 @@ on:
type: string
required: true

xcode-version:
type: string
default: '14.3'

os-runner:
type: string
default: 'macos-13'

cacheable:
type: boolean
default: true

permissions:
contents: read
actions: write

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
Expand All @@ -25,10 +37,11 @@ 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
if: inputs.cacheable
timeout-minutes: 4
continue-on-error: true
uses: actions/cache/restore@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1
Expand All @@ -40,6 +53,7 @@ jobs:

- name: Attempt to restore the build cache from main
id: build-cache
if: inputs.cacheable
timeout-minutes: 4
continue-on-error: true
uses: actions/cache/restore@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1
Expand All @@ -55,28 +69,28 @@ 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 }}

- name: Save the dependencies cache in main
if: 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: 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
run: |
gh cache delete ${{ steps.build-cache.outputs.cache-primary-key }}

- name: Save the build cache
if: github.ref_name == 'main'
if: inputs.cacheable && github.ref_name == 'main'
uses: actions/cache/save@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1
with:
path: ${{ github.workspace }}/Build
Expand Down
50 changes: 50 additions & 0 deletions .github/workflows/build_minimum_supported_swift_platforms.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Calling this workflow here as is will result in the build cache being overwritten.

You could add a new optional boolean input that allows to skip the Save the dependencies cache in main step in build_amplify_swift.yml.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks! will update it.

with:
os-runner: ${{ matrix.os-runner }}
xcode-version: ${{ matrix.xcode-version }}
platform: ${{ matrix.platform }}
cacheable: false

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
Loading