Skip to content

Commit

Permalink
NEXT-33446 - enable node_modules caching
Browse files Browse the repository at this point in the history
  • Loading branch information
Haberkamp committed Feb 5, 2024
1 parent c116801 commit 8fee590
Show file tree
Hide file tree
Showing 5 changed files with 97 additions and 76 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/chromatic.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ jobs:
with:
node-version: '20'

# - name: Retrieve the cached main "node_modules" directory (if present)
# uses: actions/cache@v3
# id: node-cache-main
# with:
# path: node_modules
# key: node-modules-main-${{ runner.os }}-${{ hashFiles('package-lock.json') }}
- name: Retrieve the cached main "node_modules" directory (if present)
uses: actions/cache@v3
id: node-cache-main
with:
path: node_modules
key: node-modules-main-${{ runner.os }}-${{ hashFiles('package-lock.json') }}

- name: Install main dependencies (if the cached directory was not found)
# if: steps.node-cache-main.outputs.cache-hit != 'true'
if: steps.node-cache-main.outputs.cache-hit != 'true'
run: npm ci

- name: Publish to Chromatic
Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ jobs:
with:
node-version: '20'

# - name: Retrieve the cached main "node_modules" directory (if present)
# uses: actions/cache@v3
# id: node-cache-main
# with:
# path: node_modules
# key: node-modules-main-${{ runner.os }}-${{ hashFiles('package-lock.json') }}
- name: Retrieve the cached main "node_modules" directory (if present)
uses: actions/cache@v3
id: node-cache-main
with:
path: node_modules
key: node-modules-main-${{ runner.os }}-${{ hashFiles('package-lock.json') }}

- name: Install main dependencies (if the cached directory was not found)
# if: steps.node-cache-main.outputs.cache-hit != 'true'
if: steps.node-cache-main.outputs.cache-hit != 'true'
run: npm ci

- name: Create the static pages directory locally in CI
Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ jobs:
with:
node-version: '20'

# - name: Retrieve the cached "node_modules" directory (if present)
# uses: actions/cache@v3
# id: node-cache
# with:
# path: node_modules
# key: node-modules-${{ runner.os }}-${{ hashFiles('package-lock.json') }}
- name: Retrieve the cached "node_modules" directory (if present)
uses: actions/cache@v3
id: node-cache
with:
path: node_modules
key: node-modules-${{ runner.os }}-${{ hashFiles('package-lock.json') }}

- name: Install dependencies (if the cached directory was not found)
# if: steps.node-cache.outputs.cache-hit != 'true'
if: steps.node-cache.outputs.cache-hit != 'true'
run: npm ci

- name: Build distributed files
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ jobs:
with:
node-version: '20'

# - name: Retrieve the cached main "node_modules" directory (if present)
# uses: actions/cache@v3
# id: node-cache-main
# with:
# path: node_modules
# key: node-modules-main-${{ runner.os }}-${{ hashFiles('package-lock.json') }}
- name: Retrieve the cached main "node_modules" directory (if present)
uses: actions/cache@v3
id: node-cache-main
with:
path: node_modules
key: node-modules-main-${{ runner.os }}-${{ hashFiles('package-lock.json') }}

- name: Install main dependencies (if the cached directory was not found)
# if: steps.node-cache-main.outputs.cache-hit != 'true'
Expand Down
119 changes: 70 additions & 49 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ name: Tests

on:
pull_request:

push:
branches:
- main

workflow_dispatch:

jobs:
Expand All @@ -14,78 +16,97 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
# - name: Retrieve the cached "node_modules" directory (if present)
# uses: actions/cache@v3
# id: node-cache
# with:
# path: node_modules
# key: node-modules-${{ runner.os }}-${{ hashFiles('package-lock.json') }}

- name: Retrieve the cached "node_modules" directory (if present)
uses: actions/cache@v3
id: node-cache
with:
path: node_modules
key: node-modules-${{ runner.os }}-${{ hashFiles('package-lock.json') }}

- name: Install dependencies (if the cached directory was not found)
# if: steps.node-cache.outputs.cache-hit != 'true'
if: steps.node-cache.outputs.cache-hit != 'true'
run: npm ci

- name: Check formatting
run: npm run format:check

- name: Perform typecheck
run: npm run lint:types

- name: Lint code
run: npm run lint:eslint

unit-tests:
name: Unit tests
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
# - name: Retrieve the cached "node_modules" directory (if present)
# uses: actions/cache@v3
# id: node-cache
# with:
# path: node_modules
# key: node-modules-${{ runner.os }}-${{ hashFiles('package-lock.json') }}

- name: Retrieve the cached "node_modules" directory (if present)
uses: actions/cache@v3
id: node-cache
with:
path: node_modules
key: node-modules-${{ runner.os }}-${{ hashFiles('package-lock.json') }}

- name: Install dependencies (if the cached directory was not found)
# if: steps.node-cache.outputs.cache-hit != 'true'
if: steps.node-cache.outputs.cache-hit != 'true'
run: npm ci

- name: unit
run: npm run test:unit
# storybook-tests:
# name: Storybook Tests
# timeout-minutes: 60
# runs-on: ubuntu-latest
# steps:
# - name: Checkout
# uses: actions/checkout@v4
# - name: Setup Node.js
# uses: actions/setup-node@v4
# # - name: Retrieve the cached "node_modules" directory (if present)
# # uses: actions/cache@v3
# # id: node-cache
# # with:
# # path: node_modules
# # key: node-modules-${{ runner.os }}-${{ hashFiles('package-lock.json') }}
# - name: Install dependencies (if the cached directory was not found)
# # if: steps.node-cache.outputs.cache-hit != 'true'
# run: npm ci
# - name: Install Playwright
# run: npx playwright install
# - name: Create the static pages directory locally in CI
# run: npm --prefix ./packages/component-library run build-storybook
# - name: Run Tests
# id: storybookTests
# run: |
# cd ./packages/component-library &&
# npx concurrently --kill-others --success first --names "SB,TEST" --prefix-colors "magenta,blue" \
# "http-server storybook-static -a 127.0.0.1 --port 6006" \
# "wait-on http://127.0.0.1:6006 && npm run test-storybook"
# - name: Archive visual test diffs
# uses: actions/upload-artifact@v3
# if: always()
# with:
# name: visual-test-diffs
# path: ./packages/component-library/__snapshots__

storybook-tests:
name: Storybook Tests
timeout-minutes: 60
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4

- name: Retrieve the cached "node_modules" directory (if present)
uses: actions/cache@v3
id: node-cache
with:
path: node_modules
key: node-modules-${{ runner.os }}-${{ hashFiles('package-lock.json') }}

- name: Install dependencies (if the cached directory was not found)
if: steps.node-cache.outputs.cache-hit != 'true'
run: npm ci

- name: Install Playwright
run: npx playwright install

- name: Create the static pages directory locally in CI
run: npm --prefix ./packages/component-library run build-storybook

- name: Run Tests
id: storybookTests
run: |
cd ./packages/component-library &&
npx concurrently --kill-others --success first --names "SB,TEST" --prefix-colors "magenta,blue" \
"http-server storybook-static -a 127.0.0.1 --port 6006" \
"wait-on http://127.0.0.1:6006 && npm run test-storybook"
- name: Archive visual test diffs
uses: actions/upload-artifact@v3
if: always()
with:
name: visual-test-diffs
path: ./packages/component-library/__snapshots__

0 comments on commit 8fee590

Please sign in to comment.