feat(ci): expand cache paths to support all Node.js package managers

- Add comprehensive caching for npm, yarn, and pnpm package managers
- Cache paths now include:
  - npm: ~/.npm, node_modules/.cache
  - yarn: ~/.yarn, ~/.cache/yarn, ~/.cache/yarn/global
  - pnpm: ~/.pnpm-store, ~/.cache/pnpm, ~/.local/share/pnpm/global
- Update cache keys to include all lockfile types (package-lock.json, yarn.lock, pnpm-lock.yaml)
- Rename 'Cache Tree-sitter CLI' to 'Cache npx store' for clarity
- Apply changes consistently across test, lint, and coverage jobs

This improves cache hit rates and build performance regardless of which
Node.js package manager is used in the development environment.
This commit is contained in:
2025-09-13 04:52:14 +03:00
parent c5334da82f
commit 3f6411b23f
5 changed files with 75 additions and 26 deletions

View File

@@ -17,6 +17,10 @@ concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false
permissions:
actions: read
contents: read
jobs:
validate:
name: 🔍 Validate Release
@@ -116,8 +120,14 @@ jobs:
- name: Cache Node.js dependencies
uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4
with:
path: ~/.npm
key: ${{ runner.os }}-node-24-${{ hashFiles('**/package-lock.json') }}
path: |
~/.npm
~/.yarn
~/.cache/yarn
~/.pnpm-store
~/.cache/pnpm
node_modules/.cache
key: ${{ runner.os }}-node-24-${{ hashFiles('**/package-lock.json', '**/yarn.lock', '**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-node-24-
${{ runner.os }}-node-
@@ -155,8 +165,14 @@ jobs:
- name: Cache Node.js dependencies
uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4
with:
path: ~/.npm
key: ${{ runner.os }}-node-24-${{ hashFiles('**/package-lock.json') }}
path: |
~/.npm
~/.yarn
~/.cache/yarn
~/.pnpm-store
~/.cache/pnpm
node_modules/.cache
key: ${{ runner.os }}-node-24-${{ hashFiles('**/package-lock.json', '**/yarn.lock', '**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-node-24-
${{ runner.os }}-node-
@@ -164,12 +180,6 @@ jobs:
- name: Install Dependencies
run: npm ci || { echo "❌ npm install failed"; npm install; }
- name: Cache Tree-sitter CLI
uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4
with:
path: ~/.npm/_npx
key: ${{ runner.os }}-tree-sitter-cli-${{ hashFiles('package.json') }}
- name: Cache Generated Grammar
uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4
id: cache-grammar

View File

@@ -7,7 +7,6 @@ on:
branches: [main, master]
pull_request:
branches: [main, master]
merge_group:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
@@ -20,6 +19,11 @@ jobs:
name: 🧪 Test Suite
runs-on: ubuntu-latest
timeout-minutes: 15
permissions:
actions: read
contents: read
issues: write
pull-requests: write
strategy:
matrix:
@@ -39,8 +43,14 @@ jobs:
uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4
id: cache-npm
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ matrix.node-version }}-${{ hashFiles('**/package-lock.json') }}
path: |
~/.npm
~/.yarn
~/.cache/yarn
~/.pnpm-store
~/.cache/pnpm
node_modules/.cache
key: ${{ runner.os }}-node-${{ matrix.node-version }}-${{ hashFiles('**/package-lock.json', '**/yarn.lock', '**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-node-${{ matrix.node-version }}-
${{ runner.os }}-node-
@@ -49,12 +59,15 @@ jobs:
run: npm ci || { echo "❌ npm install failed"; npm install; }
shell: bash
- name: Cache Tree-sitter CLI
- name: Cache npx store
uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4
id: cache-tree-sitter
id: cache-npx
with:
path: ~/.npm/_npx
key: ${{ runner.os }}-tree-sitter-cli-${{ hashFiles('package.json') }}
path: |
~/.npm/_npx
~/.cache/yarn/global
~/.local/share/pnpm/global
key: ${{ runner.os }}-npx-${{ hashFiles('package.json') }}
- name: Cache Generated Grammar
uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4
@@ -76,7 +89,7 @@ jobs:
id: cache-parser
with:
path: |
build/
src/
node_modules/
key: ${{ runner.os }}-parser-${{ matrix.node-version }}-${{ hashFiles('src/parser.c', 'binding.gyp', 'package.json') }}
@@ -138,12 +151,16 @@ jobs:
name: 🧹 Code Quality
runs-on: ubuntu-latest
timeout-minutes: 15
permissions:
contents: read
issues: write
pull-requests: write
steps:
- name: Checkout Repository
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
- name: Setup Node.js 24
- name: Setup Node.js
uses: actions/setup-node@7c12f8017d5436eb855f1ed4399f037a36fbd9e8 # v5.2.1
with:
node-version: 24
@@ -151,8 +168,14 @@ jobs:
- name: Cache Node.js dependencies
uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4
with:
path: ~/.npm
key: ${{ runner.os }}-node-24-${{ hashFiles('**/package-lock.json') }}
path: |
~/.npm
~/.yarn
~/.cache/yarn
~/.pnpm-store
~/.cache/pnpm
node_modules/.cache
key: ${{ runner.os }}-node-24-${{ hashFiles('**/package-lock.json', '**/yarn.lock', '**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-node-24-
${{ runner.os }}-node-
@@ -169,12 +192,17 @@ jobs:
runs-on: ubuntu-latest
timeout-minutes: 15
needs: test
permissions:
actions: read
contents: read
issues: write
pull-requests: write
steps:
- name: Checkout Repository
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
- name: Setup Node.js 24
- name: Setup Node.js
uses: actions/setup-node@7c12f8017d5436eb855f1ed4399f037a36fbd9e8 # v5.2.1
with:
node-version: 24
@@ -182,8 +210,14 @@ jobs:
- name: Cache Node.js dependencies
uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4
with:
path: ~/.npm
key: ${{ runner.os }}-node-24-${{ hashFiles('**/package-lock.json') }}
path: |
~/.npm
~/.yarn
~/.cache/yarn
~/.pnpm-store
~/.cache/pnpm
node_modules/.cache
key: ${{ runner.os }}-node-24-${{ hashFiles('**/package-lock.json', '**/yarn.lock', '**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-node-24-
${{ runner.os }}-node-