Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cache is reported as found and restored, but artifacts are still being downloaded #623

Closed
2 of 5 tasks
serpro69 opened this issue Apr 23, 2024 · 4 comments
Closed
2 of 5 tasks
Assignees
Labels
bug Something isn't working

Comments

@serpro69
Copy link

serpro69 commented Apr 23, 2024

Description:
A clear and concise description of what the bug is.

A screenshot is better than a thousand words?

image

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

@serpro69 serpro69 added bug Something isn't working needs triage labels Apr 23, 2024
@aparnajyothi-y
Copy link
Contributor

Hello @serpro69, Thank you for creating this issue and we will get back to you once we have some feedback on it :)

@mahabaleshwars mahabaleshwars self-assigned this May 2, 2024
@mahabaleshwars
Copy link
Contributor

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.

@serpro69
Copy link
Author

serpro69 commented May 6, 2024

Hi @mahabaleshwars ,
I've included a sample pipeline above. I can also try to reproduce this on a public repo, if you need.

@serpro69
Copy link
Author

serpro69 commented May 7, 2024

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

@serpro69 serpro69 closed this as completed May 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants