Skip to content

Commit

Permalink
Caching NPM deps
Browse files Browse the repository at this point in the history
  • Loading branch information
pH-7 committed May 18, 2024
1 parent 23ccda4 commit 125eb2d
Showing 1 changed file with 33 additions and 20 deletions.
53 changes: 33 additions & 20 deletions .github/workflows/ci-test.yml
Original file line number Diff line number Diff line change
@@ -1,30 +1,43 @@
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs

name: Tests

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
on: [push, pull_request]

jobs:
build:

runs-on: ubuntu-latest
run:
runs-on: ${{ matrix.operating-system }}

strategy:
matrix:
operating-system: ['ubuntu-latest']
node-version: [14.x, 16.x, 18.x, 20.x]

name: Node ${{ matrix.node-version }} on ${{ matrix.operating-system }}

steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- run: npm ci
- run: npm run build --if-present
- run: npm test
- name: Checkout
uses: actions/checkout@v3

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}

- name: Check Node.js Version
run: node -v

- name: Check npm Version
run: npm -v

- name: Cache npm dependencies
uses: actions/cache@v3
with:
path: ~/.npm
key: ${{ runner.OS }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.OS }}-node-
- name: Install dependencies
run: npm ci

- name: Run tests
run: npm test

0 comments on commit 125eb2d

Please sign in to comment.