ladybird/.github/actions/cache-restore/action.yml
2024-06-03 10:53:53 +02:00

93 lines
3.5 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
default: 'Linux'
arch:
description: 'Target Architecture to restore caches for'
required: false
default: 'x86_64'
toolchain:
description: 'Toolchain to restore caches for (GNU or Clang)'
required: false
default: 'GNU'
cache_key_extra:
description: 'Code coverage setting, ON or OFF, or debug setting, ALL or NORMAL'
required: false
default: 'OFF'
ccache_version:
description: 'Increment this number if CI has trouble with ccache.'
required: false
default: '0'
serenity_ccache_path:
description: 'Path to the SerenityOS ccache directory'
required: false
default: ''
download_cache_path:
description: 'Path to the download cache directory'
required: false
default: 'caches'
outputs:
serenity_ccache_primary_key:
description: 'Primary key for the Serenity ccache'
value: ${{ steps.serenity-ccache.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: 'Serenity Compiler Cache'
uses: actions/cache/restore@v4
id: 'serenity-ccache'
if: ${{ inputs.serenity_ccache_path != '' }}
with:
path: ${{ inputs.serenity_ccache_path }}
key: '"ccache" | "${{ inputs.os }}" | "${{ inputs.arch }}" | "${{ inputs.toolchain }}" | "${{ inputs.cache_key_extra }}" | "${{ inputs.ccache_version }}" | ${{ steps.date-stamp.outputs.timestamp }}'
restore-keys: |
"ccache" | "${{ inputs.os }}" | "${{ inputs.arch }}" | "${{ inputs.toolchain }}" | "${{ inputs.cache_key_extra }}" | "${{ inputs.ccache_version }}"
- name: 'Configure Serenity ccache'
if: ${{ inputs.serenity_ccache_path != '' }}
shell: bash
run: |
CCACHE_DIR=${{ inputs.serenity_ccache_path }} ccache -M 0
# Reset all ccache modification dates to a known epoch. This provides a baseline that we can prune against.
find ${{ inputs.serenity_ccache_path }} | tac | xargs touch -a -m -d "2018-10-10T09:53:07Z"
CCACHE_DIR=${{ inputs.serenity_ccache_path }} ccache -s
CCACHE_DIR=${{ inputs.serenity_ccache_path }} ccache -z
- name: 'TimeZoneData cache'
uses: actions/cache@v4
with:
path: ${{ inputs.download_cache_path }}/TZDB
key: TimeZoneData-${{ hashFiles('Meta/CMake/time_zone_data.cmake') }}-${{ steps.date-stamp.outputs.timestamp }}
restore-keys: |
TimeZoneData-${{ hashFiles('Meta/CMake/time_zone_data.cmake') }}
- name: 'UnicodeData cache'
uses: actions/cache@v4
with:
path: ${{ inputs.download_cache_path }}/UCD
key: UnicodeData-${{ hashFiles('Meta/CMake/unicode_data.cmake') }}-${{ steps.date-stamp.outputs.timestamp }}
restore-keys: |
UnicodeData-${{ hashFiles('Meta/CMake/unicode_data.cmake') }}
- name: 'UnicodeLocale cache'
uses: actions/cache@v4
with:
path: ${{ inputs.download_cache_path }}/CLDR
key: UnicodeLocale-${{ hashFiles('Meta/CMake/locale_data.cmake') }}-${{ steps.date-stamp.outputs.timestamp }}
restore-keys: |
UnicodeLocale-${{ hashFiles('Meta/CMake/locale_data.cmake') }}