Giter Site home page Giter Site logo

ccache-action's Introduction

Ccache for gh actions

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

Works on Linux, macOS, and Windows.

Usage

- run: apt update  # Only for Docker jobs
- name: ccache
  uses: hendrikmuhs/[email protected]

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 (ccache only):

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

(works for both ubuntu and macos)

or by setting create-symlink to true:

- name: ccache
  uses: hendrikmuhs/[email protected]
  with:
    create-symlink: true

Ccache/sccache gets installed by this action if it is not installed yet.

Example workflow

Notes on Windows support

Note that using Ccache on Windows is still experimental and works only in Bash. Use Sccache for stable Windows support.

If you have multiple jobs

If you have multiple jobs or targets (eg. Debug, Release) or multiple OS's, it makes sense to cache them separately. An additional cache key can be specified.

jobs:
  some_build:
    steps:
      ...
      - name: ccache
        uses: hendrikmuhs/[email protected]
        with:
          key: ${{ github.job }}-${{ matrix.os }}  # Eg. "some_build-ubuntu-latest"
  some_other_build:
    ...

Other options

See action.yml for a full list of options.

Ccache statistics

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

You may also set verbose input to 1 to enable verbose output from this action or even to 2 to make it even more verbose.

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.

ccache-action's People

Contributors

behrisch avatar botanicvelious avatar chirag-droid avatar compnerd avatar dcvz avatar dependabot[bot] avatar fruffy avatar hansfn avatar hendrikmuhs avatar itrooz avatar janisozaur avatar jkflying avatar jonashaag avatar kendalharland avatar krlmlr avatar mmomtchev avatar mvorisek avatar nerixyz avatar nmoinvaz avatar orgads avatar timangus avatar unidy2002 avatar vadz avatar virtuald avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

ccache-action's Issues

Mismatched SHA256 fingerprint on Windows ccache binary

It seems that the stored fingerprint for the Windows ccache binary does not match. As of today, I'm receiving the following error during the Install ccache phase of the action on Windows runners only:

Error: SHA256 of C:\Users\runneradmin\.cargo\bin\ccache.exe is d61defbaabdb75a9bb61b53b08a35bb302bdd938923e3ae83e08ae34a73e7166, expected 6e0959c518b0c51fa887035465e7486f50079fe9acf711e5dd7ea2d30a824521

I did not change the workflow file at all and it was working perfectly fine the other day. For an example run, see here.

Many thanks for your help!

No cache saved on Windows?

Having trouble with ccache on Windows (thanks for adding support!). My cache is empty for now, so no hits are reported. But there does appear to be something in the cache (and my cmake found ccache): Cache size (GB): 0.09 / 0.50 (18.79 %). Yet, nothing is uploaded.

This is the output I get:

+ ccache -s -v
Summary:
  Cache directory:  D:\a\scipp\scipp\.ccache
  Primary config:   C:\Users\runneradmin/ccache/ccache.conf
  Secondary config: /usr/local/etc/ccache.conf
  Stats updated:    03/24/22 09:39:15
  Hits:                0 /  395 (0.00 %)
    Direct:            0 /  395 (0.00 %)
    Preprocessed:      0 /  395 (0.00 %)
  Misses:            395
    Direct:          395
    Preprocessed:    395
Primary storage:
  Hits:                0 /  790 (0.00 %)
  Misses:            790
  Cache size (GB):  0.09 / 0.50 (18.79 %)
  Files:             790
Not saving cache because no objects are cached.

Mismatched SHA256 fingerprint on Windows ccache binary

It seems that the stored fingerprint for the Windows ccache binary does not match. As of today, I'm receiving the following error during the Install ccache phase of the action on Windows runners only:

Error: SHA256 of C:\Users\runneradmin\.cargo\bin\ccache.exe is d61defbaabdb75a9bb61b53b08a35bb302bdd938923e3ae83e08ae34a73e7166, expected 6e0959c518b0c51fa887035465e7486f50079fe9acf711e5dd7ea2d30a824521

I did not change the workflow file at all and it was working perfectly fine the other day. For an example run, see here.

Many thanks for your help!

Default compiler_check setting does not seem optimal for Github Actions

This is the default config for ccache:

Run ccache --show-config
(default) base_dir = 
(/home/runner/.ccache/ccache.conf) cache_dir = /home/runner/work/realm-kotlin/realm-kotlin/.ccache
(default) cache_dir_levels = 2
(default) compiler = 
(default) compiler_check = mtime
(/home/runner/.ccache/ccache.conf) compression = true
(default) compression_level = 6
(default) cpp_extension = 
(default) debug = false
(default) depend_mode = false
(default) direct_mode = true
(default) disable = false
(default) extra_files_to_hash = 
(default) hard_link = false
(default) hash_dir = true
(default) ignore_headers_in_manifest = 
(default) keep_comments_cpp = false
(default) limit_multiple = 0.8
(default) log_file = 
(default) max_files = 0
(/home/runner/.ccache/ccache.conf) max_size = 500.0M
(default) path = 
(default) pch_external_checksum = false
(default) prefix_command = 
(default) prefix_command_cpp = 
(default) read_only = false
(default) read_only_direct = false
(default) recache = false
(default) run_second_cpp = true
(default) sloppiness = 
(default) stats = true
(default) temporary_dir = 
(default) umask = 

But using compiler_check = mtime is suboptimal for CI as the timestamp changes on every checkout. Shouldn't the default setting be compiler_check = content?

`Post Setup ccache` not displaying correctly when using bash on Windows

The Post Setup ccache doesn't work correctly on our MinGW workflow. Led to minor confusion.

Post job cleanup.
ccache stats
  C:\ProgramData\Chocolatey\bin\ccache.exe -s
  cache directory                     C:\Users\runneradmin\AppData\Roaming/ccache
  primary config                      C:\Users\runneradmin\AppData\Roaming/ccache/ccache.conf
  secondary config (readonly)         R:/winlibs64_stage/inst_ccache-4.3/etc/ccache.conf
  cache hit (direct)                     0
  cache hit (preprocessed)               0
  cache miss                             0
  cache hit rate                      0.00 %
  cleanups performed                     0
  files in cache                         0
  cache size                           0.0 kB
  max cache size                       5.0 GB
Save cache using key "ccache-mingw-ccache-2023-05-24T20:10:55.447Z".
"C:\Program Files\Git\usr\bin\tar.exe" --posix -cf cache.tzst --exclude cache.tzst -P -C D:/a/Vulkan-ValidationLayers/Vulkan-ValidationLayers --files-from manifest.txt --force-local --use-compress-program "zstd -T0"
Cache Size: ~27 MB (27829669 B)
Cache saved successfully

However when I run ccache --show-stats directly after the build it shows the hits properly

Here is a github action that should show the behavior.

  mingw:
    runs-on: windows-latest
    defaults:
      run:
        shell: bash
    steps:
      - uses: actions/checkout@v3
      - name: Setup ccache
        uses: hendrikmuhs/[email protected]
        with:
          key: mingw-ccache
      - uses: actions/setup-python@v4
        with:
          python-version: '3.8'
      - uses: lukka/get-cmake@latest
      - name: GCC Version
        run: gcc --version # If this fails MINGW is not setup correctly
      - name: Configure
        run: cmake -S. -B build-D CMAKE_BUILD_TYPE=Release
        env:
          LDFLAGS: -fuse-ld=lld # MINGW linking is very slow. Use llvm linker instead.
          CMAKE_C_COMPILER_LAUNCHER: ccache
          CMAKE_CXX_COMPILER_LAUNCHER: ccache
          CMAKE_GENERATOR: Ninja
      - name: Build
        run: cmake --build build -- --quiet
      - name: Install
        run: cmake --install build --prefix build/install
      - name: MinGW ccache stats
        run: ccache --show-stats  # <----------------- The Post Setup ccache doesn't work right on MinGW

Link to PR where I discovered this:
KhronosGroup/Vulkan-ValidationLayers#5904

Date/time appended to cache key

Currently, the action appends the current date and time to the key when saving. This causes it to save a new cache, instead of overwriting the existing one. In turn, this leads to using more space and possibly makes it more likely for caches to be evicted.

What was the reason for this? Would it be possible to add an option so that it's possible to use the given key as-is and thus overwrite existing caches? Thanks a lot!

CCACHE_DIR environment variable is ignored by action

If the CCACHE_DIR environment variable is set ccache will use that for its cache location but ccache-action is hardcoded to use .${ccacheVariant}. The action should either honor CCACHE_DIR or set it to the hard coded path.

Sccache is not working after resume on macOS-12

On macOS-12, sccache is not working after cache resuming and then fails to post stats during the cleanup.
The latter issue causes the new cache to not be saved.

Checkout the following consecutive builds:

Build Job 48

This started with no prior cache and ran for 2h 7m 38s.

Post job cleanup.
sccache stats
  /usr/local/bin/sccache -s
  Compile requests                   4917
  Compile requests executed          4917
  Cache hits                            1
  Cache hits (C/C++)                    1
  Cache misses                       4916
  Cache misses (C/C++)               4916
  Cache timeouts                        0
  Cache read errors                     0
  Forced recaches                       0
  Cache write errors                    0
  Compilation failures                  0
  Cache errors                          0
  Non-cacheable compilations            0
  Non-cacheable calls                   0
  Non-compilation calls                 0
  Unsupported compiler calls            0
  Average cache write               0.001 s
  Average compiler                  6.422 s
  Average cache read hit            0.000 s
  Failed distributed compilations       0
  Cache location                  Local disk: "/Users/runner/work/llvm-project-ci-test/llvm-project-ci-test/.sccache"
  Use direct/preprocessor mode?   yes
  Version (client)                0.7.4
  Cache size                          141 MiB
  Max cache size                      500 MiB
Save cache using key "sccache-macOS-12-2024-01-06T20:34:28.719Z".
/usr/local/bin/gtar --posix -cf cache.tzst --exclude cache.tzst -P -C /Users/runner/work/llvm-project-ci-test/llvm-project-ci-test --files-from manifest.txt --delay-directory-restore --use-compress-program zstdmt
Cache Size: ~155 MB (162697604 B)
Cache saved successfully

In between Jobs Canceled Without Starting

Build Job 50

This build started with Job 48's cache and ran for 2h 4m 11s.

...
Install sccache
  /bin/sh -xc brew install sccache
  + brew install sccache
  ==> Downloading https://ghcr.io/v2/homebrew/core/sccache/manifests/0.7.4
  ==> Fetching sccache
  ==> Downloading https://ghcr.io/v2/homebrew/core/sccache/blobs/sha256:2398c0375c5c282810ff42b90d44dbdf56fb955c0c7ccfc980fd5bb2c0c8fbb4
  ==> Pouring sccache--0.7.4.monterey.bottle.tar.gz
  ๐Ÿบ  /usr/local/Cellar/sccache/0.7.4: 7 files, 15.1MB
  
Restore cache
  Received 0 of 162697604 (0.0%), 0.0 MBs/sec
  Received 33554432 of 162697604 (20.6%), 16.0 MBs/sec
  Received 67108864 of 162697604 (41.2%), 21.0 MBs/sec
  Received 96468992 of 162697604 (59.3%), 22.7 MBs/sec
  Received 109051904 of 162697604 (67.0%), 20.5 MBs/sec
  Received 138412032 of 162697604 (85.1%), 21.5 MBs/sec
  Cache Size: ~155 MB (162697604 B)
  /usr/local/bin/gtar -xf /Users/runner/work/_temp/b93e6650-5c21-4407-adb6-9f6730c563af/cache.tzst -P -C /Users/runner/work/llvm-project-ci-test/llvm-project-ci-test --delay-directory-restore --use-compress-program unzstd
  Received 162697604 of 162697604 (100.0%), 21.7 MBs/sec
  Cache restored successfully
  Restored from cache key "sccache-macOS-12-2024-01-06T20:34:28.719Z".
...
Post job cleanup.
sccache stats
  /usr/local/bin/sccache -s
  sccache: error: failed to get stats from server
  sccache: caused by: Failed to send data to or receive data from server. Mismatch of client/server versions?
  sccache: caused by: Failed to read response header
  sccache: caused by: failed to fill whole buffer
  Warning: Saving cache failed: Error: The process '/usr/local/bin/sccache' failed with exit code [2](https://github.com/linux4life798/llvm-project-ci-test/actions/runs/7433668388/job/20227285351#step:14:2)

In between Jobs Canceled Without Starting

Build Job 53

This build started with Job 48's cache, also, and ran for 2h 5m 4s.

...
Install sccache
  /bin/sh -xc brew install sccache
  + brew install sccache
  ==> Downloading https://ghcr.io/v2/homebrew/core/sccache/manifests/0.7.4
  ==> Fetching sccache
  ==> Downloading https://ghcr.io/v2/homebrew/core/sccache/blobs/sha256:2398c0375c5c282810ff42b90d44dbdf56fb955c0c7ccfc980fd5bb2c0c8fbb4
  ==> Pouring sccache--0.7.4.monterey.bottle.tar.gz
  ๐Ÿบ  /usr/local/Cellar/sccache/0.7.4: 7 files, 15.1MB
  
Restore cache
  Received 0 of 162697604 (0.0%), 0.0 MBs/sec
  Received 33554432 of 162697604 (20.6%), 16.0 MBs/sec
  Received 58720256 of 162697604 (36.1%), 18.7 MBs/sec
  Received 79691776 of 162697604 (49.0%), 19.0 MBs/sec
  Received 109051904 of 162697604 (67.0%), 20.8 MBs/sec
  Received 134217728 of 162697604 (82.5%), 21.3 MBs/sec
  Cache Size: ~155 MB (162697604 B)
  /usr/local/bin/gtar -xf /Users/runner/work/_temp/bb8d26a4-00a2-4c35-84f2-1e06d6a9322d/cache.tzst -P -C /Users/runner/work/llvm-project-ci-test/llvm-project-ci-test --delay-directory-restore --use-compress-program unzstd
  Received 162697604 of 162697604 (100.0%), 22.1 MBs/sec
  Cache restored successfully
  Restored from cache key "sccache-macOS-12-2024-01-06T20:34:28.719Z".
...
Post job cleanup.
sccache stats
  /usr/local/bin/sccache -s
  sccache: error: failed to get stats from server
  sccache: caused by: Failed to send data to or receive data from server. Mismatch of client/server versions?
  sccache: caused by: Failed to read response header
  sccache: caused by: failed to fill whole buffer
  Warning: Saving cache failed: Error: The process '/usr/local/bin/sccache' failed with exit code [2](https://github.com/linux4life798/llvm-project-ci-test/actions/runs/7434184703/job/20228420650#step:14:2)

These and more recent builds can be seen here.

Updating the `v1` tag

Is there any particular reason the v1 tag is stuck on a very old version, and the README.md recommends specifying hendrikmuhs/[email protected]?

As far as I understood, in GitHub Actions @v1 is generally expected to take the latest 1.x version, since a 2.x version might break compatibility.

My questions is prompted by me getting "Node.js 12 actions are deprecated" warnings regarding the use of this action, and I wonder if I should update my workflows to use @v1.2 (and potentially miss out on improvements in a future 1.3 release) or whether you could update the v1 tag in this repository to match v1.2.3 rather than v1.0.5.

Feature request: make work on MSYS2 window-based systems

Thanks for this action, I am successfully using it in various projects already :)

There are some projects I am involved in that test compiling on windows using the msys2 action, which essentially installs a gcc etc on the winows host, more closely making it behave like a linux machine. But compiling on msys2 (at least the github action CI runners) in particular is painfully slow so I wonder if your action could also be made work there.

I did try, but ... I am not familiar with typescript nor msys, so my simple attempt (see below) failed.

It does look like that maybe paths in msys2 need to be set up properly as this one failed to pacman install the package.

But even if I manually install ccache in msys, and then use something essentially like export CXX="ccache g++", just invocating $CXX hangs, so the makefile does not go anywyere. So there is a compound problem going on that someone more familiar with Windows and the interactions there might be more easily be able to troubleshoot.

diff --git a/dist/restore/index.js b/dist/restore/index.js
index 87b50ab..10db824 100644
--- a/dist/restore/index.js
+++ b/dist/restore/index.js
@@ -59239,8 +59239,9 @@ var cache = __nccwpck_require__(7799);
 async function install() {
     if (external_process_namespaceObject.platform === "darwin") {
         await exec.exec("brew install ccache");
-    }
-    else {
+    } else if (process.platform === "win32") {
+        await exec.exec("pacman --noconfirm -S --needed ccache");
+    } else {
         await exec.exec("sudo apt-get install -y ccache");
     }
 }
@@ -59298,4 +59299,4 @@ run();
 
 module.exports = __webpack_exports__;
 /******/ })()
-;
\ No newline at end of file
+;
diff --git a/src/restore.ts b/src/restore.ts
index d7e49d7..d4b8f33 100644
--- a/src/restore.ts
+++ b/src/restore.ts
@@ -9,6 +9,8 @@ import * as cache from "@actions/cache";
 async function install() {
   if (process.platform === "darwin") {
     await exec.exec("brew install ccache");
+  } else if (process.platform === "win32") {
+     await exec.exec("pacman --noconfirm -S --needed ccache");
   } else {
     await exec.exec("sudo apt-get install -y ccache");
   }

Cleaning the cache

Hi!

I have a build that someone how as gotten stuck with an bad ccache data. Adding a step that calls ccache -D makes my build pass, but my build starts failing again as soon as as I remove that step.

Is there a way to fully clean the ccache data for the project?

Thank you very much!

Cache only if `compile` step succeeds

I've noticed an issue, where if the compilation step fails for any reason, the cache is still created.
Since created caches are not overwritten, partial builds are written and can not be overwritten.

I can use some combination of append-timestamp and restore-keys but this feels awkward and brittle.

Is there a way to signal ccache-action to only save if an env variable is set or something similar?

Not caching anything on Windows-2022

key steps:

    - name: ccache
      uses: hendrikmuhs/[email protected]

    - name: Show data
      shell: bash
      run: |
        ccache -s
        ccache -p
    - name: Configure CMake
      shell: bash
      working-directory: ${{runner.workspace}}/build
      run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DCMAKE_TOOLCHAIN_FILE=$VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake -D CMAKE_C_COMPILER_LAUNCHER=ccache -D CMAKE_CXX_COMPILER_LAUNCHER=ccache
    - name: Build
      working-directory: ${{runner.workspace}}/build
      shell: bash
      run: cmake --build . --config $BUILD_TYPE

Paths seems set correctly before build.
image

But actually nothing was even passed through ccache:

"C:\Program Files\Git\bin\bash.exe" -xc "ccache -s"
+ ccache -s
cache directory                     D:\a\CFSPP\CFSPP\.ccache
primary config                      C:\Users\runneradmin/ccache/ccache.conf
secondary config (readonly)         R:/winlibs64_stage/inst_ccache-4.3/etc/ccache.conf
stats updated                       09/22/22 05:44:00
stats zeroed                        09/22/22 05:44:00
cache hit (direct)                     0
cache hit (preprocessed)               0
cache miss                             0
cache hit rate                      0.00 %
cleanups performed                     0
files in cache                         0
cache size                           0.0 kB
max cache size                     500.0 MB

The configuration works perfectly on Linux and macOS build, I'm pretty confused what step I'm missing.

Provide action output with the ccache path?

The documentation currently recommends doing

    export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"

which works, but seems a bit ugly as we use a directory in the path which doesn't exist on the current platform and not very future-proof as this will stop working when/if GitHub provides CI runners on ARM-based Macs, where we'd have to add /opt/homebrew/opt/ccache/libexec to the path instead. And the not nice thing is that this won't result in an error, but ccache will just silently not be used, until all workflows using this action are updated to use the new path.

So I wonder if it would make sense to have an output in this action with the directory to prepend to the path? It looks like it would be easy to do and I could probably do this myself if you agree that this is a good idea.

Alternatively, and even more conveniently, if also more magically, perhaps the action should just update the PATH on its own? Or is writing to $GITHUB_ENV from an action disallowed?

Make Save optional

Hello,
First of all, thank you for you work, it's a really cool action, that can save a lot of time !!

I would like to know if it's possible to make the saving optional here is the typical use case for me :

  • load & save cache on dev (ie when merging PR)
  • only load cache when running CI on a PR -> So we avoid using github cache (limited to 10Go only) and make the cache on dev branch too old (and then deleted). This works (for me) because loading cache on PR use cache located on dev branch (if base branch is dev ...)

I could also make a PR if you want :)

Post setup step shows help

In logs, in post setup step of this action you can see execution of ccache --help which seem a leftover.

Any idea why ccache not working for this `publish-docker` workflow (but it does for this other `unixlike-builds CI` workflow)?

Hi!

I believe I'm following exactly the same steps in these two workflows:
https://github.com/rturrado/the_modern_cpp_challenge/tree/unixlike-builds/.github/workflows

  • Running on an ubuntu-22.04 runner.
  • Updating, upgrading, installing gcc 12.
  • Checking out my repository.
  • ...
  • Setting up ccache with a key named after the job name.

However, ccache works in one of the workflows:
https://github.com/rturrado/the_modern_cpp_challenge/actions/runs/3264947175/jobs/5366385462
(see step ccache / Restore cache).

But not in the other:
https://github.com/rturrado/the_modern_cpp_challenge/actions/runs/3264957407/jobs/5366408088

Thanks!

MacOS: If brew fails to install ccache, skip using ccache?

See this CI Run: https://github.com/ninja-build/ninja/runs/5777867654?check_suite_focus=true

Install ccache
  /bin/bash -xc brew install ccache
  + brew install ccache
  ==> Downloading https://ghcr.io/v2/homebrew/core/hiredis/manifests/1.0.2
  ==> Downloading https://ghcr.io/v2/homebrew/core/hiredis/blobs/sha256:14ae7b3adb354b673a3744e9d849d6698846d5162d3d5f0eb8f9d8837c858e75
  ==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:14ae7b3adb354b673a3744e9d849d6698846d5162d3d5f0eb8f9d8837c858e75?se=2022-03-31T20%3A35%3A00Z&sig=%2FbbWXeQuHptzScNdWVeq0RKGBbHa1MTOGnW%2Fic5VZuY%3D&sp=r&spr=https&sr=b&sv=2019-12-12
  curl: (35) error:14004410:SSL routines:CONNECT_CR_SRVR_HELLO:sslv3 alert handshake failure
  Error: ccache: Failed to download resource "hiredis"
  Download failed: https://ghcr.io/v2/homebrew/core/hiredis/blobs/sha256:14ae7b3adb354b673a3744e9d849d6698846d5162d3d5f0eb8f9d8837c858e75
  Error: Restoring cache failed: Error: The process '/bin/bash' failed with exit code 1

The ccache directory space grows too fast for a single upload

For push-frequent repositories, old ccache is hardly ever used again after a while. However, the ccache directory still downloads the old cache directory and adds new cache items to it, and finally uploads the whole directory to the github action cache. So the ccache directory space grows too fast for a single upload. Is there a mechanism to avoid uploading the old cache in ccache directory?

Better caching for pull requests

Since pull requests touch a lot of different files, ccache reports a lot of cache misses if they all use the same key (with the timestamp postfix).

It would be nice if the first CI of a PR run would read the cache written by the latest CI run of the repo's master branch and then write and read the cache using a key that has the PR ID appended to it.

This way, the PRs wouldn't interfere with each other and the first CI run would still be quite fast.

In order to realize this, additional keys would need to be added.

Perhaps something like this:

- uses: 8BitJonny/[email protected]
        id: PR

- name: ccache
      uses: hendrikmuhs/[email protected]
      with:
          if: github.event_name == 'pull_request'
                  key-read: ${{ matrix.preset }}-${{ steps.PR.outputs.number }}
                  key-read-fallback: ${{ matrix.preset }}
                  key-write: ${{ matrix.preset }}-${{ steps.PR.outputs.number }}
          else:
                  key: ${{ matrix.preset }}

Newer ccache not installing?

It looks like by default the Github-hosted runners have ccache 4.3 installed on them already via Chocolatey. This apparently makes ccache-action skip installing a newer version, since the old one is already in the path. Is this intentional? Should there be a way to force ccache-action to install the correct version, or should I just rely on calling Chocolatey manually to install the new one?

can't save ccache in window

Cache location Local disk: "D:\a\yalantinglibs\yalantinglibs/.sccache"
Save cache using key "sccache-windows_msvc-Debug-ssl( OFF )-arch-amd64-2023-04-16T00:17:33.507Z".
Warning: Saving cache failed: Error: Path Validation Error: Path(s) specified in the action for caching do(es) not exist, hence no cache is being saved.

after compile , ccache can't be saved in right way

Fails on windows-2019 runners

When I do runs-on: windows-latest it works, but I'm working on a project (realm-js) that builds on windows-2019. The ccache action fails there with:

Error: Unable to locate executable file: sudo. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also verify the file has a valid extension for an executable file.

I think it's not detecting that it's on a windows platform, and thinks it's on linux.

I made a small demo of the issue at https://github.com/amtep/nonogram-qt/runs/7838787691

"Not saving cache because no objects are cached" on Windows workflow

I am getting the message Not saving cache because no objects are cached. on windows workflows.
I just made a small repo example to reproduce it: https://github.com/alemuntoni/ccache-hello-world)

here the workflow file and here the workflow run.

You can see that I made also similar workflows for linux and macos, which work fine.

Am I doing something wrong?

--

As @hendrikmuhs pointed on my original question on #55, ccache isn't called on my workflow:

  C:\ProgramData\Chocolatey\bin\ccache.exe -s
  cache directory                     C:\Users\runneradmin\AppData\Roaming/ccache
  primary config                      C:\Users\runneradmin\AppData\Roaming/ccache/ccache.conf
  secondary config (readonly)         R:/winlibs64_stage/inst_ccache-4.3/etc/ccache.conf
  cache hit (direct)                     0
  cache hit (preprocessed)               0
  cache miss                             0
  cache hit rate                      0.00 %
  cleanups performed                     0
  files in cache                         0
  cache size                           0.0 kB
  max cache size                       5.0 GB

Could the issue be in my cmake call?

cmake -DCMAKE_BUILD_TYPE=Release -GNinja -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache ..
ninja

https://github.com/alemuntoni/ccache-hello-world/blob/e1f7a57576d028167218ae406ae0b04cbb881935/.github/workflows/Windows.yml#L23-L24

Installs x64 binary for sccache on arm64 hosts

With Linux arm64 self-hosted runners, I'm seeing x64 binaries installed for sccache, which then (naturally) fail to run.

sccache doesn't have arm64 binaries, but it would be nice if you could at least fail on CPU architectures you don't support.

GitHub Actions macOS jobs have different compiler mtime causing cache misses

When executing jobs on macOS, compiler's mtime is different on different workers (or even for individual jobs?), causing cache misses as it is one of elements for key calculation.

The compiler size and contents are actually the same, so ccache can still be effective in those cases, but requires setting

compiler_check=content

I have verified this to be correct with ccache debugging enabled. Additionally, I have verified setting the option mentioned above made ccache hit all the TUs.

Below is diff from two builds without changing sources (formatted to remove timestamps):

--- /Users/runner/work/OpenRCT2/OpenRCT2/bin/CMakeFiles/libopenrct2.dir/src/openrct2/audio/Audio.cpp.o.20230504_165306_358636.ccache-input-text
+++ /Users/runner/work/OpenRCT2/OpenRCT2/bin/CMakeFiles/libopenrct2.dir/src/openrct2/audio/Audio.cpp.o.20230504_155944_795167.ccache-input-text
@@ -4,7 +4,7 @@
 ii
 ### cc_mtime
 1358200
