setup-go icon indicating copy to clipboard operation
setup-go copied to clipboard

Can't cache dependencies from a composite action

Open dkirrane opened this issue 10 months ago • 7 comments

Description: I have a repo with a go.mod and go.sum and I caller another repo that contains a composite action that checks out the caller repo and calls actions/setup-go@v5

name: Go Test

runs:
  using: "composite"

  steps:

    - name: Checkout
      uses: actions/checkout@v4

    - name: Setup Go
      uses: actions/setup-go@v5
      with:
        go-version-file: test/go.mod
        cache-dependency-path: test/go.sum

    - name: go test
      run: |
        cd test/
        go test
      shell: bash

Action version: actions/setup-go@v5

Platform:

  • [x] Ubuntu
  • [ ] macOS
  • [ ] Windows

Runner type:

  • [x] Hosted
  • [ ] Self-hosted

Tools version: go 1.21

Repro steps:

Caller repo calling the above composite action:

name: Caller

on:
  workflow_dispatch:

jobs:

  Test:
    runs-on: ubuntu-latest
    steps:
      - name: Go Test
        uses: company/gotest-action/test@main

Expected behavior: I was expecting dependencies to cache

Actual behavior: Cache is not found

Run actions/setup-go@v5
Setup go version spec 1.21
Found in cache @ /opt/hostedtoolcache/go/1.21.8/x64
Added go to the path
Successfully set up Go version 1.21
/opt/hostedtoolcache/go/1.21.8/x64/bin/go env GOMODCACHE
/opt/hostedtoolcache/go/1.21.8/x64/bin/go env GOCACHE
/home/runner/go/pkg/mod
/home/runner/.cache/go-build
Cache is not found
go version go1.21.8 linux/amd64

dkirrane avatar Apr 02 '24 09:04 dkirrane

I was expecting dependencies to cache

Just to clarify: you're seeing the cache not found on repeated runs on the same branch in the calling repo?

Do you see the cache being successfully saved on a previous run with a line like (in the Post Go Test section):

Cache saved with the key: setup-go-Linux-ubuntu22-....

matthewhughes934 avatar Apr 02 '24 17:04 matthewhughes934

Hello @dkirrane, Thank you for creating this issue and we will look into it :)

aparnajyothi-y avatar Apr 03 '24 13:04 aparnajyothi-y

@matthewhughes934 - yes to confirm re-runs always download dependencies again

image

I can see there is 1 cache

image

dkirrane avatar Apr 05 '24 13:04 dkirrane

to confirm re-runs always download dependencies again

:+1: in that case is your issue related to the first run of the action? From what I understand cache access is limited to workflows the repo they were created in (from: https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#restrictions-for-accessing-a-cache) so I wouldn't expect the first run to hit any cache

matthewhughes934 avatar Apr 07 '24 20:04 matthewhughes934

Ok, seems similar to this https://github.com/actions/toolkit/issues/1035 I'll try the workaround suggested

dkirrane avatar Apr 09 '24 10:04 dkirrane

Hello @dkirrane 👋, I've attempted to reproduce the issue on my end, but was unable to do so. In my test environment, caching and reuse of dependencies worked as expected. It appears that the issue might be confined to your specific setup or workflow configuration. Could you please provide a link to a minimal reproduction of the issue? It would be very helpful in addressing your issue. Thank you!


priyagupta108 avatar Apr 16 '24 09:04 priyagupta108

Hello @dkirrane, Just a gentle reminder about the issue. If you could provide a minimal reproduction of the problem, it would help us in investigating this further. Thank you in advance!

priyagupta108 avatar Apr 30 '24 09:04 priyagupta108

Hello @dkirrane👋 , A gentle reminder regarding the problem. A minimal reproduction of the problem from your end would be a great help. We look forward to your response. Thank you!

priyagupta108 avatar May 15 '24 10:05 priyagupta108

Hello @dkirrane👋, Due to inactivity, I'm going to close this issue for now. Please feel free to reopen the issue if necessary, or create a new one. Thank you :)

priyagupta108 avatar May 29 '24 12:05 priyagupta108