From da2969008bd888dc085e93cb247b3d42cb607e89 Mon Sep 17 00:00:00 2001 From: ayeteadoe Date: Sun, 3 Aug 2025 16:57:18 -0700 Subject: [PATCH] CI: Enable compiler cache for Windows --- .github/actions/cache-restore/action.yml | 27 ++++++++++++++++++++---- .github/actions/cache-save/action.yml | 8 +++++-- .github/workflows/lagom-template.yml | 6 +++--- 3 files changed, 32 insertions(+), 9 deletions(-) diff --git a/.github/actions/cache-restore/action.yml b/.github/actions/cache-restore/action.yml index adea9a2ccdb..0ea1d3aafaa 100644 --- a/.github/actions/cache-restore/action.yml +++ b/.github/actions/cache-restore/action.yml @@ -67,16 +67,35 @@ runs: "ccache" | "${{ inputs.os }}" | "${{ inputs.arch }}" | "${{ inputs.toolchain }}" | "${{ inputs.cache_key_extra }}" | "${{ inputs.ccache_version }}" - name: 'Configure Compiler Cache' - if: ${{ inputs.ccache_path != '' }} + if: ${{ inputs.os != 'Windows' && inputs.ccache_path != '' }} shell: bash + env: + CCACHE_DIR: ${{ inputs.ccache_path }} run: | - CCACHE_DIR=${{ inputs.ccache_path }} ccache -M 0 + 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_DIR=${{ inputs.ccache_path }} ccache -s - CCACHE_DIR=${{ inputs.ccache_path }} ccache -z + ccache -s + ccache -z + + - name: 'Configure Compiler Cache (Windows)' + if: ${{ inputs.os == 'Windows' && inputs.ccache_path != '' }} + 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@v4 diff --git a/.github/actions/cache-save/action.yml b/.github/actions/cache-save/action.yml index 1100ef15b71..09d52497b75 100644 --- a/.github/actions/cache-save/action.yml +++ b/.github/actions/cache-save/action.yml @@ -32,9 +32,11 @@ runs: steps: - name: 'Prune obsolete ccache files' shell: bash + env: + CCACHE_DIR: ${{ inputs.ccache_path }} if: ${{ inputs.ccache_path != '' }} run: | - CCACHE_DIR=${{ inputs.ccache_path }} ccache --evict-older-than=1d + ccache --evict-older-than=1d - name: 'Compiler Cache' uses: actions/cache/save@v4 @@ -45,9 +47,11 @@ runs: - name: 'Cache Stats' shell: bash + env: + CCACHE_DIR: ${{ inputs.ccache_path }} if: ${{ inputs.ccache_path != '' }} run: | - CCACHE_DIR=${{ inputs.ccache_path }} ccache -s + ccache -s - name: 'vcpkg binary cache' uses: actions/cache/save@v4 diff --git a/.github/workflows/lagom-template.yml b/.github/workflows/lagom-template.yml index d86124588f5..6c1f9474e5c 100644 --- a/.github/workflows/lagom-template.yml +++ b/.github/workflows/lagom-template.yml @@ -28,7 +28,7 @@ env: # github.workspace = /home/runner/work/ladybird/ladybird LADYBIRD_SOURCE_DIR: ${{ github.workspace }} CCACHE_DIR: ${{ github.workspace }}/.ccache - VCPKG_ROOT: ${{ github.workspace }}/Build/vcpkg + VCPKG_ROOT: ${{ github.workspace }}/Build/vcpkg # Use the compiler version for the ccache compiler hash. Otherwise, if plugins are enabled, the plugin .so files # are included in the hash. This results in clean builds on every run as the .so files are rebuilt. @@ -109,7 +109,7 @@ jobs: arch: ${{ inputs.arch }} toolchain: ${{ inputs.toolchain }} cache_key_extra: ${{ inputs.os_name == 'Windows' && inputs.build_preset || steps.build-parameters.outputs.ccache_key }} - ccache_path: ${{ inputs.os_name != 'Windows' && env.CCACHE_DIR }} + ccache_path: ${{ env.CCACHE_DIR }} download_cache_path: ${{ github.workspace }}/Build/caches vcpkg_cache_path: ${{ github.workspace }}/Build/caches/vcpkg-binary-cache @@ -189,7 +189,7 @@ jobs: with: runner_labels: ${{ inputs.runner_labels }} arch: ${{ inputs.arch }} - ccache_path: ${{ inputs.os_name != 'Windows' && env.CCACHE_DIR }} + ccache_path: ${{ env.CCACHE_DIR }} ccache_primary_key: ${{ steps.cache-restore.outputs.ccache_primary_key }} vcpkg_cache_path: ${{ github.workspace }}/Build/caches/vcpkg-binary-cache vcpkg_cache_primary_key: ${{ steps.cache-restore.outputs.vcpkg_cache_primary_key }}