Replace GitHub cache action with local runner cache
This commit is contained in:
@@ -47,19 +47,30 @@ jobs:
|
||||
fetch-tags: true
|
||||
submodules: false
|
||||
|
||||
- name: Prepare submodule cache key
|
||||
- name: Prepare cache keys
|
||||
run: |
|
||||
git submodule status --cached --recursive > .ci-submodules.lock
|
||||
DEPENDS_KEY="$(cat contrib/depends/Makefile contrib/depends/funcs.mk contrib/depends/hosts/*.mk contrib/depends/packages/*.mk contrib/depends/toolchain.cmake.in | sha256sum | cut -d' ' -f1)"
|
||||
echo "EXTERNAL_CACHE_KEY=$(sha256sum .ci-submodules.lock | cut -d' ' -f1)" >> "$GITHUB_ENV"
|
||||
echo "DEPENDS_CACHE_KEY=${DEPENDS_KEY}" >> "$GITHUB_ENV"
|
||||
|
||||
- name: Restore external cache
|
||||
id: cache-external
|
||||
uses: https://github.com/actions/cache@v3
|
||||
with:
|
||||
path: external
|
||||
key: external-${{ hashFiles('.ci-submodules.lock') }}
|
||||
run: |
|
||||
CACHE_ROOT="${RUNNER_TOOL_CACHE:-/tmp}/peya-ci"
|
||||
EXTERNAL_ARCHIVE="${CACHE_ROOT}/external-${EXTERNAL_CACHE_KEY}.tar.zst"
|
||||
if [ -f "${EXTERNAL_ARCHIVE}" ]; then
|
||||
echo "Restoring external cache from ${EXTERNAL_ARCHIVE}"
|
||||
rm -rf external
|
||||
mkdir -p external
|
||||
tar --zstd -xf "${EXTERNAL_ARCHIVE}"
|
||||
echo "EXTERNAL_CACHE_HIT=true" >> "$GITHUB_ENV"
|
||||
else
|
||||
echo "No external cache found"
|
||||
echo "EXTERNAL_CACHE_HIT=false" >> "$GITHUB_ENV"
|
||||
fi
|
||||
|
||||
- name: Sync submodules
|
||||
if: steps.cache-external.outputs.cache-hit != 'true'
|
||||
if: env.EXTERNAL_CACHE_HIT != 'true'
|
||||
run: |
|
||||
git submodule sync --recursive
|
||||
git submodule update --init --recursive --depth 1
|
||||
@@ -84,15 +95,17 @@ jobs:
|
||||
${{ matrix.toolchain.packages }}
|
||||
|
||||
- name: Restore depends cache
|
||||
id: cache-depends
|
||||
uses: https://github.com/actions/cache@v3
|
||||
with:
|
||||
path: |
|
||||
contrib/depends/built
|
||||
contrib/depends/sources
|
||||
contrib/depends/work/build
|
||||
contrib/depends/${{ matrix.toolchain.host }}
|
||||
key: depends-${{ matrix.toolchain.host }}-${{ hashFiles('contrib/depends/Makefile', 'contrib/depends/funcs.mk', 'contrib/depends/hosts/*.mk', 'contrib/depends/packages/*.mk', 'contrib/depends/toolchain.cmake.in') }}
|
||||
run: |
|
||||
CACHE_ROOT="${RUNNER_TOOL_CACHE:-/tmp}/peya-ci"
|
||||
DEPENDS_ARCHIVE="${CACHE_ROOT}/depends-${{ matrix.toolchain.host }}-${DEPENDS_CACHE_KEY}.tar.zst"
|
||||
if [ -f "${DEPENDS_ARCHIVE}" ]; then
|
||||
echo "Restoring depends cache from ${DEPENDS_ARCHIVE}"
|
||||
tar --zstd -xf "${DEPENDS_ARCHIVE}"
|
||||
echo "DEPENDS_CACHE_HIT=true" >> "$GITHUB_ENV"
|
||||
else
|
||||
echo "No depends cache found"
|
||||
echo "DEPENDS_CACHE_HIT=false" >> "$GITHUB_ENV"
|
||||
fi
|
||||
|
||||
- name: Prepare MinGW alternatives
|
||||
if: ${{ matrix.toolchain.host == 'x86_64-w64-mingw32' || matrix.toolchain.host == 'i686-w64-mingw32' }}
|
||||
@@ -104,6 +117,30 @@ jobs:
|
||||
run: |
|
||||
make depends target=${{ matrix.toolchain.host }} -j"$(nproc)"
|
||||
|
||||
- name: Save external cache
|
||||
if: success()
|
||||
run: |
|
||||
CACHE_ROOT="${RUNNER_TOOL_CACHE:-/tmp}/peya-ci"
|
||||
EXTERNAL_ARCHIVE="${CACHE_ROOT}/external-${EXTERNAL_CACHE_KEY}.tar.zst"
|
||||
mkdir -p "${CACHE_ROOT}"
|
||||
if [ ! -f "${EXTERNAL_ARCHIVE}" ]; then
|
||||
tar --zstd -cf "${EXTERNAL_ARCHIVE}" external
|
||||
fi
|
||||
|
||||
- name: Save depends cache
|
||||
if: success()
|
||||
run: |
|
||||
CACHE_ROOT="${RUNNER_TOOL_CACHE:-/tmp}/peya-ci"
|
||||
DEPENDS_ARCHIVE="${CACHE_ROOT}/depends-${{ matrix.toolchain.host }}-${DEPENDS_CACHE_KEY}.tar.zst"
|
||||
mkdir -p "${CACHE_ROOT}"
|
||||
if [ ! -f "${DEPENDS_ARCHIVE}" ]; then
|
||||
tar --zstd -cf "${DEPENDS_ARCHIVE}" \
|
||||
contrib/depends/built \
|
||||
contrib/depends/sources \
|
||||
contrib/depends/work/build \
|
||||
contrib/depends/${{ matrix.toolchain.host }}
|
||||
fi
|
||||
|
||||
- name: Package release archive
|
||||
if: ${{ matrix.toolchain.package_artifact }}
|
||||
run: |
|
||||
|
||||
Reference in New Issue
Block a user