Super Fast NPM install on Github Actions

Super Fast NPM install on Github Actions

Caching on GitHub. No side effects allowed. The result: faster workflow. An even faster alternative. Measure all the things. Super fast npm install on Github Actions. A guide to speed up installing Node.js dependencies in a CI environment.

As always, performance tweaking takes experimentation— but we got your back. We did the hard work, and have the numbers to prove it. With our 4-step approach, you can reduce a 16-second task to take only 2 seconds. 2 seconds! If the installation kicked off when you started reading this sentence, it’s done right about… now. As a bonus, you’re doing the world a favour: that’s a 87.5% reduction of energy use. 🌳 ❤️

The baseline

GitHub Actions make it easy to use external official actions like  setup-node in a single line: - uses: actions/[email protected]. Followed by running npm install like the setup-node readme suggests, takes care of Node.js and installing all needed dependencies.

Use a manifestation of the manifest

The biggest win in speed and efficiency is achieved by installing dependencies from the package lock file: package-lock.json. Npm generates this file by default, and by using the command npm ci, only the lock file is used during install. Since it contains a resolved dependency tree, npm can skip a whole lot of steps.

Caching on GitHub

Secondly, caching dependencies saves download time otherwise needed for each package. All cached dependencies are fetched in one go from GitHub, using a  cache action:

- name: Cache dependencies
  uses: actions/[email protected]
  with:
    path: ~/.npm
    key: npm-${{ hashFiles('package-lock.json') }}
    restore-keys: npm-

github

What is Geek Coin

What is GeekCash, Geek Token

Best Visual Studio Code Themes of 2021

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

How to Compare Multiple GitHub Projects with Our GitHub Stats tool

In this article we are going to compare three most popular machine learning projects for you.

Deploying my portfolio website on Github Pages using Github Actions.

Deploying my portfolio website on Github Pages using Github Actions. I recently deployed my portfolio site and wanted to try out github actions and this is my experience of automating the deployment.

Stay Safe on GitHub: Security Practices to Follow

As developers in this deeply interconnected community use open source code to build software, Github security should be a top priority. This is because extensive code re-use increases the risk of distributing vulnerabilities from one dependency or repository to another. As such, every contributor should focus on creating a secure development environment. Here are eight security practices that GitHub users can follow to stay safe and protect their code:

Stay Safe on GitHub: Security Practices to Follow

As developers in this deeply interconnected community use open source code to build software, Github security should be a top priority. This is because extensive code re-use increases the risk of distributing vulnerabilities from one dependency or repository to another. As such, every contributor should focus on creating a secure development environment. Here are eight security practices that GitHub users can follow to stay safe and protect their code:

Stay Safe on GitHub: Security Practices to Follow

As developers in this deeply interconnected community use open source code to build software, Github security should be a top priority. This is because extensive code re-use increases the risk of distributing vulnerabilities from one dependency or repository to another. As such, every contributor should focus on creating a secure development environment. Here are eight security practices that GitHub users can follow to stay safe and protect their code: