Skip to content

Commit 5077535

Browse files
committed
feat(ci): add custom Node.js and pnpm setup action
- Introduced a new GitHub Action for setting up Node.js and pnpm with caching capabilities. - Updated workflows to utilize the new action, changing the Node.js version to 22.x across CI, API client, and release workflows. - Streamlined dependency installation and caching processes for improved build performance. Signed-off-by: Innei <tukon479@gmail.com>
1 parent 423cc7d commit 5077535

File tree

4 files changed

+59
-62
lines changed

4 files changed

+59
-62
lines changed

.github/actions/setup-node/action.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: 'Setup Node.js and pnpm'
2+
description: 'Sets up Node.js and pnpm with caching'
3+
4+
inputs:
5+
node-version:
6+
description: 'Node.js version to use'
7+
required: false
8+
default: '22.x'
9+
10+
runs:
11+
using: 'composite'
12+
steps:
13+
- name: Use Node.js ${{ inputs.node-version }}
14+
uses: actions/setup-node@v4
15+
with:
16+
node-version: ${{ inputs.node-version }}
17+
18+
- name: Setup pnpm
19+
uses: pnpm/action-setup@v4.1.0
20+
with:
21+
run_install: false
22+
23+
- name: Get pnpm store directory
24+
shell: bash
25+
run: |
26+
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
27+
28+
- name: Cache pnpm modules
29+
uses: actions/cache@v4
30+
env:
31+
cache-name: cache-pnpm-modules
32+
with:
33+
path: ${{ env.STORE_PATH }}
34+
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ inputs.node-version }}-${{ hashFiles('**/pnpm-lock.yaml') }}
35+
restore-keys: |
36+
${{ runner.os }}-build-${{ env.cache-name }}-${{ inputs.node-version }}-${{ hashFiles('**/pnpm-lock.yaml') }}
37+
38+
- name: Install Dependencies
39+
shell: bash
40+
run: pnpm i

.github/workflows/api-client.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323

2424
strategy:
2525
matrix:
26-
node-version: [20.x]
26+
node-version: [22.x]
2727

2828
steps:
2929
- uses: actions/checkout@v4

.github/workflows/ci.yml

Lines changed: 17 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ on:
44
- 'v*'
55
paths-ignore:
66
- CHANGELOG.MD
7-
branches: master
7+
branches:
8+
- master
89
pull_request:
910
workflow_dispatch:
1011
name: CI
@@ -54,44 +55,15 @@ jobs:
5455
core:
5556
name: Build (Core)
5657
runs-on: ubuntu-latest
57-
58-
strategy:
59-
matrix:
60-
node-version: [20.x]
61-
6258
steps:
63-
- uses: actions/checkout@v4
64-
- name: Use Node.js ${{ matrix.node-version }}
65-
uses: actions/setup-node@v4
66-
with:
67-
node-version: ${{ matrix.node-version }}
68-
69-
- name: Setup pnpm
70-
uses: pnpm/action-setup@v4.1.0
71-
with:
72-
version:
73-
run_install: false
74-
75-
- name: Get pnpm store directory
76-
shell: bash
77-
run: |
78-
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
79-
80-
- name: Cache pnpm modules
81-
uses: actions/cache@v4
82-
env:
83-
cache-name: cache-pnpm-modules
59+
- name: Checkout
60+
uses: actions/checkout@v4
61+
- name: Setup Node.js and pnpm
62+
uses: ./.github/actions/setup-node
8463
with:
85-
path: ${{ env.STORE_PATH }}
86-
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ matrix.node-version }}-${{ hashFiles('**/pnpm-lock.yaml') }}
87-
restore-keys: |
88-
${{ runner.os }}-build-${{ env.cache-name }}-${{ matrix.node-version }}-${{ hashFiles('**/pnpm-lock.yaml') }}
89-
- name: Install Dependencies
90-
run: |
91-
pnpm i
64+
node-version: '22.x'
9265
- name: Build project
93-
run: |
94-
npm run bundle
66+
run: npm run bundle
9567
- name: Start MongoDB
9668
uses: supercharge/mongodb-github-action@1.12.0
9769
with:
@@ -101,36 +73,22 @@ jobs:
10173
with:
10274
redis-version: 6
10375
- name: Test Bundle Server
104-
run: |
105-
bash scripts/workflow/test-server.sh
76+
run: bash scripts/workflow/test-server.sh
77+
10678
test:
10779
name: Test
10880
timeout-minutes: 10
10981
runs-on: ubuntu-latest
110-
111-
strategy:
112-
matrix:
113-
node-version: [20.x]
114-
11582
steps:
116-
- uses: actions/checkout@v4
117-
- name: Use Node.js ${{ matrix.node-version }}
118-
uses: actions/setup-node@v4
119-
with:
120-
node-version: ${{ matrix.node-version }}
121-
122-
- name: Setup pnpm
123-
uses: pnpm/action-setup@v3
83+
- name: Checkout
84+
uses: actions/checkout@v4
85+
- name: Setup Node.js and pnpm
86+
uses: ./.github/actions/setup-node
12487
with:
125-
run_install: |
126-
- recursive: false
88+
node-version: '22.x'
12789
- name: Run Lint
128-
run: |
129-
npm run lint
130-
90+
run: npm run lint
13191
- name: Run Tests
132-
run: |
133-
npm run test
134-
92+
run: npm run test
13593
env:
13694
CI: true

.github/workflows/release.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
fetch-depth: 0
2020
- uses: actions/setup-node@v4
2121
with:
22-
node-version: 20.x
22+
node-version: 22.x
2323

2424
- name: Start MongoDB
2525
uses: supercharge/mongodb-github-action@1.12.0
@@ -32,7 +32,6 @@ jobs:
3232
- name: Setup pnpm
3333
uses: pnpm/action-setup@v4.1.0
3434
with:
35-
version:
3635
run_install: false
3736

3837
- name: Get pnpm store directory

0 commit comments

Comments
 (0)