All technological notes.
Caching
steps:
- uses: actions/cache@v3
id: cache
with:
path: node_modules
key: $
- name: Install dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: npm ci
- name: Lint & test
run: |
npm run lint
npm run test
name: 13 - caching
on:
workflow_dispatch:
inputs:
use-cache:
type: boolean
default: true
description: Whether to use cache
jobs:
build:
runs-on: ubuntu-latest
defaults:
run:
working-directory: react-app
steps:
- name: Checkout
uses: actions/checkout@v6
- name: setup node
uses: actions/setup-node@v6
with:
node-version: "24.x"
- name: Download dependencies
id: cache-deps
if: $
uses: actions/cache@v5
with:
path: react-app/node_modules
key: deps-node-modules-$
- name: Install dependencies
if: steps.cache-deps.outputs.cache-hit != 'true'
run: npm ci
- name: Testing
run: npm run test
- name: Building
run: npm run build
- name: Deploying
run: echo "Deploying to nonprod"
from 43s -> 26s key log: no Caching
- Post Download dependencies Sent 44832387 of 44832387 (100.0%), 46.8 MBs/sec Cache saved with key: deps-node-modules-4e51da629d104b02c6198499472f35027b1d0783d5450e91e6cc8e30af96d8c2
Caching
- Download dependencies Cache hit for: deps-node-modules-4e51da629d104b02c6198499472f35027b1d0783d5450e91e6cc8e30af96d8c2 Received 44832387 of 44832387 (100.0%), 125.0 MBs/sec Cache Size: ~43 MB (44832387 B) Cache restored successfully Cache restored from key: deps-node-modules-4e51da629d104b02c6198499472f35027b1d0783d5450e91e6cc8e30af96d8c2
- Install dependencies: skiped
name: 13 - caching across jobs
on:
workflow_dispatch:
inputs:
use-cache:
type: boolean
default: true
description: Whether to use cache
jobs:
pre-install:
runs-on: ubuntu-latest
defaults:
run:
working-directory: react-app
outputs:
deps-cache-key: $
steps:
- name: Checkout
uses: actions/checkout@v6
- name: setup node
uses: actions/setup-node@v6
with:
node-version: "24.x"
- name: Generate cache key
id: cache-key
run: |
echo "CACHE_KEY=deps-node-modules-$" >> "$GITHUB_OUTPUT"
- name: Download dependencies
id: cache-deps
if: $
uses: actions/cache@v5
with:
path: react-app/node_modules
key: $
- name: Install dependencies
if: steps.cache-deps.outputs.cache-hit != 'true'
run: npm ci
build:
runs-on: ubuntu-latest
needs: pre-install
defaults:
run:
working-directory: react-app
steps:
- name: Checkout
uses: actions/checkout@v6
- name: setup node
uses: actions/setup-node@v6
with:
node-version: "24.x"
- name: Download dependencies
id: cache-deps
if: $
uses: actions/cache@v5
with:
path: react-app/node_modules
key: $
- name: Install dependencies
if: steps.cache-deps.outputs.cache-hit != 'true'
run: npm ci
- name: Testing
run: npm run test
- name: Building
run: npm run build
- name: Deploying
run: echo "Deploying to nonprod"