ci: use local action to make make cache keys consistent (#20538)

The advantages of using an action is that it reduces boilerplate and
repetition from the main ci.yml workflow.
This commit is contained in:
dundargoc
2022-12-05 11:57:52 +01:00
committed by GitHub
parent 89374da798
commit 9d8dbd9846
2 changed files with 27 additions and 22 deletions

22
.github/actions/cache/action.yml vendored Normal file
View File

@@ -0,0 +1,22 @@
name: 'Cache'
description: "This action caches neovim dependencies"
runs:
using: "composite"
steps:
- run: echo "CACHE_KEY=${{ github.job }}-${{ github.base_ref }}" >> $GITHUB_ENV
shell: bash
- if: ${{ matrix }}
run: echo "CACHE_KEY=$CACHE_KEY-${{ join(matrix.*, '-') }}" >> $GITHUB_ENV
shell: bash
# Avoid using '**/CMakeLists.txt' (or any pattern starting with '**/') even
# if it makes the expression below simpler. hashFiles() has a timer that
# will fail the job if it times out, which can happen if there are too many
# files to search through.
- uses: actions/cache@v3
with:
path: ${{ env.CACHE_NVIM_DEPS_DIR }}
key: ${{ env.CACHE_KEY }}-${{ hashFiles('cmake**', 'ci/**',
'.github/workflows/ci.yml', 'CMakeLists.txt',
'runtime/CMakeLists.txt', 'src/nvim/**/CMakeLists.txt') }}