jandelgado / gcov2lcov-action

Github action to convert go coverage files to lcov format
MIT License
22 stars 2 forks source link

error: cannot find GOROOT directory: /opt/hostedtoolcache/go/1.13.15/x64 #13

Closed pashagolub closed 2 years ago

pashagolub commented 2 years ago

One of the latest runs of my workflow failed:

Run jandelgado/gcov2lcov-action@master
  with:
    infile: profile.cov
    outfile: coverage.lcov
    version: latest
Run set -x && curl -sLf "$([ latest == latest ] && echo $LATEST_RELEASE || echo $RELEASE)/${NAME}.tar.gz" | tar zxf - --strip 1
  set -x && curl -sLf "$([ latest == latest ] && echo $LATEST_RELEASE || echo $RELEASE)/${NAME}.tar.gz" | tar zxf - --strip 1
  shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
  env:
    NAME: gcov2lcov-linux-amd64
    RELEASE: https://github.com/jandelgado/gcov2lcov/releases/download/latest
    LATEST_RELEASE: https://github.com/jandelgado/gcov2lcov/releases/latest/download
+ tar zxf - --strip 1
++ '[' latest == latest ']'
++ echo https://github.com/jandelgado/gcov2lcov/releases/latest/download
+ curl -sLf https://github.com/jandelgado/gcov2lcov/releases/latest/download/gcov2lcov-linux-amd64.tar.gz
Run set -x && /tmp/gcov2lcov-linux-amd64 -infile "profile.cov" -outfile "coverage.lcov"
  set -x && /tmp/gcov2lcov-linux-amd64 -infile "profile.cov" -outfile "coverage.lcov"
  shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
+ /tmp/gcov2lcov-linux-amd64 -infile profile.cov -outfile coverage.lcov
2022/05/18 14:07:34 warn: go/build: importGo github.com/pashagolub/pgxmock/: exit status 2
go: cannot find GOROOT directory: /opt/hostedtoolcache/go/1.13.15/x64

2022/05/18 14:07:34 warn: go/build: importGo github.com/pashagolub/pgxmock/: exit status 2
go: cannot find GOROOT directory: /opt/hostedtoolcache/go/1.13.15/x64

2022/05/18 14:07:34 warn: go/build: importGo github.com/pashagolub/pgxmock/: exit status 2
go: cannot find GOROOT directory: /opt/hostedtoolcache/go/1.13.15/x64

2022/05/18 14:07:34 warn: go/build: importGo github.com/pashagolub/pgxmock/: exit status 2
go: cannot find GOROOT directory: /opt/hostedtoolcache/go/1.13.15/x64

2022/05/18 14:07:34 warn: go/build: importGo github.com/pashagolub/pgxmock/: exit status 2
go: cannot find GOROOT directory: /opt/hostedtoolcache/go/1.13.15/x64

2022/05/18 14:07:34 warn: go/build: importGo github.com/pashagolub/pgxmock/: exit status 2
go: cannot find GOROOT directory: /opt/hostedtoolcache/go/1.13.15/x64
...

Is it because runner doesn't have Go v1.13 installed anymore?

omegion commented 2 years ago

Same here, it fails for me too.

omegion commented 2 years ago

You can try https://github.com/mattn/goveralls#github-actions. @pashagolub

pashagolub commented 2 years ago

I did thanks

jandelgado commented 2 years ago

Good question ;) I'll check it in the next days

jandelgado commented 2 years ago

@pashagolub I can't find where this reference to go 1.13 is coming from. Any ideas?

pashagolub commented 2 years ago

Sorry. No idea. But my other projects suffers from the very same error: https://github.com/cybertec-postgresql/pg_timetable/runs/6518909375

dragondgold commented 2 years ago

In my case I solved it by adding this as a step before gcov2lcov:

- name: Set up GOPATH
  shell: bash
  run: |
     echo "GOROOT=$(go env GOROOT)" >> "$GITHUB_ENV"
jandelgado commented 2 years ago

I was able to reproduce the problem as follows:

  1. check out source repo
  2. run go mod download
  3. run tests with go test -v -coverprofile=profile.cov
  4. unset GOROOT environment variable (unset GOROOT)
  5. run gcov2lcov-linux-amd64 -infile profile.cov -outfile profile.lcov

This results in warnings like:

022/05/23 16:00:58 warn: go/build: importGo github.com/pashagolub/pgxmock/: exit status 2
go: cannot find GOROOT directory: /opt/hostedtoolcache/go/1.13.15/x64

However, if GOROOT is set properly, everything works fine. The reason that GOROOT is no longer set is because of a change in the setup-go action, which was recently introduced. I'll see how I can fix it...

jandelgado commented 2 years ago

@pashagolub I fixed the problem by always setting GOROOT before calling gcov2lcov and released a new version. Just use the v1 tag like in jandelgado/gcov2lcov-action@v1 to use the up-to-date version.