Skip to content

Commit

Permalink
chore: deleting old cache and replacing it in each build.
Browse files Browse the repository at this point in the history
  • Loading branch information
ruisebas committed Aug 30, 2023
1 parent 6cb1996 commit ffe3f18
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 19 deletions.
73 changes: 57 additions & 16 deletions .github/workflows/build_amplify_swift_for_testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ on:

permissions:
contents: read
actions: write

concurrency:
group: ${{ inputs.identifier || github.workflow }}-${{ github.event.pull_request.number || github.ref }}
Expand Down Expand Up @@ -40,7 +41,7 @@ jobs:
id: cache-build
timeout-minutes: 4
continue-on-error: true
uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1
uses: actions/cache/restore@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1
with:
path: ${{ github.workspace }}/Build
key: amplify-iOS-latest-build-main
Expand All @@ -53,10 +54,20 @@ jobs:
disable_package_resolution: ${{ steps.cache-packages.outputs.cache-hit }}
build_for_testing: true
other_flags: '-derivedDataPath Build -clonedSourcePackagesDirPath ~/Library/Developer/Xcode/DerivedData/Amplify'
- name: Enforce a cache update
- name: Delete the old build cache
if: steps.cache-build.outputs.cache-hit
env:
GH_TOKEN: ${{ github.token }}
continue-on-error: true
run: |
CACHE_KEY="amplify-iOS-latest-build-$GITHUB_SHA"
echo "STATE_CACHE_RESULT=${CACHE_KEY}" >> $GITHUB_ENV
gh extension install actions/gh-actions-cache
gh actions-cache delete ${{ steps.cache-build.outputs.cache-primary-key }} --confirm
shell: bash
- name: Save the build cache
uses: actions/cache/save@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1
with:
path: ${{ github.workspace }}/Build
key: ${{ steps.cache-build.outputs.cache-primary-key }}

build-for-testing-amplify-swift-macOS:
runs-on: macos-13
Expand All @@ -79,7 +90,7 @@ jobs:
id: cache-build
timeout-minutes: 4
continue-on-error: true
uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1
uses: actions/cache/restore@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1
with:
path: ${{ github.workspace }}/Build
key: amplify-macOS-latest-build-main
Expand All @@ -93,10 +104,20 @@ jobs:
disable_package_resolution: ${{ steps.cache-packages.outputs.cache-hit }}
build_for_testing: true
other_flags: '-derivedDataPath Build -clonedSourcePackagesDirPath ~/Library/Developer/Xcode/DerivedData/Amplify'
- name: Enforce a cache update
- name: Delete the old build cache
if: steps.cache-build.outputs.cache-hit
env:
GH_TOKEN: ${{ github.token }}
continue-on-error: true
run: |
CACHE_KEY="amplify-macOS-latest-build-$GITHUB_SHA"
echo "STATE_CACHE_RESULT=${CACHE_KEY}" >> $GITHUB_ENV
gh extension install actions/gh-actions-cache
gh actions-cache delete ${{ steps.cache-build.outputs.cache-primary-key }} --confirm
shell: bash
- name: Save the build cache
uses: actions/cache/save@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1
with:
path: ${{ github.workspace }}/Build
key: ${{ steps.cache-build.outputs.cache-primary-key }}

build-for-testing-amplify-swift-tvOS:
runs-on: macos-13
Expand All @@ -119,7 +140,7 @@ jobs:
id: cache-build
timeout-minutes: 4
continue-on-error: true
uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1
uses: actions/cache/restore@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1
with:
path: ${{ github.workspace }}/Build
key: amplify-tvOS-latest-build-main
Expand All @@ -133,10 +154,20 @@ jobs:
disable_package_resolution: ${{ steps.cache-packages.outputs.cache-hit }}
build_for_testing: true
other_flags: '-derivedDataPath Build -clonedSourcePackagesDirPath ~/Library/Developer/Xcode/DerivedData/Amplify'
- name: Enforce a cache update
- name: Delete the old build cache
if: steps.cache-build.outputs.cache-hit
env:
GH_TOKEN: ${{ github.token }}
continue-on-error: true
run: |
CACHE_KEY="amplify-tvOS-latest-build-$GITHUB_SHA"
echo "STATE_CACHE_RESULT=${CACHE_KEY}" >> $GITHUB_ENV
gh extension install actions/gh-actions-cache
gh actions-cache delete ${{ steps.cache-build.outputs.cache-primary-key }} --confirm
shell: bash
- name: Save the build cache
uses: actions/cache/save@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1
with:
path: ${{ github.workspace }}/Build
key: ${{ steps.cache-build.outputs.cache-primary-key }}

