@ng-easy/npm-setup
Opinionated zero-config GitHub Action to automate the installation of npm dependencies for Angular projects and Nx workspaces.
It is heavily inspired of npm-install
GitHub action, and it might be used for other Node projects as well, as long as these requirements are met:
- Use
npm
as dependency manager, others not supported - Have a
package-lock.json
and runnpm ci
for installation - Just use a root
node_modules
The approach taken for caching is:
- Try to restore
node_modules
if there is an exact match forpackage-lock.json
- If not, restore
~/.npm
based onpackage-lock.json
andpackage.json
, and use rolling cache to avoid cache snowball - Detects if Cypress is a dependency, if so caches its installation
- Detects if Angular is a dependency, if so caches its build artifacts
- Caches Nx local execution cache instead of relying on Nx Cloud if an input is provided, using rolling cache as well
Usage
name: main
on: [push]
jobs:
build-and-test:
runs-on: ubuntu-latest
name: Build and test
steps:
- uses: actions/checkout@v2
- uses: ng-easy/npm-install@v2
- run: npm run build
If you want to cache Nx local execution cache then pass nx-key
input:
- uses: ng-easy/npm-install@v2
with:
nx-key: build # or any other key you want to use for the cache that uniquely identifies the job in the workflow