This works fine when using sonarqube-scan-action v2.0.2. After the first build, files under ${{ github.workspace }}/.sonar/cache are cached and future scans run much quicker.
Upgrading to sonarqube-scan-action v2.2 makes the cache action Post job cleanup fail like this:
> Post job cleanup.
/usr/bin/tar --posix -cf cache.tzst --exclude cache.tzst -P -C /home/runner/work/ai-rapportering/ai-rapportering --files-from manifest.txt --use-compress-program zstdmt
/usr/bin/tar: .sonar/cache/3ede12e96a509e101c6eab2aa4706c50/sonar-php-plugin.jar_unzip: Cannot open: Permission denied
/usr/bin/tar: .sonar/cache/0c7e084443770eb32129caa9121bb60e/sonar-ruby-plugin.jar_unzip: Cannot open: Permission denied
...
/usr/bin/tar: Exiting with failure status due to previous errors
Warning: Failed to save: "/usr/bin/tar" failed with error: The process '/usr/bin/tar' failed with exit code 2
The cache action is clearly not allowed to read the scanner files.
I suspect this could be due to the fact that in a recent commit the user is explicitly set in the Dockerfile as:
Ensure your Dockerfile does not set the USER instruction, otherwise you will not be able to access GITHUB_WORKSPACE.
We would of course like to upgrade sonarqube-scan-action to the latest version, but we need to be able to cache the scanner files. Could you please look into this?
I now realize that this post should have been tagged with github-actions but I cannot find a way to add a tag.
Should I delete the post and create a new one one with the proper tag?
Thanks for reporting that.
We have seen errors where clearing the cache helped the CLI run; I think it is worth a try, but it is a bit different from what you described.
However, we will have a look and repro the issue that you described and get back to you.
[Edit:
The documentation says: GitHub Actions must be run by the default Docker user (root). We use USER 0 to set back to root as the base image as per docker best practices does set non-root user. ]
Still it would be great if you were able to do something in the sonarqube-scan-action. Perhaps you could look into changing the permissions for directories under .sonar/cache to make them more accessible. Right now they are like:
drwx------ 2 root root 4096 Jun 25 07:52 sonar-plsql-plugin.jar_unzip
which prevents others from accessing the cached files.
Thank you for raising this. We spent some time investigating the issue, and we think we found the error: the cleanup scripts’ limited execution radius of the permission reset.
the new version of the sonarqube-scan-action 2.3.0 should have the fix. Please let us know if this solves the problem for you.