newrelic / node-native-metrics

Optional native module for collecting low-level Node & V8 metrics
Apache License 2.0
63 stars 41 forks source link

more reliably disable husky for ci/cd environments #195

Closed dlants closed 7 months ago

dlants commented 2 years ago

Description

@newrelic/node-native-metrics is a dependency of one of my projects. When running yarn install --verbose on the project, building node-native-metrics failed with:

> yarn install --verbose

...

16:17:33 make: Leaving directory '/home/ubuntu/.cache/yarn/v6/.tmp/cded8684755c48d23b0d82fdddbfc97a.d0b66af020795b3a6552ea31dd3d07b1ba1471ef.prepare/node_modules/@newrelic/native-metrics/build'
16:17:33 gyp info ok 
16:17:33 install successful: _newrelic_native_metrics-7_1_2-native_metrics-83-linux-x64
16:17:33 success Saved lockfile.
16:17:33 $ husky install
16:17:33 husky - not a Git repository, skipping hooks installation
16:17:33 Build step 'Execute shell' marked build as failure

It seems like yarn tried to run the prepare script, which tried to run husky install. That in turn failed, because it did not find itself in a git repo.

This behavior on husky has been a pain point for many people, and they've tried to fix it a bunch of times, though it seems unreliably:

https://github.com/typicode/husky/issues/851

Their current docs provide several options for how to disable husky in various environments: https://typicode.github.io/husky/#/?id=disable-husky-in-cidockerprod

Expected Behavior

We do not attempt to run husky when installing the package as a dependency.

Your Environment

dlants commented 2 years ago

I should mention, since this repo uses husky v7, I was able to work around this issue by setting:

export HUSKY_SKIP_INSTALL="true"
bizob2828 commented 2 years ago

Thanks @dlants for capturing this issue. It looks like you found a valid workaround for your issue. I will talk to our PM to discuss getting this prioritized

vidhya03 commented 2 years ago

We also faced similar issue. when we are using jhipster framework application.

npm install -g ./gradlew -Pprod -Pwar bootWar --no-daemon -PbuildNumber=$GITHUB_RUN_NUMBER shell: /bin/bash --noprofile --norc -e -o pipefail {0} env: JAVA_HOME_11_x64: /home/actions/actions-runner/_work/_tool/jdk/11.0.15/x64 JAVA_HOME: /home/actions/actions-runner/_work/_tool/jdk/11.0.15/x64 JAVA_HOME_11_X64: /home/actions/actions-runner/_work/_tool/jdk/11.0.15/x64 NEXUS_USERNAME: NEXUS_PASSWORD: npm WARN config global --global, --local are deprecated. Use --location=global instead. npm ERR! code 127 npm ERR! path /home/actions/actions-runner/_work/sci-mycloud/sci-mycloud npm ERR! command failed npm ERR! command sh -c husky install npm ERR! sh: husky: command not found

workato-integration[bot] commented 1 year ago

https://issues.newrelic.com/browse/NR-169171

workato-integration[bot] commented 1 year ago

https://new-relic.atlassian.net/browse/NR-169171

jsumners-nr commented 7 months ago

This should be resolved by #238