toss / nestjs-aop

A way to gracefully apply AOP to nestjs
MIT License
213 stars 24 forks source link

ci: Use cache in ci.yml #4

Closed jongwooo closed 1 year ago

jongwooo commented 1 year ago

Signed-off-by: jongwooo jongwooo.han@gmail.com

Overview

Updated ci.yml to cache dependencies using actions/setup-node. setup-node@v3 or newer has caching built-in.

About caching workflow dependencies

Jobs on GitHub-hosted runners start in a clean virtual environment and must download dependencies each time, causing increased network utilization, longer runtime, and increased cost. To help speed up the time it takes to recreate files like dependencies, GitHub can cache files that frequently use in workflows.

Solutions

Node.js projects can run faster on GitHub Actions by enabling dependency caching on the setup-node action.

AS-IS

- name: Setup node
  uses: actions/setup-node@v2
  with:
    node-version: '16'

- name: Setup pnpm
  uses: pnpm/action-setup@2.2.1
  with:
    version: 7
    run_install: |
      - args: [--frozen-lockfile]

TO-BE

- name: Setup pnpm
  uses: pnpm/action-setup@2.2.4
  with:
    version: 7

- name: Setup node
  uses: actions/setup-node@v3
  with:
    node-version: '16'
    cache: 'pnpm'

 - name: Install dependencies
   run: pnpm install --frozen-lockfile

It’s literally a one line change to pass the cache: 'pnpm' input parameter.

References

PR Checklist

  1. I have read the Contributing Guide
  2. I have written documents and tests, if needed.
WhiteKiwi commented 1 year ago

Thanks for your suggestion!