hendrikmuhs / ccache-action

github action to speedup building using ccache
MIT License
114 stars 52 forks source link

Newer ccache not installing? #87

Closed timwoj closed 2 years ago

timwoj commented 2 years ago

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?

jonashaag commented 2 years ago

Somewhat related to https://github.com/hendrikmuhs/ccache-action/issues/81. I guess it would be nice to add a version option. IMO using the default installed version is fine because Ccache doesn’t change much.

timwoj commented 2 years ago

It might also be useful to have the action output the version of ccache that it's using during the setup phase, so that it's easy to catch when it's using an unexpected version.

jonashaag commented 2 years ago

Happy to review any PRs :)

timwoj commented 2 years ago

I'll see what I can do.

The reason I'm bringing this all up is because this Windows runner is being all squirrely. When the setup steps run, it uses "C:\Program Files\Git\bin\bash.exe" -xc "ccache -p" to run the correct version of ccache. I assume at this point that that's C:\ProgramData\Chocolatey\bin\ccache.exe. Setup uses a path for the configuration and one to store the cache, both within the clone of the repository I'm building. When I run cmake to configure the build though and then run ccache -p right after, it prints out the wrong path. The build says that it's using the same ccache binary from Chocolatey, but ccache -p at the end of the build also reports the wrong paths. ccache -s says that it had zero cache hits (obviously, if it's using the wrong path...). During the Post step for ccache, it uses the first path again, says that it has a hit on the existing data (because nothing changed), and skips trying to store anything.

Thoughts? I had this working at one point in the past. Since then I added support for vcpkg packages, and added action/cache@v3 to avoid having to rebuild them every time. Is it possible that's overriding something ccache-action is doing?

jonashaag commented 2 years ago

Setup uses a path for the configuration and one to store the cache, both within the clone of the repository

Is this by accident? I guess it’s better to have them outside the repo.

Do you maybe end up with two versions or Ccache installed?

timwoj commented 2 years ago

Is this by accident? I guess it’s better to have them outside the repo.

I have no idea. The only things that run in the workflow before the Set up ccache part are a clone of the repo, making a directory to store the vcpkg cache, and installing a newer version of ccache from Chocolatey since the runner only has 4.3 on it by default.

From the beginning of Set up ccache:

Configure ccache
  "C:\Program Files\Git\bin\bash.exe" -xc "ccache --set-config=cache_dir='D:\a\zeek-agent-v2\zeek-agent-v2\.ccache'"
  + ccache '--set-config=cache_dir=D:\a\zeek-agent-v2\zeek-agent-v2\.ccache'

  + ccache -p
  (default) absolute_paths_in_stderr = false
  (default) base_dir = 
  (C:\Users\runneradmin/ccache/ccache.conf) cache_dir = D:\a\zeek-agent-v2\zeek-agent-v2\.ccache

After configure and the build finish:

+ ccache -p
  (default) absolute_paths_in_stderr = false
  (default) base_dir = 
  (C:\Users\runneradmin/ccache/ccache.conf) cache_dir = D:\a\zeek-agent-v2\zeek-agent-v2\.ccache

Do you maybe end up with two versions or Ccache installed?

Not that I know of. It should only be the version installed by Chocolatey.

timwoj commented 2 years ago

I'm still not sure what causes this, but adding CCACHE_CONFIGPATH: ~/ccache/ccache.conf to the environment of the job fixes all of the problems I was seeing. For the original issue I opened this for, I ended up just adding a step that calls ccache install ccache to update to 4.6.1. I'll go ahead and close this out.