-1683219023536017184
+1683215729223801769
 ### cc_name
 c++
 ### LANG
--- /tmp/Audio.cpp.o.20230504_155944_795167.ccache-log	2023-05-05 09:44:03.322904770 +0200
+++ /tmp/Audio.cpp.o.20230504_165306_358636.ccache-log	2023-05-05 09:43:29.504179419 +0200
@@ -11,7 +11,7 @@
 Config: (default) compression_level = 0
 Config: (default) cpp_extension = 
 Config: (environment) debug = true
-Config: (environment) debug_dir = /Users/runner/work/OpenRCT2/OpenRCT2/ccache-debug-1-x64
+Config: (environment) debug_dir = /Users/runner/work/OpenRCT2/OpenRCT2/ccache-debug-2-x64
 Config: (default) depend_mode = false
 Config: (default) direct_mode = true
 Config: (default) disable = false
@@ -45,7 +45,7 @@
 Config: (default) temporary_dir = /Users/runner/work/OpenRCT2/OpenRCT2/.ccache/tmp
 Config: (default) umask = 
 Command line: /usr/local/bin/ccache /usr/local/opt/ccache/libexec/c++ -DDOCDIR="/usr/share/doc/openrct2" -DOPENGL_NO_LINK -D__ENABLE_DISCORD__ -Dlibopenrct2_EXPORTS -I/Users/runner/work/OpenRCT2/OpenRCT2/src/openrct2/../thirdparty/duktape -I/Users/runner/work/OpenRCT2/OpenRCT2/libopenrct2 -isystem /Users/runner/work/OpenRCT2/OpenRCT2/lib/macos/include -isystem /Users/runner/work/OpenRCT2/OpenRCT2/lib/macos/lib/pkgconfig/../../include -isystem /Users/runner/work/OpenRCT2/OpenRCT2/lib/macos/lib/pkgconfig/../../include/libpng16 -isystem /Users/runner/work/OpenRCT2/OpenRCT2/src/openrct2/../thirdparty -fstrict-overflow -fstrict-aliasing -Werror -Wundef -Wmissing-declarations -Winit-self -Wall -Wextra -Wshadow -Wno-unknown-pragmas -Wno-missing-braces -Wno-comment -Wnonnull -Wno-unused-parameter -Wno-attributes -DDEBUG=0 -Wno-error=objc-method-access -O3 -DNDEBUG -std=gnu++17 -arch x86_64 -isysroot /Applications/Xcode_14.2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk -mmacosx-version-min=10.14 -fPIC -Wsuggest-override -Wnon-virtual-dtor -Wmissing-variable-declarations -Wmissing-field-initializers -Wunreachable-code-break -Wrange-loop-analysis -Wtautological-unsigned-zero-compare -Wold-style-cast -Wredundant-decls -Wnull-dereference -Wignored-qualifiers -Wstrict-overflow=1 -DENABLE_SCRIPTING -MD -MT CMakeFiles/libopenrct2.dir/src/openrct2/audio/Audio.cpp.o -MF CMakeFiles/libopenrct2.dir/src/openrct2/audio/Audio.cpp.o.d -o CMakeFiles/libopenrct2.dir/src/openrct2/audio/Audio.cpp.o -c /Users/runner/work/OpenRCT2/OpenRCT2/src/openrct2/audio/Audio.cpp
-Hostname: Mac-1683215512087.local
+Hostname: Mac-1683218974148.local
 Working directory: /Users/runner/work/OpenRCT2/OpenRCT2/bin
 Compiler: /usr/local/opt/ccache/libexec/c++
 Compiler type: other
@@ -56,10 +56,10 @@
 Inode cache file loaded: /Users/runner/work/OpenRCT2/OpenRCT2/.ccache/tmp/inode-cache-64.v2
 Inode cache miss: /Users/runner/work/OpenRCT2/OpenRCT2/src/openrct2/audio/Audio.cpp
 Inode cache insert: /Users/runner/work/OpenRCT2/OpenRCT2/src/openrct2/audio/Audio.cpp
-Manifest key: 3672cnshjru37kso0fmbetubh62ah8r06
-No 3672cnshjru37kso0fmbetubh62ah8r06 in local storage
+Manifest key: e7e3gj5r41b2dg62suincf2763m13i1fi
+No e7e3gj5r41b2dg62suincf2763m13i1fi in local storage
 Running preprocessor
-Executing /usr/local/opt/ccache/libexec/c++ -fstrict-overflow -fstrict-aliasing -Wundef -Wmissing-declarations -Winit-self -Wall -Wextra -Wshadow -Wno-unknown-pragmas -Wno-missing-braces -Wno-comment -Wnonnull -Wno-unused-parameter -Wno-attributes -Wno-error=objc-method-access -O3 -std=gnu++17 -mmacosx-version-min=10.14 -fPIC -Wsuggest-override -Wnon-virtual-dtor -Wmissing-variable-declarations -Wmissing-field-initializers -Wunreachable-code-break -Wrange-loop-analysis -Wtautological-unsigned-zero-compare -Wold-style-cast -Wredundant-decls -Wnull-dereference -Wignored-qualifiers -Wstrict-overflow=1 -DDOCDIR="/usr/share/doc/openrct2" -DOPENGL_NO_LINK -D__ENABLE_DISCORD__ -Dlibopenrct2_EXPORTS -I/Users/runner/work/OpenRCT2/OpenRCT2/src/openrct2/../thirdparty/duktape -I/Users/runner/work/OpenRCT2/OpenRCT2/libopenrct2 -isystem /Users/runner/work/OpenRCT2/OpenRCT2/lib/macos/include -isystem /Users/runner/work/OpenRCT2/OpenRCT2/lib/macos/lib/pkgconfig/../../include -isystem /Users/runner/work/OpenRCT2/OpenRCT2/lib/macos/lib/pkgconfig/../../include/libpng16 -isystem /Users/runner/work/OpenRCT2/OpenRCT2/src/openrct2/../thirdparty -DDEBUG=0 -DNDEBUG -isysroot /Applications/Xcode_14.2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk -DENABLE_SCRIPTING -arch x86_64 -E -o /Users/runner/work/OpenRCT2/OpenRCT2/.ccache/tmp/cpp_stdout.tmp.K2UcDZ.ii /Users/runner/work/OpenRCT2/OpenRCT2/src/openrct2/audio/Audio.cpp
+Executing /usr/local/opt/ccache/libexec/c++ -fstrict-overflow -fstrict-aliasing -Wundef -Wmissing-declarations -Winit-self -Wall -Wextra -Wshadow -Wno-unknown-pragmas -Wno-missing-braces -Wno-comment -Wnonnull -Wno-unused-parameter -Wno-attributes -Wno-error=objc-method-access -O3 -std=gnu++17 -mmacosx-version-min=10.14 -fPIC -Wsuggest-override -Wnon-virtual-dtor -Wmissing-variable-declarations -Wmissing-field-initializers -Wunreachable-code-break -Wrange-loop-analysis -Wtautological-unsigned-zero-compare -Wold-style-cast -Wredundant-decls -Wnull-dereference -Wignored-qualifiers -Wstrict-overflow=1 -DDOCDIR="/usr/share/doc/openrct2" -DOPENGL_NO_LINK -D__ENABLE_DISCORD__ -Dlibopenrct2_EXPORTS -I/Users/runner/work/OpenRCT2/OpenRCT2/src/openrct2/../thirdparty/duktape -I/Users/runner/work/OpenRCT2/OpenRCT2/libopenrct2 -isystem /Users/runner/work/OpenRCT2/OpenRCT2/lib/macos/include -isystem /Users/runner/work/OpenRCT2/OpenRCT2/lib/macos/lib/pkgconfig/../../include -isystem /Users/runner/work/OpenRCT2/OpenRCT2/lib/macos/lib/pkgconfig/../../include/libpng16 -isystem /Users/runner/work/OpenRCT2/OpenRCT2/src/openrct2/../thirdparty -DDEBUG=0 -DNDEBUG -isysroot /Applications/Xcode_14.2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk -DENABLE_SCRIPTING -arch x86_64 -E -o /Users/runner/work/OpenRCT2/OpenRCT2/.ccache/tmp/cpp_stdout.tmp.OCtnhP.ii /Users/runner/work/OpenRCT2/OpenRCT2/src/openrct2/audio/Audio.cpp
 Inode cache hit: /Users/runner/work/OpenRCT2/OpenRCT2/src/openrct2/audio/audio.h
 Inode cache hit: /Users/runner/work/OpenRCT2/OpenRCT2/src/openrct2/Identifiers.h
 Inode cache hit: /Users/runner/work/OpenRCT2/OpenRCT2/src/openrct2/common.h
