actions / cache

Cache dependencies and build outputs in GitHub Actions
MIT License
4.37k stars 1.16k forks source link

hashFiles('**/go.sum') returns empty string #1250

Closed PanKaker closed 2 months ago

PanKaker commented 9 months ago

Hi!

Problem: hashFiles('/go.sum') returns empty string Environment**: Kubernetes runners with a Golang project

My CI looks like that:

   - name: Ls dir
      shell: bash
      run: |
        ls 

    - name: Get Go Cache environment
      shell: bash
      run: |
        echo "gomodcache=$(go env GOMODCACHE)" >> $GITHUB_ENV

    - name: Restore cache
      uses: actions/cache@v3
      with:
        path: |
          ${{ env.gomodcache }}
        key: ${{ runner.os }}-go-mod-${{ hashFiles('**/go.sum') }}
        restore-keys: |
          ${{ runner.os }}-go-mod-

I've noticed that sometimes step "Restore cache" returns empty key:

Run actions/cache@v3
  with:
    path: /go/pkg/mod

    key: Linux-go-mod-
    restore-keys: Linux-go-mod-

    enableCrossOsArchive: false
    fail-on-cache-miss: false
    lookup-only: false
  env:
    gomodcache: /go/pkg/mod

I've checked with "ls dir" step, that files are there: go.mod and go.sum I've tried to run the command with debugging log:

##[debug]Search pattern: '**/go.sum'
##[debug]Starting process:
##[debug]  File name: '/runner/externals/node16/bin/node'
##[debug]  Arguments: '"/runner/bin/hashFiles"'
##[debug]  Working directory: something
##[debug]  Require exit code zero: 'False'
##[debug]  Encoding web name:  ; code page: ''
##[debug]  Force kill process on cancellation: 'False'
##[debug]  Redirected STDIN: 'False'
##[debug]  Persist current code page: 'False'
##[debug]  Keep redirected STDIN open: 'False'
##[debug]  High priority process: 'False'
##[debug]Failed to update oom_score_adj for PID: 760.
##[debug]System.UnauthorizedAccessException: Access to the path '/proc/760/oom_score_adj' is denied.
##[debug] ---> System.IO.IOException: Permission denied
##[debug]   --- End of inner exception stack trace ---
##[debug]   at System.IO.RandomAccess.WriteAtOffset(SafeFileHandle handle, ReadOnlySpan`1 buffer, Int64 fileOffset)
##[debug]   at System.IO.Strategies.BufferedFileStreamStrategy.FlushWrite()
##[debug]   at System.IO.Strategies.BufferedFileStreamStrategy.Dispose(Boolean disposing)
##[debug]   at System.IO.StreamWriter.CloseStreamFromDispose(Boolean disposing)
##[debug]   at System.IO.StreamWriter.Dispose(Boolean disposing)
##[debug]   at System.IO.File.WriteAllText(String path, String contents)
##[debug]   at GitHub.Runner.Sdk.ProcessInvoker.WriteProcessOomScoreAdj(Int32 processId, Int32 oomScoreAdj)
##[debug]Process started with process id 760, waiting for process exit.
##[debug]Match Pattern: **/go.sum
##[debug]::debug::followSymbolicLinks 'false'
##[debug]::debug::followSymbolicLinks 'false'
##[debug]::debug::implicitDescendants 'true'
##[debug]::debug::matchDirectories 'true'
##[debug]::debug::omitBrokenSymbolicLinks 'true'
##[debug]::debug::Search path git_dir
##[debug]Hash result: ''
##[debug]undefined
##[debug]STDOUT/STDERR stream read finished.
##[debug]STDOUT/STDERR stream read finished.
##[debug]Finished process 760 with exit code 0, and elapsed time 00:00:00.0856179.
##[debug]..=> ''
##[debug]=> 'Linux-go-mod-'
##[debug]Result: 'Linux-go-mod-'

I think it could be connected with the error:

[debug]System.UnauthorizedAccessException: Access to the path '/proc/760/oom_score_adj' is denied.

[debug] ---> System.IO.IOException: Permission denied

Any help would be great. Thank you.

github-actions[bot] commented 2 months ago

This issue is stale because it has been open for 200 days with no activity. Leave a comment to avoid closing this issue in 5 days.

github-actions[bot] commented 2 months ago

This issue was closed because it has been inactive for 5 days since being marked as stale.