actions / setup-go

Set up your GitHub Actions workflow with a specific version of Go
MIT License
1.41k stars 531 forks source link

Can't cache dependencies from a composite action #467

Closed dkirrane closed 5 months ago

dkirrane commented 7 months ago

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:

Runner type:

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
matthewhughes934 commented 7 months ago

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-....

aparnajyothi-y commented 7 months ago

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

dkirrane commented 7 months ago

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

image

I can see there is 1 cache

image

matthewhughes934 commented 7 months ago

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

dkirrane commented 7 months ago

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

priyagupta108 commented 7 months ago

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 commented 6 months ago

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 commented 6 months ago

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 commented 5 months ago

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 :)