Open
Description
We use the same configuration everywhere:
- name: Install JDK
uses: actions/setup-java@v4.0.0
with:
distribution: 'adopt'
java-version: '8'
cache: 'maven'
So, the jobs use Maven cache by default. But there seems to be a problem that a cache might not have some dependencies and a job had to download them. Here is the example:
Cache Size: ~2 MB (1978758 B)
/usr/bin/tar -xf /home/runner/work/_temp/6da31f4c-fad8-481e-b2e2-bb721e9a8117/cache.tzst -P -C /home/runner/work/mystamps/mystamps --use-compress-program unzstd
Cache restored successfully
Cache restored from key: setup-java-Linux-maven-c34d1feb73d33e5eb28cf0d245a2f3fdfa75d7b91c9cd00f1129572c94aac6af
Received 1978758 of 1978758 (100.0%), 1.9 MBs/sec
in the middle of the log, there a lot of downloads:
[INFO] Downloading from central: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-enforcer-plugin/3.0.0-M3/maven-enforcer-plugin-3.0.0-M3.pom
[INFO] Downloaded from central: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-enforcer-plugin/3.0.0-M3/maven-enforcer-plugin-3.0.0-M3.pom (7.3 kB at 27 kB/s)
and at the end:
Cache hit occurred on the primary key setup-java-Linux-maven-c34d1feb73d33e5eb28cf0d245a2f3fdfa75d7b91c9cd00f1129572c94aac6af, not saving cache.
The root cause is that the jobs might need different set of dependencies but they use a single cache for everyone. Also, it's not clear who is publishing that cache. It seems like, a job that the first finished, puts its dependencies to a cache.
I see the following ways to fix it:
- all jobs will continue to use a single cache, but we need to populate it properly by a special job (that is triggered on every
pom.xml
modification) - every job will have its own cache
Anyway, we will have to manage cache manually because actions/setup-java
doesn't have capabilities to adjust cache properties (actions/setup-java#551).