Try to improve caching

This commit is contained in:
Jordan Eldredge 2025-07-05 17:34:11 -07:00
parent 81a3dd2897
commit 63d0abdca9

View file

@ -11,28 +11,9 @@ on:
- 'LICENSE.txt'
jobs:
# Fast job to install dependencies and cache them for other jobs
setup:
runs-on: ubuntu-latest
outputs:
cache-key: ${{ steps.cache-key.outputs.key }}
steps:
- uses: actions/checkout@v4
- name: Generate cache key
id: cache-key
run: echo "key=node-modules-${{ hashFiles('**/yarn.lock') }}" >> $GITHUB_OUTPUT
- name: Use Node.js 20.x
uses: actions/setup-node@v4
with:
node-version: 20.x
cache: 'yarn'
- name: Install Dependencies
run: yarn install --frozen-lockfile
# Build job - runs in parallel with lint and test jobs
# Build job - includes dependency installation and builds everything
build:
runs-on: ubuntu-latest
needs: setup
steps:
- uses: actions/checkout@v4
- name: Use Node.js 20.x
@ -57,12 +38,13 @@ jobs:
path: |
packages/*/built
packages/*/dist
key: build-artifacts-${{ github.sha }}
node_modules
key: build-cache-${{ github.sha }}-${{ hashFiles('**/yarn.lock') }}
# Lint job - runs in parallel
# Lint job - reuses dependencies from build job
lint:
runs-on: ubuntu-latest
needs: setup
needs: build
steps:
- uses: actions/checkout@v4
- name: Use Node.js 20.x
@ -70,17 +52,24 @@ jobs:
with:
node-version: 20.x
cache: 'yarn'
- name: Install Dependencies
run: yarn install --frozen-lockfile
- name: Restore dependencies and build cache
uses: actions/cache@v4
with:
path: |
packages/*/built
packages/*/dist
node_modules
key: build-cache-${{ github.sha }}-${{ hashFiles('**/yarn.lock') }}
fail-on-cache-miss: true
- name: Lint
run: |
yarn lint
yarn workspace webamp type-check
# Test job - runs in parallel
# Test job - reuses dependencies from build job
test:
runs-on: ubuntu-latest
needs: setup
needs: build
steps:
- uses: actions/checkout@v4
- name: Use Node.js 20.x
@ -88,8 +77,15 @@ jobs:
with:
node-version: 20.x
cache: 'yarn'
- name: Install Dependencies
run: yarn install --frozen-lockfile
- name: Restore dependencies and build cache
uses: actions/cache@v4
with:
path: |
packages/*/built
packages/*/dist
node_modules
key: build-cache-${{ github.sha }}-${{ hashFiles('**/yarn.lock') }}
fail-on-cache-miss: true
- name: Run Unit Tests
run: |
touch packages/skin-database/config.js
@ -131,15 +127,14 @@ jobs:
node-version: 20.x
registry-url: https://registry.npmjs.org/
cache: 'yarn'
- name: Install dependencies
run: yarn install --frozen-lockfile
- name: Restore build artifacts
- name: Restore dependencies and build cache
uses: actions/cache@v4
with:
path: |
packages/*/built
packages/*/dist
key: build-artifacts-${{ github.sha }}
node_modules
key: build-cache-${{ github.sha }}-${{ hashFiles('**/yarn.lock') }}
fail-on-cache-miss: true
- name: Set version
if: github.ref == 'refs/heads/master'