diff --git a/.github/workflows/deploy_package.yml b/.github/workflows/deploy_package.yml index ddccd83258..209bcf863a 100644 --- a/.github/workflows/deploy_package.yml +++ b/.github/workflows/deploy_package.yml @@ -11,6 +11,7 @@ on: permissions: id-token: write contents: write + actions: write jobs: build-amplify-swift: diff --git a/.github/workflows/deploy_release.yml b/.github/workflows/deploy_release.yml index 71a913672d..62996eebe5 100644 --- a/.github/workflows/deploy_release.yml +++ b/.github/workflows/deploy_release.yml @@ -7,6 +7,7 @@ on: permissions: id-token: write contents: write + actions: write jobs: release-stable: diff --git a/.github/workflows/deploy_unstable.yml b/.github/workflows/deploy_unstable.yml index f0f02c7cad..7a91b886b5 100644 --- a/.github/workflows/deploy_unstable.yml +++ b/.github/workflows/deploy_unstable.yml @@ -7,6 +7,7 @@ on: permissions: id-token: write contents: write + actions: write jobs: release-unstable: diff --git a/.github/workflows/run_xcodebuild_test_platforms.yml b/.github/workflows/run_xcodebuild_test_platforms.yml index 03a75c204c..0400a12a53 100644 --- a/.github/workflows/run_xcodebuild_test_platforms.yml +++ b/.github/workflows/run_xcodebuild_test_platforms.yml @@ -32,6 +32,7 @@ env: permissions: contents: read + actions: write jobs: test-iOS: @@ -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' }} @@ -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 @@ -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' }} @@ -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 @@ -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' }} @@ -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 @@ -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' }} @@ -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 }} diff --git a/.github/workflows/unit_test.yml b/.github/workflows/unit_test.yml index e7678b69d0..d329901675 100644 --- a/.github/workflows/unit_test.yml +++ b/.github/workflows/unit_test.yml @@ -14,6 +14,7 @@ on: permissions: contents: read + actions: write concurrency: group: ${{ inputs.identifier || github.workflow }}-${{ github.event.pull_request.number || github.ref }}