@@ -78,15 +78,21 @@ jobs:
78
78
node-version : ${{ matrix.node-version }}
79
79
cache : ' pnpm'
80
80
81
- - name : 获取上一次提交的 SHA
82
- run : echo "PREV_SHA=$(git rev-parse HEAD^)" >> $GITHUB_ENV
81
+ - name : 获取上次提交 SHA
82
+ uses : actions/cache/restore@v4
83
+ with :
84
+ path : previous_sha.txt
85
+ key : ${{ github.ref_name }}-previous_sha
86
+ - name : 读取 SHA 文件
87
+ id : read_previous
88
+ run : echo "previous_sha=$(cat previous_sha.txt)" >> $GITHUB_OUTPUT
83
89
- name : 使用 NX 缓存
84
90
uses : actions/cache/restore@v4
85
91
with :
86
92
path : .nx
87
- key : NX- ${{ runner.os }}-${{ matrix.node-version }}-${{ github.ref_name }}-${{ env.PREV_SHA }}
93
+ key : ${{ github.ref_name }}-NX- ${{ runner.os }}-${{ matrix.node-version }}-${{ steps.read_previous.outputs.previous_sha }}
88
94
restore-keys : |
89
- NX- ${{ runner.os }}-${{ matrix.node-version }}-${{ github.ref_name }}-
95
+ ${{ github.ref_name }}-NX- ${{ runner.os }}-${{ matrix.node-version }}-
90
96
NX-${{ runner.os }}-${{ matrix.node-version }}
91
97
92
98
- name : Prune store
@@ -130,14 +136,14 @@ jobs:
130
136
# 部分测试依赖使用 moduleNameMapper 映射,破坏了 NX 的依赖视图,但若加入 package.json 又会造成循环依赖
131
137
# actions/checkout 需要设置 fetch-depth: 0 获取所有的 commit 历史才能正确计算 affected,非常耗时
132
138
- name : 构建、测试
133
- run : pnpm nx run-many -t prod test:ci --exclude @tarojs/cli @tarojs/ tests --parallel=3 && pnpm --filter=@tarojs/cli prod && pnpm --filter=@tarojs/cli --filter=@tarojs/tests test:ci
139
+ run : pnpm nx run-many -t prod test:ci --exclude @tarojs/tests --parallel=3 && pnpm --filter=@tarojs/tests test:ci
134
140
135
141
- name : 更新 NX 缓存
136
- if : ${{ always() }}
142
+ if : always()
137
143
uses : actions/cache/save@v4
138
144
with :
139
145
path : .nx
140
- key : NX- ${{ runner.os }}-${{ matrix.node-version }}-${{ github.ref_name }}-${{ github.sha }}
146
+ key : ${{ github.ref_name }}-NX- ${{ runner.os }}-${{ matrix.node-version }}-${{ github.sha }}
141
147
142
148
# 以下 coverage 流程通过 artifact 拆分文件作为单独 job 上传时间损耗过长,因此在 node test 后直接继续执行
143
149
- name : Upload [taro-cli] coverage to Codecov
0 commit comments