Cache is reported as found and restored, but artifacts are still being downloaded
serpro69 opened this issue · comments
Description:
A clear and concise description of what the bug is.
A screenshot is better than a thousand words?
The step that installs java reports that cache is found and restored:
Cache Size: ~157 MB (165088951 B)
/usr/bin/tar -xf /home/runner/work/_temp/d074075c-418e-43ad-aae2-9d2ff268f1[39](https://github.com/foo/template-spring-sdk/actions/runs/8798451641/job/24145516455#step:3:41)/cache.tzst -P -C /home/runner/work/template-spring-sdk/template-spring-sdk --use-compress-program unzstd
Received 165088951 of 165088951 (100.0%), 78.7 MBs/sec
Cache restored successfully
Cache restored from key: setup-java-Linux-maven-6adf5af8388c457cef82a4da3a454e4fe729ec5f1c86b04a1b206e037f67123e
The next step that runs maven tests still downloads every single artifact...
Run mvn clean test -Djacoco.destFile=exportJacoco/jacoco-unit.exec
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------< foo.bar:template-spring-sdk >------------------
[INFO] Building template-spring-sdk 0.0.0
[INFO] from pom.xml
[INFO] --------------------------------[ jar ]---------------------------------
Downloading from central: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-resources-plugin/3.3.1/maven-resources-plugin-3.3.1.pom
Progress (1): 2.8/8.2 kB
Progress (1): 5.5/8.2 kB
Progress (1): 8.2 kB
Downloaded from central: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-resources-plugin/3.3.1/maven-resources-plugin-3.3.1.pom (8.2 kB at 30 kB/s)
Downloading from central: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-plugins/39/maven-plugins-39.pom
Progress (1): 2.8/8.1 kB
Progress (1): 5.5/8.1 kB
Progress (1): 8.1 kB
Downloaded from central: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-plugins/39/maven-plugins-39.pom (8.1 kB at 238 kB/s)
Downloading from central: https://repo.maven.apache.org/maven2/org/apache/maven/maven-parent/39/maven-parent-39.pom
Progress (1): 4.1/48 kB
Progress (1): 8.2/48 kB
Progress (1): 16/48 kB
Progress (1): 20/48 kB
Progress (1): 25/48 kB
Progress (1): 29/48 kB
Progress (1): 33/48 kB
Progress (1): 37/48 kB
Progress (1): 41/48 kB
Progress (1): 45/48 kB
Progress (1): 48 kB
Downloaded from central: https://repo.maven.apache.org/maven2/org/apache/maven/maven-parent/39/maven-parent-39.pom (48 kB at 979 kB/s)
Downloading from central: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-resources-plugin/3.3.1/maven-resources-plugin-3.3.1.jar
Progress (1): 4.1/31 kB
Progress (1): 8.2/31 kB
Progress (1): 12/31 kB
Progress (1): 20/31 kB
Progress (1): 25/31 kB
Progress (1): 29/31 kB
Progress (1): 31 kB
Task version:
v4
Platform:
- Ubuntu
- macOS
- Windows
Runner type:
- Hosted
- Self-hosted
Repro steps:
Here's the pipeline:
lint:
name: lint
runs-on: ubuntu-latest
needs: before
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup JDK 17
uses: actions/setup-java@v4
with:
java-version: ${{ inputs.version }}
distribution: ${{ inputs.distribution }}
cache: maven
overwrite-settings: false
- name: Prepare Maven settings.xml
run: |
mkdir -p ~/.m2
echo "${{ secrets.MAVEN_SETTINGS }}" | base64 -d > ~/.m2/settings.xml
- name: Lint with Maven
run: mvn clean spotless:check checkstyle:check
unit-test:
name: unit test
runs-on: ubuntu-latest
needs: lint
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup JDK 17
uses: actions/setup-java@v4
with:
java-version: ${{ inputs.version }}
distribution: ${{ inputs.distribution }}
cache: maven
overwrite-settings: false
- name: Prepare Maven settings.xml
run: |
mkdir -p ~/.m2
echo "${{ secrets.MAVEN_SETTINGS }}" | base64 -d > ~/.m2/settings.xml
- name: Unit Test with Maven
run: mvn clean test -Djacoco.destFile=exportJacoco/jacoco-unit.exec
- name: Upload jacoco exec results
uses: actions/upload-artifact@v4
with:
name: jacoco-unit-test
path: exportJacoco/jacoco-unit.exec
integration-test:
name: integration test
runs-on: ubuntu-latest
needs: lint
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup JDK 17
uses: actions/setup-java@v4
with:
java-version: ${{ inputs.version }}
distribution: ${{ inputs.distribution }}
cache: maven
overwrite-settings: false
- name: Prepare Maven settings.xml
run: |
mkdir -p ~/.m2
echo "${{ secrets.MAVEN_SETTINGS }}" | base64 -d > ~/.m2/settings.xml
- name: Integration Test with Maven
run: mvn clean verify -Djacoco.destFile=exportJacoco/jacoco-integration.exec
- name: Upload jacoco exec results
uses: actions/upload-artifact@v4
with:
name: jacoco-integration-test
path: exportJacoco/jacoco-integration.exec
Expected behavior:
Artifacts should not be re-downloaded when cache is found and restored.
Actual behavior:
Cache doesn't seem to be restored properly.
What's even more strange, the lint run actually uses cache properly, but unit and integration tests don't
Hello @serpro69, Thank you for creating this issue and we will get back to you once we have some feedback on it :)
Hello @serpro69, would you be able to provide the steps to replicate the problem? Alternatively, a reference repository that I could examine would also be helpful.
Hi @mahabaleshwars ,
I've included a sample pipeline above. I can also try to reproduce this on a public repo, if you need.
I've tried to make a public copy of the setup and reproduce it, but couldn't.
I'll try to dig more into this, and will re-open if I can provide a reproducible example
Thanks