Skip to content

Support parsing node versions from Github Actions #4

Description

@dominykas
No description provided.

Activity

  1. dominykas commented on Mar 1, 2020

    @dominykas
    MemberAuthor

    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)
  2. wesleytodd commented on Mar 3, 2020

    @wesleytodd
    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!

  3. bdougie commented on Mar 11, 2020

    @bdougie

    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.

  4. dominykas commented on Mar 12, 2020

    @dominykas
    MemberAuthor

    $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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions