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

use cache without package-lock #782

Closed
merlinpaypal opened this issue Jun 16, 2023 · 10 comments
Closed

use cache without package-lock #782

merlinpaypal opened this issue Jun 16, 2023 · 10 comments
Assignees
Labels
feature request New feature or request to improve the current logic

Comments

@merlinpaypal
Copy link

Description:
Use cache without package-lock file

Justification:
We don’t want a package lock because we want our CI to run with the latest dependencies. Our repo is a library that gets packaged into an SDK. So if the SDK team updates a dependency we use, then that causes messaging to break.

If we used a package-lock, these issues wouldn't be discovered until late in the release or post-release process

Are you willing to submit a PR?
Possibly, depending on the difficulty and if I get pointed in the right direction. But I'm new to building actions and I know caching/setting up node is not an easy process.

@merlinpaypal merlinpaypal added feature request New feature or request to improve the current logic needs triage labels Jun 16, 2023
@dusan-trickovic
Copy link

Hello, @merlinpaypal ! Thank you for creating this issue, we will investigate it and see what can be done :)

@dusan-trickovic
Copy link

Hello again, @merlinpaypal ! I'm just letting you know about a feature that could possibly be what you might be looking for. Namely, our action has an input called cache-dependency-path which is used to define a clear path to the package-lock (or, in general, some constant file). In caching, such file is necessary, as it plays the role of generating the primary key for the cache. In case having a package-lock isn't an optimal solution for you, maybe you can use that input to point to another file in your repo that never changes?

@merlinpaypal
Copy link
Author

Hi @dusan-trickovic , thanks for letting me know about that. I did try pointing it at package.json but it fails for some reason. Any thoughts on what the issue is?

Run actions/setup-node@v3
  with:
    node-version-file: .nvmrc
    cache: npm
    cache-dependency-path: ./package.json
    always-auth: false
    check-latest: false
    token: ***
Resolved .nvmrc as 16
Found in cache @ /opt/hostedtoolcache/node/16.[2](https://github.com/merlinpaypal/paypal-messaging-components/actions/runs/5292060305/jobs/9578455765#step:3:2)0.0/x6[4](https://github.com/merlinpaypal/paypal-messaging-components/actions/runs/5292060305/jobs/9578455765#step:3:4)
Environment details
  node: v1[6](https://github.com/merlinpaypal/paypal-messaging-components/actions/runs/5292060305/jobs/9578455765#step:3:6).20.0
  npm: [8](https://github.com/merlinpaypal/paypal-messaging-components/actions/runs/5292060305/jobs/9578455765#step:3:8).1[9](https://github.com/merlinpaypal/paypal-messaging-components/actions/runs/5292060305/jobs/9578455765#step:3:10).4
  yarn: 1.22.19
/opt/hostedtoolcache/node/16.20.0/x64/bin/npm config get cache
/home/runner/.npm
npm cache is not found

https://github.com/merlinpaypal/paypal-messaging-components/actions/runs/5292060305/workflow

@dusan-trickovic
Copy link

Hello again @merlinpaypal ! I just wanted to point out a few things regarding your issue:

  • We checked out the workflow file of the run you provided and we noticed that you don't have a step in place that installs the dependencies required by the workflow (or anything from the package.json the repo is using).

  • We're a bit confused by the point you mentioned - about CI running with the latest dependencies. I suppose you could just use npm install in that case, as it installs the most recent version of the dependency from a given range (as opposed to npm ci which would just keep installing whichever ones were included in the original package file). Either way, I think the concern can be eased with that, but if you're seeing any additional problem specific to your organisation's needs, feel free to let us know.

That's all from our side for now. You could try adding npm install as a step in your workflow, as mentioned above, and let us know if that solves your problem. And, of course, let us know if any other occurs and we will investigate it shortly.

Thank you for your time and cooperation :)

@merlinpaypal
Copy link
Author

I added the install step (I think I pointed to the wrong workflow before), but now it fails by not finding eslint and jest. It's like the install step didn't work

@dusan-trickovic
Copy link

Hello again @merlinpaypal ! I have consulted with my team and we decided that we will, unfortunately, have to close this issue, as it doesn't seem like anything can be done from our end. Our action is built with a cache-dependency-path that seems to be working exactly as expected.

However, your runs seem to suggest that the dependencies you installed (mainly eslint and jest) aren't recognized by the runner for one reason or another. Your dependencies could be missing, not getting installed for some reason or they might have been cached and then emptied out when the cache got regenerated at some point.

Although this issue isn't on our side, I suggest enabling logging for your action runs if you can. This can help you catch some issues, if any, with the dependency installation process on the runner.

You could also ensure that all the dependencies are configured properly and that the code runs as expected by starting the project locally and seeing if you detect something in the local logs, as this can likely help you resolve an issue before it even reaches the runner.

Whichever the case may be, this doesn't seem to be related to our Action in particular. For that reason, this issue will be closed, but please don't hesitate to reach out again if you're facing any other issues while using our Actions.

Thank you so much for your patience and contribution :)

@merlinpaypal
Copy link
Author

I've enabled debug logging (both ACTIONS_RUNNER_DEBUG and ACTIONS_STEP_DEBUG.

I have set up 2 runs, one with Node 14, which passes. And one with Node 16, which fails, but I see no obvious errors or problems.

So I think there's some kind of bad interaction between github actions and node 16, so I think this issue should stay open.

@dmitry-shibanov
Copy link
Contributor

Hello @merlinpaypal. I think it is not the issue from the action side because the action works as expected Nodejs can be called without any issue. Could you please disable the cache for Nodejs 14 because I think that some dependencies can be loaded from the cache ?

@merlinpaypal
Copy link
Author

As it turns out, there is an issue with the upgrade from npm 6 to npm 8, which makes the preinstall script run after installing, which is why our runs were failing. Our preinstall command removes node_modules to ensure a clean install, which isn't needed in a CI environment.

npm/cli#2660

Thanks for bearing with me on this.

@adityaraute
Copy link

As mentioned in this comment, https://github.com/orgs/community/discussions/58213#discussioncomment-11461861

I was able to point the workflow to my package.json file and successfully run the action.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature or request to improve the current logic
Projects
None yet
Development

No branches or pull requests

4 participants