@@ -603,46 +603,46 @@
 Inode cache hit: /Users/runner/work/OpenRCT2/OpenRCT2/src/openrct2/audio/AudioChannel.h
 Inode cache hit: /Users/runner/work/OpenRCT2/OpenRCT2/src/openrct2/audio/AudioContext.h
 Got result key from preprocessor with -arch x86_64
-Result key: 587f85tskge212c97lkvpq9350df0jacs
-No 587f85tskge212c97lkvpq9350df0jacs in local storage
+Result key: 645dh8t6qb42429iptb7sdenak12684eu
+No 645dh8t6qb42429iptb7sdenak12684eu in local storage
 Running real compiler
 Executing /usr/local/opt/ccache/libexec/c++ -fstrict-overflow -fstrict-aliasing -Wundef -Wmissing-declarations -Winit-self -Wall -Wextra -Wshadow -Wno-unknown-pragmas -Wno-missing-braces -Wno-comment -Wnonnull -Wno-unused-parameter -Wno-attributes -Wno-error=objc-method-access -O3 -std=gnu++17 -mmacosx-version-min=10.14 -fPIC -Wsuggest-override -Wnon-virtual-dtor -Wmissing-variable-declarations -Wmissing-field-initializers -Wunreachable-code-break -Wrange-loop-analysis -Wtautological-unsigned-zero-compare -Wold-style-cast -Wredundant-decls -Wnull-dereference -Wignored-qualifiers -Wstrict-overflow=1 -Werror -DDOCDIR="/usr/share/doc/openrct2" -DOPENGL_NO_LINK -D__ENABLE_DISCORD__ -Dlibopenrct2_EXPORTS -I/Users/runner/work/OpenRCT2/OpenRCT2/src/openrct2/../thirdparty/duktape -I/Users/runner/work/OpenRCT2/OpenRCT2/libopenrct2 -isystem /Users/runner/work/OpenRCT2/OpenRCT2/lib/macos/include -isystem /Users/runner/work/OpenRCT2/OpenRCT2/lib/macos/lib/pkgconfig/../../include -isystem /Users/runner/work/OpenRCT2/OpenRCT2/lib/macos/lib/pkgconfig/../../include/libpng16 -isystem /Users/runner/work/OpenRCT2/OpenRCT2/src/openrct2/../thirdparty -DDEBUG=0 -DNDEBUG -isysroot /Applications/Xcode_14.2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk -DENABLE_SCRIPTING -c -arch x86_64 -MD -MT CMakeFiles/libopenrct2.dir/src/openrct2/audio/Audio.cpp.o -MF CMakeFiles/libopenrct2.dir/src/openrct2/audio/Audio.cpp.o.d -o CMakeFiles/libopenrct2.dir/src/openrct2/audio/Audio.cpp.o /Users/runner/work/OpenRCT2/OpenRCT2/src/openrct2/audio/Audio.cpp
 Base dir not set, skip using relative paths
 Using default compression level 1
 Storing embedded entry #0 .o (28272 bytes) from CMakeFiles/libopenrct2.dir/src/openrct2/audio/Audio.cpp.o
 Storing embedded entry #1 .d (78050 bytes) from CMakeFiles/libopenrct2.dir/src/openrct2/audio/Audio.cpp.o.d
-Acquiring /Users/runner/work/OpenRCT2/OpenRCT2/.ccache/lock/subdir_58.lock
-Acquired /Users/runner/work/OpenRCT2/OpenRCT2/.ccache/lock/subdir_58.lock
-Creating /Users/runner/work/OpenRCT2/OpenRCT2/.ccache/lock/subdir_58.alive
-Stored 587f85tskge212c97lkvpq9350df0jacs in local storage (/Users/runner/work/OpenRCT2/OpenRCT2/.ccache/5/8/7f85tskge212c97lkvpq9350df0jacsR)
-Acquiring /Users/runner/work/OpenRCT2/OpenRCT2/.ccache/5/stats.lock
-Acquired /Users/runner/work/OpenRCT2/OpenRCT2/.ccache/5/stats.lock
-Creating /Users/runner/work/OpenRCT2/OpenRCT2/.ccache/5/stats.alive
-Releasing /Users/runner/work/OpenRCT2/OpenRCT2/.ccache/5/stats.lock
-Unlink /Users/runner/work/OpenRCT2/OpenRCT2/.ccache/5/stats.alive
-Unlink /Users/runner/work/OpenRCT2/OpenRCT2/.ccache/5/stats.lock
-Released /Users/runner/work/OpenRCT2/OpenRCT2/.ccache/5/stats.lock
-Releasing /Users/runner/work/OpenRCT2/OpenRCT2/.ccache/lock/subdir_58.lock
-Unlink /Users/runner/work/OpenRCT2/OpenRCT2/.ccache/lock/subdir_58.alive
-Unlink /Users/runner/work/OpenRCT2/OpenRCT2/.ccache/lock/subdir_58.lock
-Released /Users/runner/work/OpenRCT2/OpenRCT2/.ccache/lock/subdir_58.lock
-Added result key to manifest 3672cnshjru37kso0fmbetubh62ah8r06
+Acquiring /Users/runner/work/OpenRCT2/OpenRCT2/.ccache/lock/subdir_64.lock
+Acquired /Users/runner/work/OpenRCT2/OpenRCT2/.ccache/lock/subdir_64.lock
+Creating /Users/runner/work/OpenRCT2/OpenRCT2/.ccache/lock/subdir_64.alive
+Stored 645dh8t6qb42429iptb7sdenak12684eu in local storage (/Users/runner/work/OpenRCT2/OpenRCT2/.ccache/6/4/5dh8t6qb42429iptb7sdenak12684euR)
+Acquiring /Users/runner/work/OpenRCT2/OpenRCT2/.ccache/6/stats.lock
+Acquired /Users/runner/work/OpenRCT2/OpenRCT2/.ccache/6/stats.lock
+Creating /Users/runner/work/OpenRCT2/OpenRCT2/.ccache/6/stats.alive
+Releasing /Users/runner/work/OpenRCT2/OpenRCT2/.ccache/6/stats.lock
+Unlink /Users/runner/work/OpenRCT2/OpenRCT2/.ccache/6/stats.alive
+Unlink /Users/runner/work/OpenRCT2/OpenRCT2/.ccache/6/stats.lock
+Released /Users/runner/work/OpenRCT2/OpenRCT2/.ccache/6/stats.lock
+Releasing /Users/runner/work/OpenRCT2/OpenRCT2/.ccache/lock/subdir_64.lock
+Unlink /Users/runner/work/OpenRCT2/OpenRCT2/.ccache/lock/subdir_64.alive
+Unlink /Users/runner/work/OpenRCT2/OpenRCT2/.ccache/lock/subdir_64.lock
+Released /Users/runner/work/OpenRCT2/OpenRCT2/.ccache/lock/subdir_64.lock
+Added result key to manifest e7e3gj5r41b2dg62suincf2763m13i1fi
 Using default compression level 1
