Skip to content

Commit

Permalink
ci(github): 👷 commonalize setup node and pnpm
Browse files Browse the repository at this point in the history
  • Loading branch information
syakoo committed Mar 2, 2024
1 parent dd96f12 commit f51af7b
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 81 deletions.
37 changes: 37 additions & 0 deletions .github/actions/setup-node-and-pnpm/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Setup Node.js and Pnpm
description: Setup Node.js and Pnpm Action

runs:
using: composite
steps:
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version-file: ./.node-version

- name: Check Node.js version
shell: bash
run: node --version

- uses: pnpm/action-setup@v3
name: Install pnpm
with:
version: 8
run_install: false

- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- uses: actions/cache@v4
name: Setup pnpm cache
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-node-${{ hashFiles('**/.node-version') }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-node-${{ hashFiles('**/.node-version') }}-pnpm-store-
- name: Install dependencies
shell: bash
run: pnpm install
87 changes: 6 additions & 81 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,32 +11,8 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version-file: ./.node-version

- uses: pnpm/action-setup@v3
name: Install pnpm
with:
version: 8
run_install: false

- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- uses: actions/cache@v4
name: Setup pnpm cache
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-node-${{ hashFiles('**/.node-version') }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-node-${{ hashFiles('**/.node-version') }}-pnpm-store-
- name: Install dependencies
run: pnpm install
- name: Setup Node.js and Pnpm
uses: ./.github/actions/setup-node-and-pnpm

- name: Run Lint
run: pnpm lint
Expand All @@ -48,35 +24,8 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version-file: ./.node-version

- uses: pnpm/action-setup@v3
name: Install pnpm
with:
version: 8
run_install: false

- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- uses: actions/cache@v4
name: Setup pnpm cache
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-node-${{ hashFiles('**/.node-version') }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-node-${{ hashFiles('**/.node-version') }}-pnpm-store-
- name: Install dependencies
run: pnpm install

- name: Collect Workflow Telemetry
uses: catchpoint/workflow-telemetry-action@v2
- name: Setup Node.js and Pnpm
uses: ./.github/actions/setup-node-and-pnpm

- name: Run unit test
run: pnpm test
Expand All @@ -88,32 +37,8 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version-file: ./.node-version

- uses: pnpm/action-setup@v3
name: Install pnpm
with:
version: 8
run_install: false

- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- uses: actions/cache@v4
name: Setup pnpm cache
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-node-${{ hashFiles('**/.node-version') }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-node-${{ hashFiles('**/.node-version') }}-pnpm-store-
- name: Install dependencies
run: pnpm install
- name: Setup Node.js and Pnpm
uses: ./.github/actions/setup-node-and-pnpm

- name: Run Build
run: pnpm build

0 comments on commit f51af7b

Please sign in to comment.