How to simplify matrix key for usage with ccache?

54 views Asked by At

Currently I have a job on linux with a fairly complex matrix.

jobs:
  linux:
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        os: [ubuntu-22.04, ...]
        compiler: [{cc: gcc, cxx: g++}, {cc:clang, cxx:clang++}]
        config: [debug, release]
        cpp_std: [17, 20]
        ... # Address sanitizer, thread sanitizer, etc.

And I'm using ccache. So I need to make a unique key for the job. However, the more I complicate the matrix the more complicated the key gets.

Here is what I mean

- name: Setup ccache
  uses: hendrikmuhs/[email protected]
  with:
    key: ${{ matrix.os }}-${{ matrix.config }}-${{ matrix.compiler.cc }}-${{ matrix.compiler.cxx }}-${{ matrix.cpp_std }}-${{ matrix.flags.c }}-${{ matrix.flags.ld }}

The key is over 158 characters and is very easy to forget to update correctly.

Is there a better way to write this?

0

There are 0 answers