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

chore: Caching the build folder for unit test schemes #3200

Merged
merged 11 commits into from
Oct 4, 2023
1 change: 1 addition & 0 deletions .github/workflows/deploy_package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ on:
permissions:
id-token: write
contents: write
actions: write

jobs:
build-amplify-swift:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/deploy_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ on:
permissions:
id-token: write
contents: write
actions: write

jobs:
release-stable:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/deploy_unstable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ on:
permissions:
id-token: write
contents: write
actions: write

jobs:
release-unstable:
Expand Down
157 changes: 149 additions & 8 deletions .github/workflows/run_xcodebuild_test_platforms.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ env:

permissions:
contents: read
actions: write

jobs:
test-iOS:
Expand All @@ -52,12 +53,25 @@ jobs:
key: amplify-packages-${{ hashFiles('Package.resolved') }}
restore-keys: |
amplify-packages-
- name: Attempt to restore the build cache
- name: Attempt to restore the build cache for this SHA
id: restore-build
timeout-minutes: 4
continue-on-error: true
uses: actions/cache/restore@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1
with:
path: ${{ github.workspace }}/Build
key: ${{ env.SCHEME }}-iOS-build-${{ github.sha }}
restore-keys: |
${{ env.SCHEME }}-iOS-build-
- name: Attempt to restore the build cache from main
if: steps.restore-build.outputs.cache-hit != 'true'
id: restore-main-build
timeout-minutes: 4
continue-on-error: true
uses: actions/cache/restore@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1
with:
path: ${{ github.workspace }}/Build
key: ${{ env.SCHEME }}-iOS-latest-build-main
- name: Run iOS Test Suite
id: run-tests
continue-on-error: ${{ env.RETRY_ON_ERROR == 'true' }}
Expand Down Expand Up @@ -86,12 +100,34 @@ jobs:
disable_package_resolution: true
test_without_building: true
other_flags: ${{ inputs.other_flags }}
- name: Save the build cache for re-runs
- name: Save the SHA build cache for re-runs
if: failure() && steps.retry-tests.outcome=='failure'
uses: actions/cache/save@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1
with:
path: ${{ github.workspace }}/Build
key: ${{ env.SCHEME }}-iOS-build-${{ github.sha }}
- name: Delete the SHA build cache on re-run success
if: steps.restore-build.outputs.cache-matched-key
env:
GH_TOKEN: ${{ github.token }}
continue-on-error: true
run: |
gh cache delete ${{ steps.restore-build.outputs.cache-matched-key }}
shell: bash
- name: Delete the old build cache on main
if: github.ref_name == 'main' && steps.restore-main-build.outputs.cache-hit
env:
GH_TOKEN: ${{ github.token }}
continue-on-error: true
run: |
gh cache delete ${{ steps.restore-main-build.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.restore-main-build.outputs.cache-primary-key }}
- name: Upload Report File
if: ${{ inputs.generate_coverage_report == true }}
uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce #v3.1.2
Expand Down Expand Up @@ -120,12 +156,25 @@ jobs:
key: amplify-packages-${{ hashFiles('Package.resolved') }}
restore-keys: |
amplify-packages-
- name: Attempt to restore the build cache
- name: Attempt to restore the build cache for this SHA
id: restore-build
timeout-minutes: 4
continue-on-error: true
uses: actions/cache/restore@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1
with:
path: ${{ github.workspace }}/Build
key: ${{ env.SCHEME }}-macOS-build-${{ github.sha }}
restore-keys: |
${{ env.SCHEME }}-macOS-build-
- name: Attempt to restore the build cache from main
if: steps.restore-build.outputs.cache-hit != 'true'
id: restore-main-build
timeout-minutes: 4
continue-on-error: true
uses: actions/cache/restore@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1
with:
path: ${{ github.workspace }}/Build
key: ${{ env.SCHEME }}-macOS-latest-build-main
- name: Run macOS Test Suite
id: run-tests
continue-on-error: ${{ env.RETRY_ON_ERROR == 'true' }}
Expand Down Expand Up @@ -154,12 +203,34 @@ jobs:
disable_package_resolution: true
test_without_building: true
other_flags: ${{ inputs.other_flags }}
- name: Save the build cache for re-runs
- name: Save the SHA build cache for re-runs
if: failure() && steps.retry-tests.outcome=='failure'
uses: actions/cache/save@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1
with:
path: ${{ github.workspace }}/Build
key: ${{ env.SCHEME }}-macOS-build-${{ github.sha }}
- name: Delete the SHA build cache on re-run success
if: steps.restore-build.outputs.cache-matched-key
env:
GH_TOKEN: ${{ github.token }}
continue-on-error: true
run: |
gh cache delete ${{ steps.restore-build.outputs.cache-matched-key }}
shell: bash
- name: Delete the old build cache on main
if: github.ref_name == 'main' && steps.restore-main-build.outputs.cache-hit
env:
GH_TOKEN: ${{ github.token }}
continue-on-error: true
run: |
gh cache delete ${{ steps.restore-main-build.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.restore-main-build.outputs.cache-primary-key }}

test-tvOS:
name: ${{ inputs.scheme }} tvOS Tests
Expand All @@ -179,12 +250,25 @@ jobs:
key: amplify-packages-${{ hashFiles('Package.resolved') }}
restore-keys: |
amplify-packages-
- name: Attempt to restore the build cache
- name: Attempt to restore the build cache for this SHA
id: restore-build
timeout-minutes: 4
continue-on-error: true
uses: actions/cache/restore@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1
with:
path: ${{ github.workspace }}/Build
key: ${{ env.SCHEME }}-tvOS-build-${{ github.sha }}
restore-keys: |
${{ env.SCHEME }}-tvOS-build-
- name: Attempt to restore the build cache from main
if: steps.restore-build.outputs.cache-hit != 'true'
id: restore-main-build
timeout-minutes: 4
continue-on-error: true
uses: actions/cache/restore@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1
with:
path: ${{ github.workspace }}/Build
key: ${{ env.SCHEME }}-tvOS-latest-build-main
- name: Run tvOS Test Suite
id: run-tests
continue-on-error: ${{ env.RETRY_ON_ERROR == 'true' }}
Expand Down Expand Up @@ -213,12 +297,34 @@ jobs:
disable_package_resolution: true
test_without_building: true
other_flags: ${{ inputs.other_flags }}
- name: Save the build cache for re-runs
- name: Save the SHA build cache for re-runs
if: failure() && steps.retry-tests.outcome=='failure'
uses: actions/cache/save@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1
with:
path: ${{ github.workspace }}/Build
key: ${{ env.SCHEME }}-tvOS-build-${{ github.sha }}
- name: Delete the SHA build cache on re-run success
if: steps.restore-build.outputs.cache-matched-key
env:
GH_TOKEN: ${{ github.token }}
continue-on-error: true
run: |
gh cache delete ${{ steps.restore-build.outputs.cache-matched-key }}
shell: bash
- name: Delete the old build cache on main
if: github.ref_name == 'main' && steps.restore-main-build.outputs.cache-hit
env:
GH_TOKEN: ${{ github.token }}
continue-on-error: true
run: |
gh cache delete ${{ steps.restore-main-build.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.restore-main-build.outputs.cache-primary-key }}

test-watchOS:
name: ${{ inputs.scheme }} watchOS Tests
Expand All @@ -238,12 +344,25 @@ jobs:
key: amplify-packages-${{ hashFiles('Package.resolved') }}
restore-keys: |
amplify-packages-
- name: Attempt to restore the build cache
- name: Attempt to restore the build cache for this SHA
id: restore-build
timeout-minutes: 4
continue-on-error: true
uses: actions/cache/restore@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1
with:
path: ${{ github.workspace }}/Build
key: ${{ env.SCHEME }}-watchOS-build-${{ github.sha }}
restore-keys: |
${{ env.SCHEME }}-watchOS-build-
- name: Attempt to restore the build cache from main
if: steps.restore-build.outputs.cache-hit != 'true'
id: restore-main-build
timeout-minutes: 4
continue-on-error: true
uses: actions/cache/restore@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1
with:
path: ${{ github.workspace }}/Build
key: ${{ env.SCHEME }}-watchOS-latest-build-main
- name: Run watchOS Test Suite
id: run-tests
continue-on-error: ${{ env.RETRY_ON_ERROR == 'true' }}
Expand Down Expand Up @@ -272,9 +391,31 @@ jobs:
disable_package_resolution: true
test_without_building: true
other_flags: ${{ inputs.other_flags }}
- name: Save the build cache for re-runs
- name: Save the SHA build cache for re-runs
if: failure() && steps.retry-tests.outcome=='failure'
uses: actions/cache/save@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1
with:
path: ${{ github.workspace }}/Build
key: ${{ env.SCHEME }}-watchOS-build-${{ github.sha }}
- name: Delete the SHA build cache on re-run success
if: steps.restore-build.outputs.cache-matched-key
env:
GH_TOKEN: ${{ github.token }}
continue-on-error: true
run: |
gh cache delete ${{ steps.restore-build.outputs.cache-matched-key }}
shell: bash
- name: Delete the old build cache on main
if: github.ref_name == 'main' && steps.restore-main-build.outputs.cache-hit
env:
GH_TOKEN: ${{ github.token }}
continue-on-error: true
run: |
gh cache delete ${{ steps.restore-main-build.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.restore-main-build.outputs.cache-primary-key }}
1 change: 1 addition & 0 deletions .github/workflows/unit_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ on:

permissions:
contents: read
actions: write

concurrency:
group: ${{ inputs.identifier || github.workflow }}-${{ github.event.pull_request.number || github.ref }}
Expand Down