GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Use CI friendly commands in documentation by jonkoops · Pull Request #326 · actions/setup-node

Conversation

@jonkoops

@jonkoops jonkoops commented Sep 3, 2021 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Replaces npm install with npm ci command and adds the --frozen-lockfile flag for Yarn and PNPM installation commands. This makes installation of packages faster (for NPM) and provides guarantees about lockfile correctness at install time.

Previous efforts for this are documented in #103.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

arabold, btkostner, pi9min, hori-ryota, and Lemmingh reacted with thumbs up emoji
All reactions
  • 👍 5 reactions
@jonkoops jonkoops mentioned this pull request Sep 3, 2021
Suggest npm ci in main readme #103
Closed
@jonkoops jonkoops mentioned this pull request Dec 24, 2021
docs: recommend npm ci #371
Closed
2 tasks
@privatenumber

privatenumber commented Jan 10, 2022

Copy link
Copy Markdown

@dmitry-shibanov Anything blocking this from getting merged?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@pi9min

pi9min commented Mar 11, 2022

Copy link
Copy Markdown

+1

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

hubgit
hubgit reviewed Mar 31, 2022
View reviewed changes
Comment thread docs/advanced-usage.md
cache: 'npm'
cache-dependency-path: '**/package-lock.json'
- run: npm install
- run: npm ci

@hubgit hubgit Mar 31, 2022

Copy link
Copy Markdown

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Does it make sense to use npm ci when the dependencies are being restored from a cache?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@jonkoops jonkoops Mar 31, 2022 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I believe the cache option only caches the global cache, not the node_modules directory. So it still makes sense.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@hubgit hubgit Mar 31, 2022

Copy link
Copy Markdown

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

It does look like it's running npm config get cache to get the path to cache, so that does make sense, thanks 👍

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@jonkoops

jonkoops commented May 3, 2022

Copy link
Copy Markdown
Contributor Author

@dmitry-shibanov @brcrista @marko-zivic-93 is there any interest in getting this merged?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@dmitry-shibanov

dmitry-shibanov commented May 3, 2022

Copy link
Copy Markdown
Contributor

Hello @jonkoops. Thank you for your pull request. I think we can adjust these changes when caching is enabled, because it relies on hash from dependency files. For other cases I think we should leave it as npm install because some repositories do not have package-lock.json.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@jonkoops
jonkoops requested a review from a team May 4, 2022 10:06
@jonkoops

jonkoops commented May 4, 2022

Copy link
Copy Markdown
Contributor Author

For other cases I think we should leave it as npm install because some repositories do not have package-lock.json.

I think differently about this matter, checking in lockfiles is considered best practice for all package managers. Instead of appeasing users that might not have checked this file in we should encourage them to follow these practices.

For example, the NPM documentation says the following about the package-lock.json file:

This file is intended to be committed into source repositories, and serves various purposes:

  • Describe a single representation of a dependency tree such that teammates, deployments, and continuous integration are guaranteed to install exactly the same dependencies.
  • Provide a facility for users to "time-travel" to previous states of node_modules without having to commit the directory itself.
  • Facilitate greater visibility of tree changes through readable source control diffs.
  • Optimize the installation process by allowing npm to skip repeated metadata resolutions for previously-installed packages.
  • As of npm v7, lockfiles include enough information to gain a complete picture of the package tree, reducing the need to read package.json files, and allowing for significant performance improvements.

All of these points apply directly to Github and Github Actions and I believe that these best practices should be reflected here as well.

I propose that all commands are replaced with their appropriate CI friendly versions as per the original purpose of this PR and that the documentation is amended to have a dedicated section to lockfiles.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@jonkoops
Use CI friendly commands in documentation
ba445ba
Replaces `npm install` with `npm ci` command and adds the `--frozen-lockfile` flag for Yarn and PNPM installation commands.
@jonkoops

jonkoops commented May 4, 2022

Copy link
Copy Markdown
Contributor Author

I've added some documentation about lockfiles as mentioned above.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@privatenumber

privatenumber commented May 4, 2022

Copy link
Copy Markdown

For an official action like this, I think it's important to use examples that adopt best practices.

There are many beginners that read these examples that are not aware of the trade-offs between npm install and npm ci.

The problem with using npm install or not using package-lock.json is that there's a chance their CI will unexpectedly fail because of inconsistent dependencies.

For example, a new dependency update that satisfies the package.json semver range can be installed on the CI before the developer tests it locally and fail (or even worse, fail silently and trigger a release).

npm ci was designed for Continuous Integration to prevent these problems.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

dmitry-shibanov
dmitry-shibanov approved these changes May 5, 2022
View reviewed changes
@dmitry-shibanov
dmitry-shibanov merged commit b067f78 into actions:main May 5, 2022
@dmitry-shibanov

dmitry-shibanov commented May 5, 2022

Copy link
Copy Markdown
Contributor

Thank you @jonkoops for improving the documentation and your work.

jonkoops reacted with rocket emoji
All reactions
  • 🚀 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@jonkoops
jonkoops deleted the feature/ci-friendly-commands branch May 8, 2022 22:00
@jonkoops

jonkoops commented May 8, 2022

Copy link
Copy Markdown
Contributor Author

Thanks for taking this into consideration and merging it!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

jablko pushed a commit to jablko/setup-node that referenced this pull request May 10, 2022
@jonkoops @jablko
Use CI friendly commands in documentation (actions#326)
1c58812
@coderabbitai coderabbitai Bot mentioned this pull request Jul 23, 2026
Fix vulnerabilities veraPDF/verapdf-js-viewer#103
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

2 more reviewers
@hubgit hubgit hubgit left review comments
@dmitry-shibanov dmitry-shibanov dmitry-shibanov approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

5 participants

@jonkoops @privatenumber @pi9min @dmitry-shibanov @hubgit
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.