Skip to content

Commit de9756b

Browse files
committed
fix(workflow): add new setup action and fix unit-test.yml workflow
1 parent d441f9a commit de9756b

File tree

2 files changed

+47
-11
lines changed

2 files changed

+47
-11
lines changed

.github/actions/setup/action.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
---
2+
name: Setup
3+
description: Setup the environment for the project
4+
5+
inputs:
6+
node-version:
7+
description: Node.js version
8+
default: '24'
9+
required: false
10+
node-registry:
11+
description: Node.js package registry to set up for auth
12+
required: false
13+
14+
runs:
15+
using: composite
16+
steps:
17+
- name: Install Node.js
18+
uses: actions/setup-node@v5
19+
with:
20+
node-version: ${{ inputs.node-version }}
21+
registry-url: ${{ inputs.node-registry }}
22+
23+
- name: Install pnpm
24+
uses: pnpm/action-setup@v4
25+
26+
- name: Get pnpm store directory
27+
id: pnpm-cache-dir
28+
shell: bash
29+
run: echo "dir=$(pnpm store path)" >> $GITHUB_OUTPUT
30+
31+
- name: Setup pnpm cache
32+
uses: actions/cache@v4
33+
with:
34+
path: ${{ steps.pnpm-cache-dir.outputs.dir }}
35+
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
36+
restore-keys: |
37+
${{ runner.os }}-pnpm-store-
38+
39+
- name: Install dependencies
40+
shell: bash
41+
run: pnpm install --prefer-frozen-lockfile

.github/workflows/unit-test.yml

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,24 @@
1+
---
12
name: Unit Test
23

34
on:
45
push:
56
branches: [main]
67
pull_request:
78
branches: [main]
9+
workflow_dispatch:
810

911
jobs:
1012
test:
1113
runs-on: ubuntu-latest
1214
steps:
1315
- name: Checkout
14-
uses: actions/checkout@v4
16+
uses: actions/checkout@v5
1517

16-
- name: Install pnpm
17-
uses: pnpm/[email protected]
18-
19-
- name: Set node LTS
20-
uses: actions/setup-node@v4
18+
- name: Setup
19+
uses: ./.github/actions/setup
2120
with:
22-
node-version: lts/*
23-
cache: pnpm
24-
25-
- name: Install
26-
run: pnpm install
21+
node-registry: https://registry.npmjs.org
2722

2823
- name: Build
2924
run: pnpm run build

0 commit comments

Comments
 (0)