-Acquiring /Users/runner/work/OpenRCT2/OpenRCT2/.ccache/lock/subdir_36.lock
-Acquired /Users/runner/work/OpenRCT2/OpenRCT2/.ccache/lock/subdir_36.lock
-Creating /Users/runner/work/OpenRCT2/OpenRCT2/.ccache/lock/subdir_36.alive
-Stored 3672cnshjru37kso0fmbetubh62ah8r06 in local storage (/Users/runner/work/OpenRCT2/OpenRCT2/.ccache/3/6/72cnshjru37kso0fmbetubh62ah8r06M)
-Acquiring /Users/runner/work/OpenRCT2/OpenRCT2/.ccache/3/stats.lock
-Acquired /Users/runner/work/OpenRCT2/OpenRCT2/.ccache/3/stats.lock
-Creating /Users/runner/work/OpenRCT2/OpenRCT2/.ccache/3/stats.alive
-Releasing /Users/runner/work/OpenRCT2/OpenRCT2/.ccache/3/stats.lock
-Unlink /Users/runner/work/OpenRCT2/OpenRCT2/.ccache/3/stats.alive
-Unlink /Users/runner/work/OpenRCT2/OpenRCT2/.ccache/3/stats.lock
-Released /Users/runner/work/OpenRCT2/OpenRCT2/.ccache/3/stats.lock
-Releasing /Users/runner/work/OpenRCT2/OpenRCT2/.ccache/lock/subdir_36.lock
-Unlink /Users/runner/work/OpenRCT2/OpenRCT2/.ccache/lock/subdir_36.alive
-Unlink /Users/runner/work/OpenRCT2/OpenRCT2/.ccache/lock/subdir_36.lock
-Released /Users/runner/work/OpenRCT2/OpenRCT2/.ccache/lock/subdir_36.lock
+Acquiring /Users/runner/work/OpenRCT2/OpenRCT2/.ccache/lock/subdir_e7.lock
+Acquired /Users/runner/work/OpenRCT2/OpenRCT2/.ccache/lock/subdir_e7.lock
+Creating /Users/runner/work/OpenRCT2/OpenRCT2/.ccache/lock/subdir_e7.alive
+Stored e7e3gj5r41b2dg62suincf2763m13i1fi in local storage (/Users/runner/work/OpenRCT2/OpenRCT2/.ccache/e/7/e3gj5r41b2dg62suincf2763m13i1fiM)
+Acquiring /Users/runner/work/OpenRCT2/OpenRCT2/.ccache/e/stats.lock
+Acquired /Users/runner/work/OpenRCT2/OpenRCT2/.ccache/e/stats.lock
+Creating /Users/runner/work/OpenRCT2/OpenRCT2/.ccache/e/stats.alive
+Releasing /Users/runner/work/OpenRCT2/OpenRCT2/.ccache/e/stats.lock
+Unlink /Users/runner/work/OpenRCT2/OpenRCT2/.ccache/e/stats.alive
+Unlink /Users/runner/work/OpenRCT2/OpenRCT2/.ccache/e/stats.lock
+Released /Users/runner/work/OpenRCT2/OpenRCT2/.ccache/e/stats.lock
+Releasing /Users/runner/work/OpenRCT2/OpenRCT2/.ccache/lock/subdir_e7.lock
+Unlink /Users/runner/work/OpenRCT2/OpenRCT2/.ccache/lock/subdir_e7.alive
+Unlink /Users/runner/work/OpenRCT2/OpenRCT2/.ccache/lock/subdir_e7.lock
+Released /Users/runner/work/OpenRCT2/OpenRCT2/.ccache/lock/subdir_e7.lock
 Result: cache_miss
 Result: direct_cache_miss
 Result: local_storage_miss
@@ -651,17 +651,17 @@
 Result: local_storage_write
 Result: local_storage_write
 Result: preprocessed_cache_miss
-Acquiring /Users/runner/work/OpenRCT2/OpenRCT2/.ccache/e/9/stats.lock
-Acquired /Users/runner/work/OpenRCT2/OpenRCT2/.ccache/e/9/stats.lock
-Creating /Users/runner/work/OpenRCT2/OpenRCT2/.ccache/e/9/stats.alive
-Releasing /Users/runner/work/OpenRCT2/OpenRCT2/.ccache/e/9/stats.lock
-Unlink /Users/runner/work/OpenRCT2/OpenRCT2/.ccache/e/9/stats.alive
-Unlink /Users/runner/work/OpenRCT2/OpenRCT2/.ccache/e/9/stats.lock
-Released /Users/runner/work/OpenRCT2/OpenRCT2/.ccache/e/9/stats.lock
+Acquiring /Users/runner/work/OpenRCT2/OpenRCT2/.ccache/1/d/stats.lock
+Acquired /Users/runner/work/OpenRCT2/OpenRCT2/.ccache/1/d/stats.lock
+Creating /Users/runner/work/OpenRCT2/OpenRCT2/.ccache/1/d/stats.alive
+Releasing /Users/runner/work/OpenRCT2/OpenRCT2/.ccache/1/d/stats.lock
+Unlink /Users/runner/work/OpenRCT2/OpenRCT2/.ccache/1/d/stats.alive
+Unlink /Users/runner/work/OpenRCT2/OpenRCT2/.ccache/1/d/stats.lock
+Released /Users/runner/work/OpenRCT2/OpenRCT2/.ccache/1/d/stats.lock
 Trying to acquire /Users/runner/work/OpenRCT2/OpenRCT2/.ccache/lock/auto_cleanup.lock
 Acquired /Users/runner/work/OpenRCT2/OpenRCT2/.ccache/lock/auto_cleanup.lock
 Creating /Users/runner/work/OpenRCT2/OpenRCT2/.ccache/lock/auto_cleanup.alive
-No automatic cleanup needed (size 36.4 MB, files 1498, max size 500.0 MB)
+No automatic cleanup needed (size 67.7 MB, files 2734, max size 500.0 MB)
 Releasing /Users/runner/work/OpenRCT2/OpenRCT2/.ccache/lock/auto_cleanup.lock
 Unlink /Users/runner/work/OpenRCT2/OpenRCT2/.ccache/lock/auto_cleanup.alive
 Unlink /Users/runner/work/OpenRCT2/OpenRCT2/.ccache/lock/auto_cleanup.lock

And the logs themselves (only from one run)
Audio.cpp.o.20230504_155944_795167.ccache-input-text.txt
Audio.cpp.o.20230504_155944_795167.ccache-log.txt

Cache is not restored any longer

I have no idea what happened but since relatively recently (I've missed when exactly has it started, as I was on vacation during this time...), the action doesn't work at all any longer because it fails to restore the previously saved cache. All I see in the "Restore cache" section of the logs is "No cache found." when it used to work before.

E.g., without any changes to the CI workflow or anything else, the cache was restored in this build from 2 weeks ago, but a more recent build doesn't find anything.

I have no idea what happened here and what to do about it. It's not specific to this repository neither, I also see it in another (private) repository I use. Does anybody have any ideas?

Version 1.2.12 fails to work on CentOS7, but 1.2.11 was fine

Thus, this action fails to work where it was used via @v1.2.
Please, remove this release or re-release as v1.2.14 the backward-compatible version.
The problem is hidden in the cache action version 3.2.3 (PR #175), that introduces node20 dependency.
I suggest to re-release the update as v1.3 or even v2, because actually It is not a "minor fix".

preferred way for configuring ccache

Using this action, what's the preferred way to change ccache configuration, e.g. altering cache size?

await exec.exec("ccache --set-config=max_size=500M");

has the defaults hardcoded, should I alter the file after the action has executed? Is there an output variable to store the file path? Should I use ccache's support for setup with env variables?

I'm comfortable with doing any of those, but wanted to reach out in case there's some preference already. Ideally though, there would be an input to this action to be passed on to ccache configuration.

Invalid input option 'save'

Hello,

I tried to use the newly introduced input option 'save' to disabled saving cache when some conditions are met.
Unfortunately I get the following warning :
Warning: Unexpected input(s) 'save', valid inputs are ['key', 'max-size']
workfow run : https://github.com/hove-io/navitia/runs/6292655767?check_suite_focus=true#step:4:38

I check that the latest version of ccache-action is used : https://github.com/hove-io/navitia/runs/6292655767?check_suite_focus=true#step:1:56

Thank you for your help and tour work

Unable to locate executable file: sudo

I have the following error on Windows:

Error: Unable to locate executable file: sudo. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also verify the file has a valid extension for an executable file.

Does Windows supported by this action?

Not using latest cache key?

Using your action like this

    - name: ccache
      uses: hendrikmuhs/[email protected]
      with:
          key: ${{ matrix.preset }}
[...]
    - name: CMake Preset
      run: |
        cmake -DCMAKE_CXX_COMPILER_LAUNCHER=ccache --preset ${{ matrix.preset }}

I saw the following:

image

image

Note the timeline:

CI run 1 succeeded 42 min ago and saved the cache using the key ccache-linux-gcc-test-2023-09-28T17:29:31.499Z
CI run 2 started 14 min ago and restored the cache using the key ccache-linux-gcc-test-2023-09-28T16:08:40.914Z

Is this due to Github not guaranteeing to use the latest cache, perhaps because it takes some time to copy the data to the runners?

I think it's not that important, since usually commits only touch a few files, but it was still unexpected.

Skip timestamp append by default

Turns out for busy repos the default timestamp costs quite a lot since cache gets dropped a lot, thus increasing build times.
Please consider setting append-timestamp to false by default.
I would expect a major release with it to save people any issues.

Also what was the purpose of the timestamp? Does it give any benefit I'm missing?

Silently fails to write GCS cache

If sccache is unable to authenticate to GCS it just silently proceeds without authentication. If it gets a "unauthorized" response when writing, it proceeds. Instead, I think several of these things should be an error, with the option to configure it to bypass the errors. I found mozilla/sccache#1180, which I think covers some of these issues, but there are others that should

Here are some logs demonstrating the issue: https://gist.github.com/GMNGeoffrey/b0f7453349b8211b3af355bc9a9765f9

[2022-11-08T22:53:15Z DEBUG sccache::cache::cache] Trying GCS bucket(iree-github-actions-presubmit-artifacts, gcmn-test-sccache, Some("/usr/local/google/home/gcmn/.config/gcloud/application_default_credentials.json"), None, None, ReadWrite)
[2022-11-08T22:53:15Z WARN  sccache::cache::cache] Failed to parse service account credentials from file: missing field `private_key` at line 6 column 1. Continuing without authentication.

This should be an error. I think just changing https://github.com/mozilla/sccache/blob/b6b20059cec5d3c4311b7f5fe99f9c37d0412fb9/src/cache/cache.rs#L378 here.

[2022-11-08T22:53:16Z DEBUG reqwest::async_impl::client] response '404 Not Found' for https://www.googleapis.com/download/storage/v1/b/iree-github-actions-presubmit-artifacts/o/gcmn-test-sccache%2F03e462fba45b71c78c638ecafbbf2a1e233ab6b79214350310269d3593f26987?alt=media
[2022-11-08T22:53:16Z WARN  sccache::cache::gcs] Got GCS error: didn't get a successful HTTP status, got `404 Not Found`

This should be DEBUG. A 404 is just a cache miss. mozilla/sccache#1180 covers this.

[2022-11-08T22:56:53Z DEBUG sccache::cache::cache] Trying GCS bucket(iree-github-actions-presubmit-artifacts, gcmn-test-sccache, None, None, None, ReadWrite)
[2022-11-08T22:56:53Z WARN  sccache::cache::cache] No SCCACHE_GCS_KEY_PATH specified-- no authentication will be used.

Should this be an error? No authentication with ReadWrite, seems exceptionally unlikely to work... I wonder if any cloud bucket is configured for unauthenticated write access

[2022-11-08T22:56:53Z DEBUG reqwest::async_impl::client] response '401 Unauthorized' for https://www.googleapis.com/upload/storage/v1/b/iree-github-actions-presubmit-artifacts/o?name=gcmn-test-sccache/03e462fba45b71c78c638ecafbbf2a1e233ab6b79214350310269d3593f26987&uploadType=media
[2022-11-08T22:56:53Z DEBUG sccache::compiler::compiler] [Demangle.cpp.o]: Cache write error: failed to put cache entry in GCS

This should be an error.

I am happy to send patches for these issues.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.