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

Add information how to properly set up checked-out code with GO... env variables #102

Closed
januszm opened this issue Jan 28, 2021 · 7 comments
Labels
documentation Improvements or additions to documentation

Comments

@januszm
Copy link

januszm commented Jan 28, 2021

Most basic setup with the following steps:

- uses: actions/checkout@v2
...
- uses: actions/setup-go@v2

will fail during dep ensure or go test ./... :

/home/runner/work/myproject/myproject is not within a known GOPATH/src

I must admit that with a little bit of searching I couldn't easily configure it.
Currently it starts with empty directories:

/home/runner/go
/home/runner/go/bin

The code after checkout is in:

/home/runner/work/REPOSITORY/REPOSITORY

It would be worth adding some instructions on how to modify the "checkout" step or how to set environment variables or what shell commands to execute to make it all work.

@januszm
Copy link
Author

januszm commented Jan 28, 2021

I got it to work with this yml:

env:
  GOPATH: ${{ github.workspace }}
  GOBIN: ${{ github.workspace }}/bin
defaults:
  run:
    working-directory: ${{ env.GOPATH }}/src/myproject
steps:
  - uses: actions/checkout@v2
    with:
      fetch-depth: 1
      path: ${{ env.GOPATH }}/src/myproject
  - name: Set up Go
    uses: actions/setup-go@v2
    with:
      go-version: ...

The key was to set this: "working-directory: ${{ env.GOPATH }}/src/myproject" and be consistent.
An equivalent of Travis's go_import_path is to define path: ${{ env.GOPATH }}/src/myproject for checkout and working-directory

@longwuyuan
Copy link

longwuyuan commented Jan 28, 2021

what is github.workspace .. its failing for me when it is supposed to be that /home/runner/go

@longwuyuan
Copy link

hi @januszm thanks for the comments earlier. Your workaround is good. I tried and the test passed. However there is more to this and since I am not a developer I can't talk too much.

basically the idea of modules as documented at golan.org for go version 1.15 is that GO111MODULE is not needed to be set and also using modules means no use of GOPATH. But neither works in case of my code for a specific integration test framework. Normal build works. Thanks you again

@longwuyuan
Copy link

my problem turned out to be unique for the codebase in question kubernetes/kube-openapi#225

infraweavers added a commit to infraweavers/GoBuildTest that referenced this issue Feb 11, 2021
@Sergey-Murtazin Sergey-Murtazin added the documentation Improvements or additions to documentation label Oct 21, 2021
@Sergey-Murtazin
Copy link
Contributor

Hi @januszm ! Sorry for the late response!
Could you please clarify if the issue is still actual for you?
Thanks!

@Sergey-Murtazin
Copy link
Contributor

Sergey-Murtazin commented Dec 15, 2021

Hi, @januszm !

Thanks for your proposal.
But we don't consider adding such instructions. Because they are related to the work of the other action.
Also because this issue is not actual already, as I see.

Feel free to contact us if you have any questions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

3 participants