Proper caching for CI builds

My sonarcloud github action is taking about 3 minutes to run now. I’m trying to see if caching the ~/.sonar/cache directory will help, as I saw done in another sample.

I have the cache working, but I still see this log line when I do the begin step for the sonar scanner CLI:

Cache data is empty. A full analysis will be performed

Does this mean I’m not doing something right? I clearly see the action/cache step downloading the cache from a previous build. But I see the above message in later steps, and my overall workflow time to complete doesn’t change.

My workflow and code is completely open source. You can see an example workflow run here. My workflow YAML is here.

There’s two different caches to speak of here.

  • Analyzer cache, stored in ~/.sonar/cache, which prevents analyzers from having to be redownloaded on each run
  • Analysis cache, reusing results that are stored on SonarCloud to make analysis faster (not having to reanalyze everything).

This message refers to the latter:

This only works in the context of pull requests right now, not of standalone branch analyses (maybe someday!). As a result, it’s normal that the cache data is empty for your workflow run, as it’s for a branch analysis rather than a pull request analysis.

I hope this helps.

1 Like

How can I learn when standalone branch analysis caching is available outside of PRs? Is watching the releases page here enough?

https://github.com/SonarSource/sonar-scanner-cli

EDIT: Hmm, now that I’m looking, the releases page here does not have release notes. So I’m not really sure where I can keep up to date on new changes to the CLI.

Any changes related to this would actually be SonarCloud side instead of scanner side (though a scanner update might be required).

Keep an eye on What’s new in SonarCloud.

To be very transparent, we’ve put a lot of work into incremental analysis in the last year, and given some other priorites I’m not sure this topic will come up again soon – but the groundwork is laid.

That page you linked is a great resource. Unfortunately I don’t see a way to sign up for a mailing list or subscribe to updates. Would be nice if you had a newsletter of some kind, or release notes I could subscribe to on github.

Thanks for your continued help.

I think there is more on this coming soon (a way for SonarCloud users to stay up to date with important updates).

You can also subscribe to these categories in the Community to receive notifications:

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.