Skip to content

Commit

Permalink
Use node_modules cache
Browse files Browse the repository at this point in the history
  • Loading branch information
wendevlin committed Nov 22, 2024
1 parent 9d4a190 commit 1342b82
Showing 1 changed file with 36 additions and 38 deletions.
74 changes: 36 additions & 38 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,43 +19,27 @@ concurrency:
cancel-in-progress: true

jobs:
setup:
name: Setup node and install dependencies
runs-on: ubuntu-latest
steps:
- name: Check out files from GitHub
uses: actions/[email protected]
- name: Setup Node
uses: actions/[email protected]
with:
node-version-file: ".nvmrc"
cache: yarn
- name: Install dependencies
run: yarn install --immutable
- name: Check for duplicate dependencies
run: yarn dedupe --check
- name: Upload node_modules as artifact
uses: actions/upload-artifact@v4
with:
name: node_modules
path: node_modules
lint:
name: Lint and check format
needs: [setup]
runs-on: ubuntu-latest
steps:
- name: Check out files from GitHub
uses: actions/[email protected]
- name: Setup Node
id: setup-node
uses: actions/[email protected]
with:
node-version-file: ".nvmrc"
cache: yarn
- name: Download node_modules artifact
uses: actions/download-artifact@v4
- uses: actions/cache@v4
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
name: node_modules
path: node_modules
path: "node_modules"
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}-${{ steps.setup-node.outputs.node-version }}
restore-keys: ${{ runner.os }}-yarn-${{ steps.setup-node.outputs.node-version }}
- name: Install dependencies
if: steps.yarn-cache.outputs.cache-hit != 'true'
run: yarn install --immutable
- name: Build resources
run: ./node_modules/.bin/gulp gen-icons-json build-translations build-locale-data gather-gallery-pages
- name: Setup lint cache
Expand All @@ -77,21 +61,25 @@ jobs:
run: yarn run lint:prettier
test:
name: Run tests
needs: [setup]
runs-on: ubuntu-latest
steps:
- name: Check out files from GitHub
uses: actions/[email protected]
- name: Setup Node
id: setup-node
uses: actions/[email protected]
with:
node-version-file: ".nvmrc"
cache: yarn
- name: Download node_modules artifact
uses: actions/download-artifact@v4
- uses: actions/cache@v4
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
name: node_modules
path: node_modules
path: "node_modules"
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}-${{ steps.setup-node.outputs.node-version }}
restore-keys: ${{ runner.os }}-yarn-${{ steps.setup-node.outputs.node-version }}
- name: Install dependencies
if: steps.yarn-cache.outputs.cache-hit != 'true'
run: yarn install --immutable
- name: Build resources
run: ./node_modules/.bin/gulp gen-icons-json build-translations build-locale-data
- name: Run Tests
Expand All @@ -104,15 +92,20 @@ jobs:
- name: Check out files from GitHub
uses: actions/[email protected]
- name: Setup Node
id: setup-node
uses: actions/[email protected]
with:
node-version-file: ".nvmrc"
cache: yarn
- name: Download node_modules artifact
uses: actions/download-artifact@v4
- uses: actions/cache@v4
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
name: node_modules
path: node_modules
path: "node_modules"
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}-${{ steps.setup-node.outputs.node-version }}
restore-keys: ${{ runner.os }}-yarn-${{ steps.setup-node.outputs.node-version }}
- name: Install dependencies
if: steps.yarn-cache.outputs.cache-hit != 'true'
run: yarn install --immutable
- name: Build Application
run: ./node_modules/.bin/gulp build-app
env:
Expand All @@ -131,15 +124,20 @@ jobs:
- name: Check out files from GitHub
uses: actions/[email protected]
- name: Setup Node
id: setup-node
uses: actions/[email protected]
with:
node-version-file: ".nvmrc"
cache: yarn
- name: Download node_modules artifact
uses: actions/download-artifact@v4
- uses: actions/cache@v4
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
name: node_modules
path: node_modules
path: "node_modules"
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}-${{ steps.setup-node.outputs.node-version }}
restore-keys: ${{ runner.os }}-yarn-${{ steps.setup-node.outputs.node-version }}
- name: Install dependencies
if: steps.yarn-cache.outputs.cache-hit != 'true'
run: yarn install --immutable
- name: Build Application
run: ./node_modules/.bin/gulp build-hassio
env:
Expand Down

0 comments on commit 1342b82

Please sign in to comment.