Skip to content

ci: improve cache

ci: improve cache #533

Workflow file for this run

name: Test
on:
push:
branches: [develop]
pull_request:
branches: [master, develop, next]
jobs:
test:
name: Test
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
timeout-minutes: 10
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
- name: Setup pnpm
uses: pnpm/action-setup@v2
with:
version: 8
- name: Get pnpm store directory
shell: bash
run: echo "PNPM_STORE=$(pnpm store path --silent)" >> $GITHUB_ENV
- uses: actions/cache@v3
name: Cache pnpm
with:
path: ${{ env.PNPM_STORE }}
key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: ${{ runner.os }}-pnpm-
- name: Install dependencies
run: pnpm install
- name: Get Node.js cache directory
shell: bash
run: echo "NVE_CACHE=$(node -e 'console.log(require("cachedir")("nve"))')" >> $GITHUB_ENV
- name: Cache Node.js versions
uses: actions/cache@v3
with:
path: ${{ env.NVE_CACHE }}
key: ${{ runner.os }}-nodejs-${{ hashFiles('tests/index.ts') }}
restore-keys: ${{ runner.os }}-nodejs-
- name: Test
run: pnpm test
- name: Type check
if: ${{ matrix.os == 'ubuntu-latest' }}
run: pnpm type-check
- name: Lint
if: ${{ matrix.os == 'ubuntu-latest' }}
run: pnpm lint