Skip to content

Commit

Permalink
ci: properly cache results of prisma generate
Browse files Browse the repository at this point in the history
You can't update a cache once it's made, so sharing the Prisma between jobs
is quite annoying. My solution is to use two caches: one for the original
node_modules, another for node_modules + the Prisma client.
  • Loading branch information
tsa96 committed Aug 15, 2023
1 parent 5996c72 commit cf90578
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,23 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/cache@v3
id: cache
- name: Original node_modules Cache
uses: actions/cache@v3
id: original_cache
with:
path: node_modules
key: modules-${{ hashFiles('package-lock.json') }}
- name: node_modules Cache with Prisma Client
uses: actions/cache@v3
with:
path: node_modules
key: modules-${{ github.run_id }}
- uses: actions/setup-node@v3
with:
node-version: 18.x
cache: 'npm'
- name: npm install
if: steps.cache.outputs.cache-hit != 'true'
if: steps.original_cache.outputs.cache-hit != 'true'
run: npm ci --no-scripts
- name: prisma generate
run: npx nx run db:generate
Expand All @@ -36,7 +42,7 @@ jobs:
- uses: actions/cache@v3
with:
path: node_modules
key: modules-${{ hashFiles('package-lock.json') }}
key: modules-${{ github.run_id }}
- name: commitlint
if: github.event_name == 'pull_request'
run: npx commitlint
Expand Down Expand Up @@ -65,7 +71,7 @@ jobs:
uses: actions/cache@v3
with:
path: node_modules
key: modules-${{ hashFiles('package-lock.json') }}
key: modules-${{ github.run_id }}
- name: Test Affected
run: npx nx affected
--target=test
Expand All @@ -86,7 +92,7 @@ jobs:
uses: actions/cache@v3
with:
path: node_modules
key: modules-${{ hashFiles('package-lock.json') }}
key: modules-${{ github.run_id }}
- name: Build Affected
run: npx nx affected
--target=build
Expand All @@ -107,7 +113,7 @@ jobs:
uses: actions/cache@v3
with:
path: node_modules
key: modules-${{ hashFiles('package-lock.json') }}
key: modules-${{ github.run_id }}
- name: Check affected
run:
|
Expand Down Expand Up @@ -141,7 +147,7 @@ jobs:
uses: actions/cache@v3
with:
path: node_modules
key: modules-${{ hashFiles('package-lock.json') }}
key: modules-${{ github.run_id }}
- name: Check affected
run:
|
Expand Down

0 comments on commit cf90578

Please sign in to comment.