Git Product home page Git Product logo

action's Introduction

GitHub Action to Setup Volta

GitHub Actions status

This action installs volta by:

  • downloading and caching volta (adding it to your $PATH)
  • optionally downloading and caching a version of node - npm by version spec and add to PATH

Inputs

parameter description required default
volta-version Version of volta to fetch and setup. Examples: 0.6.0, 10.15.1, >=10.15.0 false
node-version Version Spec of the node version to use. Examples: 10.6.x, 10.15.1, >=10.15.0 false
npm-version Version Spec of the npm version to use. Examples: 7.5.x, 7.5.3, >=7.5.3 false
yarn-version Version Spec of the yarn version to use. Examples: 1.6.x, 10.15.1, >=10.15.0 false
package-json-path The path to the package.json to update when using an explicit node-version yarn-version npm-version override. By default, we will use package.json in the checkout root.
variant Specific variant to install. Example: providing the variant "linux-openssl-rhel", which will target installing the volta-${version}-linux-openssl-rhel.tar.gz tarball false
registry-url Optional registry to set up for auth. Will set the registry in a project level .npmrc file, and set up auth to read in from env.NODE_AUTH_TOKEN false
scope Optional scope for authenticating against scoped registries. Will fall back to the repository owner when using the GitHub Packages registry (https://npm.pkg.github.com/). false
token Used to avoid low rate limiting for cached tool downloads. Since there's a default, this is typically not supplied by the user. false ${{ github.token }}
always-auth Set always-auth in npmrc false false

Usage

See action.yml

Basic (when the project's package.json has a volta property with node and/or yarn versions pinned):

steps:
- uses: actions/checkout@v4
- uses: volta-cli/action@v4
- run: npm install
- run: npm test

Manually specifying node and/or yarn versions (e.g. to test a project without volta in package.json):

steps:
- uses: actions/checkout@v4
- uses: volta-cli/action@v4
  with:
    node-version: 18.x
    yarn-version: 1.19.1

- run: yarn install
- run: yarn test

Setting up a matrix of node versions:

strategy:
  matrix:
    node-version: ['^14.10', '16', '18']

steps:
- uses: actions/checkout@v4
- uses: volta-cli/action@v4
  with:
    node-version: ${{ matrix.node-version }}

- run: npm install
- run: npm test

You can also specify the version of npm:

strategy:
  matrix:
    node-version: ['^8.12', '10', '12']

steps:
- uses: actions/checkout@v4
- uses: volta-cli/action@v4
  with:
    node-version: ${{ matrix.node-version }}
    npm-version: '7'

- run: npm install
- run: npm test

In some cases, you may know the particular variant of the installer that you want to use for Volta. You can specify the variant input to the action to use a specific installer:

steps:
- uses: actions/checkout@v4
- uses: volta-cli/action@v4
  with:
    variant: 'linux-openssl-rhel'

- run: yarn install
- run: yarn test

The variant fragment corresponds to a portion of the installer filename, and can be found in the Volta Releases page.

License

The scripts and documentation in this project are released under the MIT License

action's People

Contributors

alexlafroscia avatar dependabot[bot] avatar felipecrs avatar jeevcat avatar maxwell2022 avatar otahontas avatar pzuraq avatar rwjblue avatar scalvert avatar stijnvn avatar turbo87 avatar zaubernerd avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

action's Issues

Testing Against Multiple Node Versions

I'm wondering if there's any way to use this action to test against multiple versions of node when one of them is pinned in the package.json.

I tried to do something like this:

name: Verify

on: [push]

jobs:
  test:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        node-version: [6.7.0, 12.16.1]
    steps:
      - uses: actions/checkout@v1
      - uses: volta-cli/action@v1
        with:
          node-version: ${{ matrix.node-version }}
      - name: Print node version
        run: node --version
      - run: yarn install
      - run: yarn test

But the pinned version from package.json is used regardless of what was provided in node-version.

Node 20

Hi, I saw that you had switched to node 20 on the main branch. Would it be possible to do a curtesy version or are we waiting for some other tickets to finalize before moving to v5?

package.json in a subdirectory

I have a mono repo with a volta-using project in a subdirectory. There is no root package.json:

$ ls **/package.json | grep -v node_modules
app/package.json

Is it possible to point volta action to a non-root package.json location?

I cannot have package.json in root, because of unrelated bug in another tool I'm using.

Action fails to download `[email protected]`

volta-cli/action started failing suddenly today.

Here are the errors that I have observed:

Using volta-cli/action@v1

Run volta-cli/action@v1
downloading [email protected]
Object prototype may only be an Object or null: undefined
Waiting 14 seconds before trying again
Object prototype may only be an Object or null: undefined
Waiting 1[6](https://github.com/<reducted>/<reducted>/actions/runs/3267621963/jobs/5373337030#step:3:7) seconds before trying again
Error: Object prototype may only be an Object or null: undefined

Using volta-cli/action@v3

Run volta-cli/action@v3
looking up latest volta version from https://volta.sh/latest-version
downloading [email protected]
/usr/bin/openssl version
OpenSSL 1.1.1f  31 Mar 2020
Error: Unexpected HTTP response: 404

The [email protected] seems to be available (and has been for some time.)

Interestingly enough, pinning the version to 1.0.8 "fixes" the errors:

- uses: volta-cli/action@v3
  with:
   volta-version: 1.0.8

Any pointers?

Intermittent errors unpacking Node v18.18.2

Since I bumped the version of Node to v18.18.2 on a number of my projects in package.json, setting up of this version as part of my github actions workflow frequently fails:

Volta error: Could not unpack Node v18.18.2

Please ensure the correct version is specified.
Volta error: Error cause: failed to unpack `/opt/hostedtoolcache/volta/1.1.1/x64/tmp/.tmp1h3dUo/node-v18.18.2-linux-x64/bin/node`

Error cause: failed to unpack `/opt/hostedtoolcache/volta/1.1.1/x64/tmp/.tmp1h3dUo/node-v18.18.2-linux-x64/bin/node`

Error cause: failed to unpack `node-v18.18.2-linux-x64/bin/node` into `/opt/hostedtoolcache/volta/1.1.1/x64/tmp/.tmp1h3dUo/node-v18.18.2-linux-x64/bin/node`

Error cause: Resource temporarily unavailable (os error 11)

Failing run: https://github.com/pulumiverse/infra/actions/runs/6574407526/job/17859391875

When I trigger the Rerun failed jobs button on the Github web UI, the re-run usually succeeds. For example, here is the re-run which succeeds: https://github.com/pulumiverse/infra/actions/runs/6574407526/job/17862002636

My workflow file: https://github.com/pulumiverse/infra/blob/main/.github/workflows/pull-request.yml#L13-L14

Such intermittent errors don't contribute to a stable CI experience.

Is there any way I can root-cause this error? Has anyone encountered this error also?

Enhance documentation/ explain how it works

I wonder how it suppresses the node version I've set in my package.json, which is a very good feature, but I wonder how this action does that.

Is it by running volta pin node@version? If so, does it leave the package.json modified?

Failure in Github workflows on ec2-runners

I'm using this action in my CI, but getting errors regarding my profile/bashrc.

executing `/__w/_tool/volta/1.1.1/x64/bin/volta setup`
/__w/_tool/volta/1.1.1/x64/bin/volta setup
error: Could not locate user profile.
Tried $PROFILE (), ~/.bashrc, ~/.bash_profile, ~/.zshrc, ~/.profile, and ~/.config/fish/config.fish

Please create one of these and try again; or you can edit your profile manually to add '/__w/_tool/volta/1.1.1/x64/bin' to your PATH
Error: The process '/__w/_tool/volta/1.1.1/x64/bin/volta' failed with exit code 6

Minimum Working Example

name: Minimum Working Example
on:
  push:
defaults:
  run:
    shell: bash
jobs:
  success-ubuntu:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - name: Setup Volta-cli
        uses: volta-cli/action@v4
  fail-ec2:
    runs-on: ec2-runners
    container:
      image: ${{ vars.EC2_RUNNER }}
    steps:
      - uses: actions/checkout@v3
      - name: Setup Volta-cli
        uses: volta-cli/action@v4

Set up eslint and tsc problem matchers?

The setup-node action automatically adds eslint and tsc problem matchers to the build. I thought I read somewhere in the documentation that it's considered best practice for setup-* actions to add relevant problem matchers specific to that language, but I couldn't find the source. In any case, since this is often used as a direct replacement for setup-node, should it do the same? Or is it expected to use setup-node and setup-volta side-by-side for this purpose?

Github Requiring Node 20

With Github announcing mandatory updating to Node 20 starting in May, will there be a new release soon to bump volta-cli/action to Node 20? I see it's been merged to main, but not yet released

https://github.blog/changelog/2024-03-07-github-actions-all-actions-will-run-on-node20-instead-of-node16-by-default/

From them:

Node16 has been out of support since September 2023. As a result we have started the deprecation process of Node16 for GitHub Actions. We plan to migrate all actions to run on Node20 by Spring 2024.
Following on from our warning in workflows using Node16 we will start enforcing the use of Node20 rather than Node16 on the 13th of May.

Installing executables with Volta

Hi!
I have an issue while setting up Volta and aws cdk.
I would like to use cdk cli in the later steps (cdk synth, cdk deploy) but no executable is installed. However, this works flawlessly in local.

Git action
image

Local
image

Remove assumption about OpenSSL version

Currently hardcoded to assume linux is using openssl 1.1 (this is because the Ubuntu 18.04 environments provided by GH are using OpenSSL 1.1, so it happens to work). We need to confirm that Ubuntu 16.04 environments also work...

Support `npm-version`

It currently seems to support volta-version, node-version, and yarn-version. It's just missing npm-version, which I would want to set on 7 for example.

Use @action/cache to cache where possible

There are a few scenarios where we could take advantage of the newly published caching package:

  • To download volta itself (though this should already be cached)
  • To download a tool based on the provided explicit node/yarn version
  • When using this action without manually specifying node-version or yarn-version. We should be able to cache based on the volta key in package.json, and avoid having to download node/volta/etc if nothing has changed.
  • When using a SemVer range matcher like node-version: 12.x. This is a bit trickier than the prior scenario since it is not obvious how to comprise the cache key so that you do get a newer versions within your allowed range "periodically". Ideally we do not need to duplicate the logic in Volta itself for determining the node versions.

Support `actions/setup-node`'s `registry-url` input

Example:

# Setup .npmrc file to publish to npm
- uses: actions/setup-node@v1
  with:
    registry-url: 'https://registry.npmjs.org'

Creates an .npmrc file with the following:

//registry.npmjs.org/:_authToken=${NODE_AUTH_TOKEN}
registry=https://registry.npmjs.org/
always-auth=true

Pre-Packaged Actions Unable to Locate Executables

I ran into a case where another action in my workflow required npx, but the environment configured by Volta didn't provide it. I tried to manually run volta install npx as a step in my workflow, but ran into this error:

Screen Shot 2020-11-19 at 2 01 06 PM

I'm not sure if this just doesn't work conceptually, is an issue with Volta, or is an issue with npx itself not working with Volta. Does it seem like this should have worked?

If additional context helps, the full workflow can be found here:

https://github.com/movableink/tailwind-config/pull/305/checks?check_run_id=1426078472

Object prototype may only be an Object or null: undefined

With a workflow something like this:

jobs:
  build_and_test:
    runs-on: ubuntu-18.04
    steps:
      - uses: actions/checkout@v2
      - uses: volta-cli/action@v1

Sometimes I get this error:

Run volta-cli/action@v1
  with:
downloading [email protected]
Object prototype may only be an Object or null: undefined
Waiting 15 seconds before trying again
Object prototype may only be an Object or null: undefined
Waiting 17 seconds before trying again
Error: Object prototype may only be an Object or null: undefined

But we usually get something like this:

Run volta-cli/action@v1
downloading [email protected]
/bin/tar xz --warning=no-unknown-keyword -C /home/runner/work/_temp/78439663-c6be-4524-a513-5bae4b96382d/bin -f /home/runner/work/_temp/b685a57c-16cf-4c07-b8bd-31cb865c76ee
/home/runner/work/_temp/78439663-c6be-4524-a513-5bae4b96382d/bin/volta setup
caching [email protected] into /opt/hostedtoolcache/volta/1.0.5/x64
adding /opt/hostedtoolcache/volta/1.0.5/x64/bin to $PATH

Please release

Hey! Thanks for the action.
Can you create a release so we can use the registry url input.
Thanks!

Unexpected input(s) 'registry-url'

I saw there registry-url in here
but when I try with a workflow like this:

jobs:
  publish-npm:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
         uses: actions/checkout@v3
         with:
           fetch-depth: 0

      - name: Setup environment with volta
         uses: volta-cli/action@v1
         with:
           registry-url: https://registry.npmjs.org/

      - name: Publish Package
         run: npm publish --access public
         env:
           NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

I get this warning:

Warning: Unexpected input(s) 'registry-url', valid inputs are ['volta-version', 'node-version', 'npm-version', 'yarn-version']
Run volta-cli/action@v1
downloading [email protected]

then I get this error:

npm ERR! code E404
npm ERR! 404 Not Found - PUT https://registry.npmjs.org/@logustra%2fvountdown - Not found
npm ERR! 404 
npm ERR! 404  '@logustra/[email protected]' is not in the npm registry.

Using volta-cli/action on GitHub Enterprise Server causes frequent rate-limits with no fallback

We are using this action on GitHub Enterprise Server and we're seeing frequent failures trying to get the latest volta-cli version, because we're not authenticated against GitHub.com.

For now we have pinned the volta-version to 1.0.8, but we would like to remove that pinning again, so that we will get the latest volta-cli version in the future.

I saw that the actions/setup-node action has a fallback to get the version directly from nodejs.org in case of rate-limits: https://github.com/actions/setup-node/blob/9f3a02bbd17adc05b078145bb8f676c84be77e89/src/installer.ts#L109-L129
Maybe something like that would make sense to implement in this action also.

I actually have two ideas that could solve this:

  1. check if the request got rate-limited and fall back to https://volta.sh/latest-version
  2. check if the request got rate-limited and do a HEAD request to https://github.com/volta-cli/volta/releases/latest which will redirect to the latest version

If there's interest and a suggestion on which route to take, I'd be willing to create a PR for it.

Ref: #77, #101, #97

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.