Skip to content

Build: Improve cache key generation with build configuration files #92

@m-marinucci

Description

@m-marinucci

Context

As identified in PR #89 review, the cache keys may not be sufficiently robust to all build changes.

Current Issue

Cache key only includes source files:

key: ccache-${{ matrix.compiler }}-${{ hashFiles('tol-master/tol/**/*.cpp', 'tol-master/tol/**/*.h') }}

This misses changes to:

  • CMakeLists.txt files
  • .cmake configuration files
  • Build scripts
  • Dependency specifications

Proposed Solution

Enhanced Cache Key

key: ccache-${{ matrix.compiler }}-${{ hashFiles('tol-master/tol/**/*.cpp', 'tol-master/tol/**/*.h', 'tol-master/tol/CMakeLists.txt', 'tol-master/tol/**/*.cmake', 'tol-master/tol/**/CMakeLists.txt') }}

Additional Improvements

  1. Version cache keys: Add version prefix for breaking changes
  2. Include compiler version: Add compiler version to key
  3. Build type differentiation: Separate Debug/Release caches
  4. Dependency tracking: Include dependency version info

Implementation

env:
  CACHE_VERSION: v1  # Increment for cache-breaking changes

key: |
  ${{ env.CACHE_VERSION }}-
  ccache-
  ${{ matrix.compiler }}-
  ${{ matrix.build_type }}-
  ${{ hashFiles('**/CMakeLists.txt', '**/*.cmake', '**/*.cpp', '**/*.h') }}

Benefits

  • Proper cache invalidation on build system changes
  • Prevents stale cache issues
  • Better build reproducibility
  • Reduced mysterious build failures

Related: PR #89

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions