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

Support for Outputting or Exporting Go Environment Variables #54

Open
bflad opened this issue May 28, 2020 · 9 comments · May be fixed by #334
Open

Support for Outputting or Exporting Go Environment Variables #54

bflad opened this issue May 28, 2020 · 9 comments · May be fixed by #334
Assignees
Labels
feature request New feature or request to improve the current logic

Comments

@bflad
Copy link

bflad commented May 28, 2020

Version

actions/setup-go@v2

Description

In some of our GitHub Actions workflows, we opt to cache the GOCACHE between jobs to save compilation time. It seems like we currently need to run go env GOCACHE to fetch the correct GOCACHE path after this action is run, e.g.

jobs:
  example:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2
    - uses: actions/setup-go@v2
      with:
        go-version: "1.14"
    - name: go env
      run: |
        echo "::set-env name=GOCACHE::$(go env GOCACHE)"
    - uses: actions/cache@v2
      with:
        path: ${{ env.GOCACHE }}
        key: ${{ runner.os }}-GOCACHE-${{ hashFiles('go.sum') }}-${{ hashFiles('src/**') }}

Since this action already runs go env, it would be great if those values were either available as outputs, e.g.

jobs:
  example:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2
    - uses: actions/setup-go@v2
      id: setup_go
      with:
        go-version: "1.14"
    - uses: actions/cache@v2
      with:
        path: ${{ steps.setup_go.outputs.GOCACHE }}
        key: ${{ runner.os }}-GOCACHE-${{ hashFiles('go.sum') }}-${{ hashFiles('src/**') }}

Or if we could configure environment variables to automatically be exported:

jobs:
  example:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2
    - uses: actions/setup-go@v2
      with:
        go-version: "1.14"
        export-environment-variables: [GOCACHE]
    - uses: actions/cache@v2
      with:
        path: ${{ env.GOCACHE }}
        key: ${{ runner.os }}-GOCACHE-${{ hashFiles('go.sum') }}-${{ hashFiles('src/**') }}

Thank you for the consideration! Please reach out if I'm missing something and this is already possible or if this would be acceptable as an enhancement.

@Sergey-Murtazin
Copy link
Contributor

Sergey-Murtazin commented Oct 19, 2021

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

@Sergey-Murtazin Sergey-Murtazin added the enhancement New feature or request label Oct 19, 2021
@jgustie
Copy link

jgustie commented Oct 19, 2021

It definitely helps make workflow definitions platform agnostic. For example, it would allow all three platform specific cache action examples to be replaced with a single more robust example:

- uses: actions/cache@v2
  with:
    path: |
      ${{ steps.setup_go.outputs.GOCACHE }}
      ${{ steps.setup_go.outputs.GOMODCACHE }}
    key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
    restore-keys: |
      ${{ runner.os }}-go-

This particular use case may not be as relevant if setup-go had a cache input (like setup-node) to handle cache setup.

@bflad
Copy link
Author

bflad commented Oct 19, 2021

Hi @Sergey-Murtazin 👋 Certainly still valid for our use cases, mostly to help with platform agnostic workflows as mentioned above. Thanks!

@Sergey-Murtazin Sergey-Murtazin added feature request New feature or request to improve the current logic and removed enhancement New feature or request labels Oct 25, 2021
@lucacome
Copy link

I was about to open a similar issue 🙂

I'm interested in GOPATH and I know it's pretty simple to retrieve it, but having it as an output of the action would make the workflows cleaner IMHO.

A JSON output of go env would work too.

@e-korolevskii e-korolevskii self-assigned this Aug 31, 2022
@e-korolevskii e-korolevskii removed their assignment Oct 27, 2022
@qrkourier
Copy link

It'd be helpful to have go env as outputs from this action so that it's not necessary to solve for GOBIN, GOPATH, GOCACHE in the worflow.

@lucacome lucacome linked a pull request Feb 16, 2023 that will close this issue
2 tasks
@lucacome
Copy link

I've opened a #334 with some default outputs that I think will cover 99% of the cases, let me know what you think 🙏

@urica12
Copy link

urica12 commented Feb 16, 2023

Run

@mvdan
Copy link

mvdan commented Mar 27, 2023

Would love this as well. I currently have extra steps like echo "dir=$(go env GOMODCACHE)" >> ${GITHUB_OUTPUT}, which are verbose and wasteful, since setup-go has already run go env.

@dsame dsame self-assigned this Jul 12, 2023
@IvanZosimov IvanZosimov added the investigation The issue is under investigation label Aug 3, 2023
@dsame dsame removed the investigation The issue is under investigation label Aug 3, 2023
@dsame
Copy link
Contributor

dsame commented Aug 28, 2023

The issue is waiting for the merge of the PR #334

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature or request to improve the current logic
Projects
None yet
Development

Successfully merging a pull request may close this issue.

12 participants