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

build: ignore npm scripts when installing dependencies in dependent analyzer workflow #3013

Merged
merged 2 commits into from
Feb 28, 2024

Conversation

viktorrusakov
Copy link
Contributor

@viktorrusakov viktorrusakov commented Feb 27, 2024

Description

Fixes #3000 which was caused by adding prepare life cycle script to the root package.json file which installs husky. It works fine if you run the script in the root directory but it fails if you run it from somewhere else (e.g. dependent-usage-analyzer directory from which npm ci is run during the workflow which I assume triggers npm run prepare of root package.json because we use workspaces). The reason is that husky is configured to be run from the root directory.

Merge Checklist

  • If your update includes visual changes, have they been reviewed by a designer? Send them a link to the Netlify deploy preview, if applicable.
  • Does your change adhere to the documented style conventions?
  • Do any prop types have missing descriptions in the Props API tables in the documentation site (check deploy preview)?
  • Were your changes tested using all available themes (see theme switcher in the header of the deploy preview, under the "Settings" icon)?
  • Were your changes tested in the example app?
  • Is there adequate test coverage for your changes?
  • Consider whether this change needs to reviewed/QA'ed for accessibility (a11y). If so, please add wittjeff and adamstankiewicz as reviewers on this PR.

Post-merge Checklist

  • Verify your changes were released to NPM at the expected version.
  • If you'd like, share your contribution in #show-and-tell.
  • 🎉 🙌 Celebrate! Thanks for your contribution.

@openedx-webhooks
Copy link

Thanks for the pull request, @viktorrusakov! Please note that it may take us up to several weeks or months to complete a review and merge your PR.

Feel free to add as much of the following information to the ticket as you can:

  • supporting documentation
  • Open edX discussion forum threads
  • timeline information ("this must be merged by XX date", and why that is)
  • partner information ("this is a course on edx.org")
  • any other information that can help Product understand the context for the PR

All technical communication about the code itself will be done via the GitHub pull request interface. As a reminder, our process documentation is here.

Please let us know once your PR is ready for our review and all tests are green.

@openedx-webhooks openedx-webhooks added the open-source-contribution PR author is not from Axim or 2U label Feb 27, 2024
Copy link

netlify bot commented Feb 27, 2024

Deploy Preview for paragon-openedx ready!

Name Link
🔨 Latest commit 48ed494
🔍 Latest deploy log https://app.netlify.com/sites/paragon-openedx/deploys/65de40cda6dad4000871d15d
😎 Deploy Preview https://deploy-preview-3013--paragon-openedx.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@viktorrusakov viktorrusakov linked an issue Feb 27, 2024 that may be closed by this pull request
@@ -227,7 +227,7 @@ jobs:
with:
node-version: ${{ env.NODE_VER }}
- name: Install dependencies
run: npm ci
run: npm ci --ignore-scripts
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will skip running npm prepare which is run during npm ci by default.

Copy link
Member

@adamstankiewicz adamstankiewicz Feb 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The proposed fix here makes sense to me, though I'm wondering if you also considered exploring the recommendation in the husky documentation here:

If installing only dependencies (not devDependencies), the "prepare": "husky" script may fail because Husky won't be installed. Modify the prepare script to never fail:

// package.json
"prepare": "husky || true"

Similar sanity-check type question: the prepare script in package.json includes husky install, which seems to differ a bit from just the husky command from their docs above. I do see we have v8 of husky installed when v9 is latest so maybe this bit is due to the version discrepancy? 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I haven't seen that part in their documentation, let me try that as well. And I didn't notice we are behind the latest version as well 😅 . (Thanks for the quick review!)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I personally would like to see us just completely remove husky. I'm not a fan of git hooks - I find they get in the way when I just want to push something WIP up real quick (I know I can use git push --no-verify but still), and in general they slow down pushes. I also see them as redundant in our case considering the checks we have in CI.

That's definitely a conversation that is out of scope for this PR though, so if husky || true works I say :shipit:

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, it worked, I updated husky to v9 as well (the steps to do that were pretty easy). It does log a small error husky: command not found now whenever you try to install dependencies in dependent-usage-analyzer directory, but I think it should be ok (they have a fix for that as well in docs, but it only works in CI environments, e.g. github actions. And it crashes if you install deps locally, but that's because we use workspaces I think...)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I'm not a big fan of husky as well haha, feels like it causes more trouble than helps us

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Personally, I agree as well! I tend to use --no-verify out of habit in husky enabled repos lol.

Copy link

codecov bot commented Feb 27, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 93.18%. Comparing base (7e4a81f) to head (48ed494).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #3013   +/-   ##
=======================================
  Coverage   93.18%   93.18%           
=======================================
  Files         249      249           
  Lines        4342     4342           
  Branches     1036     1036           
=======================================
  Hits         4046     4046           
  Misses        292      292           
  Partials        4        4           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@viktorrusakov
Copy link
Contributor Author

@adamstankiewicz @brian-smith-tcril can you please review this? It fixes the issue locally for me.

@brian-smith-tcril brian-smith-tcril merged commit 98e6313 into master Feb 28, 2024
10 checks passed
@brian-smith-tcril brian-smith-tcril deleted the rusakov/fix-dependent-analyzer branch February 28, 2024 16:25
@openedx-webhooks
Copy link

@viktorrusakov 🎉 Your pull request was merged! Please take a moment to answer a two question survey so we can improve your experience in the future.

@openedx-semantic-release-bot

🎉 This PR is included in version 22.2.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
open-source-contribution PR author is not from Axim or 2U released
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

[docs] Paragon "Usage Insights" not updated with fresh data
6 participants