Skip to content

Commit

Permalink
Refactor(ci): Move Node.js setup and deps installation into separate …
Browse files Browse the repository at this point in the history
…action

  * it also includes a better caching of node_modules
  • Loading branch information
literat committed Sep 19, 2024
1 parent 4ab9f62 commit d57cdae
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 69 deletions.
27 changes: 27 additions & 0 deletions .github/actions/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: 'setup and install'
description: 'Setup Node and Install Dependencies'
runs:
using: 'composite'
steps:
- name: Enable Corepack
shell: bash
run: corepack enable

- name: Set up Node
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
cache: 'yarn'
cache-dependency-path: yarn.lock

- name: Restore cached node_modules
uses: actions/cache@v4
with:
path: '**/node_modules'
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install dependencies
shell: bash
run: yarn --immutable --inline-builds
13 changes: 2 additions & 11 deletions .github/workflows/commitlint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,8 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

- name: Enable Corepack
run: corepack enable

- name: Configure Node
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
cache: 'yarn'

- name: Install dependencies
run: yarn --immutable --inline-builds
- name: Setup Node and Install Dependencies
uses: ./.github/actions/setup-install

- name: Run Commitlint
run: yarn lint:commit
13 changes: 2 additions & 11 deletions .github/workflows/component-analysis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,8 @@ jobs:
# Omlet.dev uses Git History for analysis; Disable shallow clone
fetch-depth: 0

- name: Enable Corepack
run: corepack enable

- name: Configure Node
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
cache: 'yarn'

- name: Install dependencies
run: yarn --immutable --inline-builds
- name: Setup Node and Install Dependencies
uses: ./.github/actions/setup-install

- name: Analyze
run: npx omlet analyze
Expand Down
13 changes: 2 additions & 11 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,8 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Enable Corepack
run: corepack enable

- name: Configure Node
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
cache: 'yarn'

- name: Install dependencies
run: yarn --immutable --inline-builds
- name: Setup Node and Install Dependencies
uses: ./.github/actions/setup-install

# Wait for the Netlify preview URL to be ready
- name: Wait for Netlify Deploy
Expand Down
13 changes: 2 additions & 11 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,8 @@ jobs:
- name: Clone repository
uses: actions/checkout@v4

- name: Enable Corepack
run: corepack enable

- name: Configure Node.js
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
cache: 'yarn'

- name: Install dependencies
run: yarn --immutable --inline-builds
- name: Setup Node and Install Dependencies
uses: ./.github/actions/setup-install

- name: Build
run: yarn build
Expand Down
13 changes: 2 additions & 11 deletions .github/workflows/test-web-twig.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,8 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Enable Corepack
run: corepack enable

- name: Configure Node
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
cache: 'yarn'

- name: Install dependencies
run: yarn --immutable --inline-builds
- name: Setup Node and Install Dependencies
uses: ./.github/actions/setup-install

- name: Build Icons
working-directory: ./packages/icons
Expand Down
16 changes: 2 additions & 14 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,8 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

- name: Enable Corepack
run: corepack enable

- name: Configure Node
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
cache: 'yarn'

- name: Fetch Git history
run: git fetch --no-tags --depth=50 origin main

- name: Install dependencies
run: yarn --immutable --inline-builds
- name: Setup Node and Install Dependencies
uses: ./.github/actions/setup-install

- name: Build
run: yarn build
Expand Down

0 comments on commit d57cdae

Please sign in to comment.