Browse Source

CI: Update ccache cache entries to enable restoration from master branch

Current caching steps do not use a coarse restore key to enable cache
restoration from a possible master cache. This is a forward-port of a
future CI workflow update that uses the same cache key logic.

Also fixes missing generator token for cache keys generated by master
branch.

(cherry picked from commit f1c7296ac25ed72c4758ae02c2da6a8d9842f196)
PatTheMav 2 years ago
parent
commit
cf2af3a5b4
1 changed files with 18 additions and 5 deletions
  1. 18 5
      .github/workflows/main.yml

+ 18 - 5
.github/workflows/main.yml

@@ -106,10 +106,19 @@ jobs:
 
 
       - name: 'Check for GitHub Labels'
       - name: 'Check for GitHub Labels'
         id: github-check
         id: github-check
-        if: github.event_name == 'pull_request'
         run: |
         run: |
-          if test -n "$(curl -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" -s "${{ github.event.pull_request.url }}" | jq -e '.labels[] | select(.name == "Seeking Testers")')"; then
-            echo "generator=Xcode" >> $GITHUB_OUTPUT
+          if [[ "${GITHUB_EVENT_NAME}" == 'pull_request' ]]; then
+            if test -n "$(curl -H "Authorization: Bearer ${{ github.token }}" -s "${{ github.event.pull_request.url }}" | jq -e '.labels[] | select(.name == "Seeking Testers")')"; then
+              echo "generator=Xcode" >> $GITHUB_OUTPUT
+            else
+              echo "generator=Ninja" >> $GITHUB_OUTPUT
+            fi
+          elif [[ "${GITHUB_EVENT_NAME}" == 'push' ]]; then
+            if [[ ${GITHUB_REF_NAME} =~ [0-9]+.[0-9]+.[0-9]+(-(rc|beta).+)? ]]; then
+              echo "generator=Xcode" >> $GITHUB_OUTPUT
+            else
+              echo "generator=Ninja" >> $GITHUB_OUTPUT
+            fi
           else
           else
             echo "generator=Ninja" >> $GITHUB_OUTPUT
             echo "generator=Ninja" >> $GITHUB_OUTPUT
           fi
           fi
@@ -119,7 +128,9 @@ jobs:
         uses: actions/cache@v3
         uses: actions/cache@v3
         with:
         with:
           path: ${{ github.workspace }}/.ccache
           path: ${{ github.workspace }}/.ccache
-          key: ${{ runner.os }}-${{ github.ref_name }}-${{ steps.github-check.outputs.generator }}-ccache-${{ matrix.arch }}-${{ needs.config.outputs.cache_date }}
+          key: ${{ runner.os }}-ccache-${{ steps.github-check.outputs.generator }}-${{ matrix.arch }}-${{ github.event_name }}-${{ github.head_ref }}
+          restore-keys: |
+            ${{ runner.os }}-ccache-${{ steps.github-check.outputs.generator }}-${{ matrix.arch }}-push-
 
 
       - name: 'Setup build environment'
       - name: 'Setup build environment'
         id: setup
         id: setup
@@ -215,7 +226,9 @@ jobs:
           CACHE_NAME: 'ccache-cache'
           CACHE_NAME: 'ccache-cache'
         with:
         with:
           path: ${{ github.workspace }}/.ccache
           path: ${{ github.workspace }}/.ccache
-          key: ${{ runner.os }}-pr-${{ env.CACHE_NAME }}-${{ matrix.ubuntu }}-${{ needs.config.outputs.cache_date }}
+          key: ${{ runner.os }}-ccache-${{ matrix.ubuntu }}-${{ github.event_name }}-${{ github.head_ref }}
+          restore-keys: |
+            ${{ runner.os }}-ccache-${{ matrix.ubuntu }}-push-
 
 
       - name: 'Restore Chromium Embedded Framework from cache'
       - name: 'Restore Chromium Embedded Framework from cache'
         id: cef-cache
         id: cef-cache