89 lines
3 KiB
YAML
89 lines
3 KiB
YAML
name: 'Cache Restore Action'
|
|
description: 'Restores caches of downloaded files and build artifacts.'
|
|
author: 'Andrew Kaster <akaster@serenityos.org>'
|
|
|
|
inputs:
|
|
os:
|
|
description: 'Operating System to restore caches for'
|
|
required: true
|
|
arch:
|
|
description: 'Target Architecture to restore caches for'
|
|
required: true
|
|
toolchain:
|
|
description: 'Toolchain to restore caches for (GNU or Clang)'
|
|
required: true
|
|
cache_key_extra:
|
|
description: 'Code coverage setting, ON or OFF, or debug setting, ALL or NORMAL'
|
|
required: true
|
|
ccache_path:
|
|
description: 'Path to the ccache directory'
|
|
required: true
|
|
vcpkg_cache_path:
|
|
description: 'Path to vcpkg binary cache'
|
|
required: true
|
|
|
|
outputs:
|
|
ccache_primary_key:
|
|
description: 'Primary ccache key'
|
|
value: ${{ steps.ccache.outputs.cache-primary-key }}
|
|
vcpkg_cache_primary_key:
|
|
description: 'Primary vcpkg binary cache key'
|
|
value: ${{ steps.vcpkg.outputs.cache-primary-key }}
|
|
|
|
runs:
|
|
using: "composite"
|
|
steps:
|
|
- name: 'Date Stamp'
|
|
shell: bash
|
|
id: 'date-stamp'
|
|
run: |
|
|
echo "timestamp=$(date -u "+%Y%m%d%H%M_%S")" >> "$GITHUB_OUTPUT"
|
|
|
|
- name: 'Compiler Cache'
|
|
uses: actions/cache/restore@v5
|
|
id: 'ccache'
|
|
with:
|
|
path: ${{ inputs.ccache_path }}
|
|
key: ccache | ${{ inputs.os }} | ${{ inputs.arch }} | ${{ inputs.toolchain }} | ${{ inputs.cache_key_extra }} | ${{ steps.date-stamp.outputs.timestamp }}
|
|
restore-keys: |
|
|
ccache | ${{ inputs.os }} | ${{ inputs.arch }} | ${{ inputs.toolchain }} | ${{ inputs.cache_key_extra }}
|
|
|
|
- name: 'Configure Compiler Cache'
|
|
if: ${{ inputs.os != 'Windows' }}
|
|
shell: bash
|
|
env:
|
|
CCACHE_DIR: ${{ inputs.ccache_path }}
|
|
run: |
|
|
ccache -M 0
|
|
|
|
# Reset all ccache modification dates to a known epoch. This provides a baseline that we can prune against.
|
|
find "${{ inputs.ccache_path }}" | tac | xargs touch -a -m -d "2018-10-10T09:53:07Z"
|
|
|
|
ccache -s
|
|
ccache -z
|
|
|
|
- name: 'Configure Compiler Cache (Windows)'
|
|
if: ${{ inputs.os == 'Windows' }}
|
|
shell: pwsh
|
|
env:
|
|
CCACHE_DIR: ${{ inputs.ccache_path }}
|
|
run: |
|
|
ccache -M 0
|
|
|
|
# Reset all ccache modification dates to a known epoch. This provides a baseline that we can prune against.
|
|
Get-ChildItem -Path "${{ inputs.ccache_path }}" -Recurse | Sort-Object FullName -Descending | ForEach-Object {
|
|
$_.LastWriteTime = [DateTime]::Parse("2018-10-10T09:53:07Z")
|
|
$_.LastAccessTime = [DateTime]::Parse("2018-10-10T09:53:07Z")
|
|
}
|
|
|
|
ccache -s
|
|
ccache -z
|
|
|
|
- name: 'Restore vcpkg cache'
|
|
uses: actions/cache/restore@v5
|
|
id: 'vcpkg'
|
|
with:
|
|
path: ${{ inputs.vcpkg_cache_path }}
|
|
key: vcpkg | ${{ inputs.os }} | ${{ inputs.arch }} | ${{ inputs.toolchain }} | ${{ inputs.cache_key_extra }} | ${{ hashFiles('vcpkg.json') }}
|
|
restore-keys: |
|
|
vcpkg | ${{ inputs.os }} | ${{ inputs.arch }} | ${{ inputs.toolchain }} | ${{ inputs.cache_key_extra }}
|