Skip to content

Commit

Permalink
CI: add workaround for nested composite actions issue
Browse files Browse the repository at this point in the history
Because of actions/runner#2009 the deeply
nested action cache was failing to save the cache in the post run phase.

For the moment we just avoid the nesting with a copy-pasted action
snippet.
  • Loading branch information
redsun82 committed Nov 30, 2022
1 parent da57307 commit 8563859
Showing 1 changed file with 41 additions and 3 deletions.
44 changes: 41 additions & 3 deletions .github/actions/cache-query-compilation/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,49 @@ outputs:
runs:
using: composite
steps:
- name: Cache the query compilation caches
uses: ./.github/actions/incremental-cache
# FIXME: because of https://github.com/actions/runner/issues/2009, nested composite actions with inputs have their
# post actions broken. So instead of reusing incremental-cache (which would have the nested cache action not able
# to save the cache in the post-action phase), we are just copy-pasting the steps here
# - name: Cache the query compilation caches
# uses: ./.github/actions/incremental-cache
# with:
# path: '**/.cache'
# key: codeql-compile-${{ inputs.key }}
# start of copy-paste from ./.github/actions/incremental-cache (replacing inputs.path with '**/.cache')
# calculate the merge-base with main, in a way that works both on PRs and pushes to main.
- name: Calculate merge-base
shell: bash
if: ${{ github.event_name == 'pull_request' }}
env:
BASE_BRANCH: ${{ github.base_ref }}
run: |
MERGE_BASE=$(git cat-file commit $GITHUB_SHA | grep '^parent ' | head -1 | cut -f 2 -d " ")
echo "merge_base=$MERGE_BASE" >> $GITHUB_ENV
- name: Restore read-only cache (PR)
if: ${{ github.event_name == 'pull_request' }}
uses: erik-krogh/actions-cache@a88d0603fe5fb5606db9f002dfcadeb32b5f84c6
with:
<<<<<<< Updated upstream
path: ${{ inputs.path }}
=======
path: '**/.cache'
>>>>>>> Stashed changes
read-only: true
key: ${{ inputs.key }}-pr-${{ github.sha }}
restore-keys: |
${{ inputs.key }}-${{ github.base_ref }}-${{ env.merge_base }}
${{ inputs.key }}-${{ github.base_ref }}-
${{ inputs.key }}-main-
- name: Fill cache (push)
if: ${{ github.event_name != 'pull_request' }}
uses: erik-krogh/actions-cache@a88d0603fe5fb5606db9f002dfcadeb32b5f84c6
with:
path: '**/.cache'
key: codeql-compile-${{ inputs.key }}
key: ${{ inputs.key }}-${{ github.ref_name }}-${{ github.sha }} # just fill on main
restore-keys: | # restore the latest cache if the exact cache is unavailable, to speed up compilation.
${{ inputs.key }}-${{ github.ref_name }}-
${{ inputs.key }}-main-
# end of copy-paste
- name: Fill compilation cache directory
id: fill-compilation-dir
shell: bash
Expand Down

0 comments on commit 8563859

Please sign in to comment.