14
14
runs-on : ubuntu-latest
15
15
outputs :
16
16
testComponents : ${{ steps.parseTitle.outputs.testComponents }}
17
+ utilsModified : ${{ steps.check-utils-changes.outputs.modified }}
17
18
steps :
19
+ - uses : actions/checkout@v3
20
+ with :
21
+ fetch-depth : 0
18
22
- name : Parse Title
19
23
id : parseTitle
20
24
uses : actions/github-script@v6
42
46
core.setOutput('tip', warningString)
43
47
core.warning(warningString)
44
48
}
49
+ - name : Check Utils Changes
50
+ id : check-utils-changes
51
+ run : |
52
+ # 从远程仓库获取目标分支的最新代码
53
+ git fetch origin ${{ github.base_ref }}
54
+
55
+ # 获取当前PR分支相对于目标分支的所有变更文件列表
56
+ CHANGED_FILES=$(git diff --name-only origin/${{ github.base_ref }}..HEAD)
57
+
58
+ # 使用grep检查变更文件列表中是否包含utils包的改动
59
+ # ^packages/utils/ 表示以packages/utils/开头的文件路径
60
+ if echo "$CHANGED_FILES" | grep -q "^packages/utils/"; then
61
+ # 如果检测到utils包有改动,设置modified输出变量为true
62
+ echo "modified=true" >> $GITHUB_OUTPUT
63
+ echo "Utils package has been modified, utils tests will be executed"
64
+ else
65
+ # 如果没有检测到utils包的改动,设置modified输出变量为false
66
+ echo "modified=false" >> $GITHUB_OUTPUT
67
+ echo "No changes detected in utils package"
68
+ fi
45
69
- name : generate user-tip.txt
46
70
if : ${{ steps.parseTitle.outputs.tip }}
47
71
run : |
72
96
runs-on : ubuntu-latest
73
97
env :
74
98
TEST_COMPONENTS : ${{ needs.parse-components.outputs.testComponents }}
99
+ UTILS_MODIFIED : ${{ needs.parse-components.outputs.utilsModified }}
75
100
steps :
76
101
- uses : actions/checkout@v3
77
102
- name : Setup pnpm
@@ -97,6 +122,10 @@ jobs:
97
122
- name : Install dependencies
98
123
run : pnpm i --no-frozen-lockfile
99
124
100
- - name : Unit Test
125
+ - name : Unit Test for Components
101
126
if : ${{ env.TEST_COMPONENTS }}
102
127
run : pnpm test:unit3 ${{ env.TEST_COMPONENTS }}
128
+
129
+ - name : Utils Unit Test
130
+ if : ${{ env.UTILS_MODIFIED == 'true' }}
131
+ run : pnpm test:utils
0 commit comments