Skip to content

github action to speedup building using ccache

License

Notifications You must be signed in to change notification settings

hzeller/ccache-action

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ccache for gh actions

A Github action to speedup building using ccache for C/C++ projects.

Example usage

- name: ccache
  uses: hendrikmuhs/ccache-action@v1

NB! This should always come after the actions/checkout step.

In order to use ccache in your other steps, point the compiler to it, e.g. with run-cmake:

- name: build with cmake
  uses: lukka/run-cmake@v3
  with:
    cmakeListsOrSettingsJson: CMakeListsTxtAdvanced
    cmakeAppendedArgs: '-DCMAKE_BUILD_TYPE=${{ matrix.type }} -D CMAKE_C_COMPILER_LAUNCHER=ccache -D CMAKE_CXX_COMPILER_LAUNCHER=ccache'
    ...

or by manipulating PATH:

- name: build
  run: |
    export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"

(works for both ubuntu and macos)

Ccache gets installed by this action, if its not installed yet.

Configuration

If you have multiple targets(Debug, Release) and/or multiple OS's, it makes sense to cache them separetely. An additional cache key can be specified. You can also specify the maximum cache size - default 500M (500 MB).

- name: ccache
  uses: hendrikmuhs/ccache-action@v1
  with:
    key: ${{ matrix.os }}-${{ matrix.type }}
    max-size: 100M

How it works

This action is based on https://cristianadam.eu/20200113/speeding-up-c-plus-plus-github-actions-using-ccache/

In a nutshell, the .ccache folder is configured in the runner path and the folder is persisted and reloaded using cache. For more details see: https://docs.github.com/en/free-pro-team@latest/actions/guides/caching-dependencies-to-speed-up-workflows.

Stats

Stats are provided as part of the post action, check the output to see if cache is effective.

Example workflow

About

github action to speedup building using ccache

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • TypeScript 100.0%