build-for-testing-amplify-swift-watchOS:
runs-on: macos-13
Expand All @@ -159,7 +190,7 @@ jobs:
id: cache-build
timeout-minutes: 4
continue-on-error: true
uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1
uses: actions/cache/restore@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1
with:
path: ${{ github.workspace }}/Build
key: amplify-watchOS-latest-build-main
Expand All @@ -173,7 +204,17 @@ jobs:
disable_package_resolution: ${{ steps.cache-packages.outputs.cache-hit }}
build_for_testing: true
other_flags: '-derivedDataPath Build -clonedSourcePackagesDirPath ~/Library/Developer/Xcode/DerivedData/Amplify'
- name: Enforce a cache update
- name: Delete the old build cache
if: steps.cache-build.outputs.cache-hit
env:
GH_TOKEN: ${{ github.token }}
continue-on-error: true
run: |
CACHE_KEY="amplify-watchOS-latest-build-$GITHUB_SHA"
echo "STATE_CACHE_RESULT=${CACHE_KEY}" >> $GITHUB_ENV
gh extension install actions/gh-actions-cache
gh actions-cache delete ${{ steps.cache-build.outputs.cache-primary-key }} --confirm
shell: bash
- name: Save the build cache
uses: actions/cache/save@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1
with:
path: ${{ github.workspace }}/Build
key: ${{ steps.cache-build.outputs.cache-primary-key }}
27 changes: 24 additions & 3 deletions .github/workflows/run_xcodebuild_test_platforms.yml
Original file line number Diff line number Diff line change
Expand Up @@ -127,12 +127,19 @@ jobs:
key: amplify-packages-${{ hashFiles('Package.resolved') }}
restore-keys: |
amplify-packages-
- name: Attempt to restore the build cache
- name: Attempt to restore the scheme build cache
id: restore-build
uses: actions/cache/restore@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1
with:
path: ${{ github.workspace }}/Build
key: ${{ env.SCHEME }}-macOS-build-${{ github.sha }}
- name: Attempt to restore the Amplify build cache
if: steps.restore-build.outputs.cache-hit != true
id: restore-amplify-build
uses: actions/cache/restore@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1
with:
path: ${{ github.workspace }}/Build
key: amplify-macOS-latest-build-main
- name: Run macOS Test Suite
id: run-tests
continue-on-error: ${{ env.RETRY_ON_ERROR == 'true' }}
Expand Down Expand Up @@ -186,12 +193,19 @@ jobs:
key: amplify-packages-${{ hashFiles('Package.resolved') }}
restore-keys: |
amplify-packages-
- name: Attempt to restore the build cache
- name: Attempt to restore the scheme build cache
id: restore-build
uses: actions/cache/restore@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1
with:
path: ${{ github.workspace }}/Build
key: ${{ env.SCHEME }}-tvOS-build-${{ github.sha }}
- name: Attempt to restore the Amplify build cache
if: steps.restore-build.outputs.cache-hit != true
id: restore-amplify-build
uses: actions/cache/restore@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1
with:
path: ${{ github.workspace }}/Build
key: amplify-tvOS-latest-build-main
- name: Run tvOS Test Suite
id: run-tests
continue-on-error: ${{ env.RETRY_ON_ERROR == 'true' }}
Expand Down Expand Up @@ -245,12 +259,19 @@ jobs:
key: amplify-packages-${{ hashFiles('Package.resolved') }}
restore-keys: |
amplify-packages-
- name: Attempt to restore the build cache
- name: Attempt to restore the scheme build cache
id: restore-build
uses: actions/cache/restore@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1
with:
path: ${{ github.workspace }}/Build
key: ${{ env.SCHEME }}-watchOS-build-${{ github.sha }}
- name: Attempt to restore the Amplify build cache
if: steps.restore-build.outputs.cache-hit != true
id: restore-amplify-build
uses: actions/cache/restore@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1
with:
path: ${{ github.workspace }}/Build
key: amplify-watchOS-latest-build-main
- name: Run watchOS Test Suite
id: run-tests
continue-on-error: ${{ env.RETRY_ON_ERROR == 'true' }}
Expand Down

0 comments on commit ffe3f18

Please sign in to comment.