nrwl / nx-cloud-workflows

MIT License
8 stars 6 forks source link

feat(steps): add install-node step #49

Closed barbados-clemens closed 3 months ago

barbados-clemens commented 4 months ago

This step allows installing a defined version of node via nvm. This version can be passed to agents via the node_version input. environment variable or via populating a .nvmrc file in the workspace.

- name: Install Node v18
  uses: 'nrwl/nx-cloud-workflows/<version>/workflow-steps/install-nodes/main.yaml'
  inputs:
    node_version: 18

if a .nvmrc file exists in the workspace (via a checkout step), then the node_version input can be omitted.

- name: Install Node v18
  uses: 'nrwl/nx-cloud-workflows/<version>/workflow-steps/install-nodes/main.yaml'

the volta.node version will be picked up as well if node_version input or .nvmrc file isn't passed in.

NOTE: we still allow passing NODE_VERSION env as a fallback for now. so we could technically publish a v3 and v4 of the step if so desired without modifications. This would allow us to add this step in the default workflow and folks can pass via the nx-cloud cli a --with-env-vars="NODE_VERSION" and that node version will be used. (or a .nvmrc/volta.node version).

Will hold off on updating the default template until I can confirm how we want to proceed.

barbados-clemens commented 4 months ago

Also I'd like some help in testing this, as trying to reference this step results in steps erroring out sliently in some way that I'm unsure how to debug.

image https://staging.nx.app/cipes/6638e2898f54e76fcee20fb4

barbados-clemens commented 3 months ago

Might need to go back to the drawing board on this one, as using corepack results in potential issues of peoples package.json getting modified if they aren't using corepack which can result in affected/cache hits. WkMacM1-Vq6trj0J_05200908

! The local project doesn't define a 'packageManager' field. Corepack will now add one referencing yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e.
! For more details about this field, consult the documentation at https://nodejs.org/api/packages.html#packagemanager
JamesHenry commented 3 months ago

@barbados-clemens You can try setting COREPACK_ENABLE_AUTO_PIN=0

Source: https://github.com/nodejs/corepack?tab=readme-ov-file#environment-variables

barbados-clemens commented 3 months ago

fixed issued with info from james in a new test image.