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 parsing node versions from Github Actions #4

Open
dominykas opened this issue Feb 7, 2020 · 4 comments · May be fixed by #68
Open

Support parsing node versions from Github Actions #4

dominykas opened this issue Feb 7, 2020 · 4 comments · May be fixed by #68

Comments

@dominykas
Copy link
Member

No description provided.

@dominykas
Copy link
Member Author

dominykas commented Mar 1, 2020

A node version can be defined in any of the .github/workflows/*.yml files:

  1. In the matrix (it seems people use node-version and node keys for that)
  2. Inside uses: with: (when uses: setup-node@v1, the with will contain node-version, which can either be a static value or an item from the matrix)
  3. Some people install node using nvs, rather than setup-node (e.g. https://github.com/mishoo/UglifyJS2/blob/master/.github/workflows/ci.yml)

@wesleytodd
Copy link
Member

Since this is the one I am most interested in, I will post a link to the basic setup I am doing:

https://github.com/pkgjs/support/blob/master/.github/workflows/test.yml

As you say, this follows the pattern of using node-version, but that is just an arbitrary key coppied from their examples. A user can change that to anything. So, the best way to robustly do this is to read the lines here https://github.com/wesleytodd/create-package-json/blob/master/.github/workflows/test.yml#L17-L18.

If you look for jobs.[job].steps[step].uses.startsWith('actions/setup-node'), then in that look at .with.node-version, then parse the double curly brace expression we should be able to look up the key in the matrix block.

I think this will be brittle, but I am not sure we can do better with the power which GitHub Actions gives. I am going to ping in @bdougieYO from GH to see if maybe someone from their side can give us a better way to do this. @bdougieYO any help (or hook us up with someone who can) would be appreciated!

@bdougie
Copy link

bdougie commented Mar 11, 2020

I would lean towards what you are describing @wesleytodd.

But if I had the bandwidth, I would explore updating the https://github.com/actions/setup-node to provide a $NODE_VERSION env. That way you wouldn't have to guess or need to lean on a deeply nested check.

I am not sure if that would get approved and merged, but it would be worth opening up this discussion/issue in that repo.

@dominykas
Copy link
Member Author

$NODE_VERSION env

This would only be available when the action is running?

The tool I'm building is to generate the stats about what people are using in their test setup - so I suspect I'll do what @wesleytodd proposes for now, and I'll see where that takes me after I actually collect some data.

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

Successfully merging a pull request may close this issue.

3 participants