Skip to content

Commit 96d1173

Browse files
committed
chore(): check storyboard changes in ci
1 parent 08a37b2 commit 96d1173

File tree

2 files changed

+82
-2
lines changed

2 files changed

+82
-2
lines changed

.github/workflows/ci.yml

Lines changed: 81 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ jobs:
4848
key: ${{ runner.os }}-nx-${{ hashFiles('yarn.lock', 'package.json') }}-${{ hashFiles('**/package.json') }}
4949
restore-keys: |
5050
${{ runner.os }}-nx-${{ hashFiles('yarn.lock', 'package.json') }}-
51-
51+
5252
# Fix `yarn install --frozen-lockfile` not working in monorepo.
5353
# https://github.com/yarnpkg/yarn/issues/5840#issuecomment-468782288
5454
- name: Get checksum before yarn install
@@ -88,3 +88,83 @@ jobs:
8888
with:
8989
npm-token: ${{ secrets.NPM_TOKEN }}
9090
if: github.event_name == 'push'
91+
92+
# 📝 检测 storyboard.yaml 变化并生成折叠 diff + 文件统计表
93+
- name: Generate storyboard diff
94+
id: storyboard-diff
95+
run: |
96+
FILES=$(git diff --name-only origin/${GITHUB_BASE_REF} HEAD -- 'apps/**/storyboard.yaml' || true)
97+
FILE_COUNT=$(echo "$FILES" | grep -v '^$' | wc -l)
98+
TOTAL_ADDS=0
99+
TOTAL_DELS=0
100+
101+
echo "<!-- storyboard-diff-check -->" > storyboard_diff.txt
102+
103+
if [ "$FILE_COUNT" -eq "0" ]; then
104+
echo "### 📝 Storyboard Diff (0 files changed, +0/-0 lines)" >> storyboard_diff.txt
105+
echo "" >> storyboard_diff.txt
106+
echo "<details open>" >> storyboard_diff.txt
107+
echo "<summary>No changes detected</summary>" >> storyboard_diff.txt
108+
echo "```diff" >> storyboard_diff.txt
109+
echo "No differences found." >> storyboard_diff.txt
110+
echo "```" >> storyboard_diff.txt
111+
echo "</details>" >> storyboard_diff.txt
112+
echo "::set-output name=diff_exists::false"
113+
exit 0
114+
fi
115+
116+
# 写总统计标题
117+
echo "### 📝 Storyboard Diff (${FILE_COUNT} files changed)" >> storyboard_diff.txt
118+
echo "" >> storyboard_diff.txt
119+
120+
# 文件增删行统计表头
121+
echo "| File | + Added | - Deleted |" >> storyboard_diff.txt
122+
echo "|------|---------|-----------|" >> storyboard_diff.txt
123+
124+
# 遍历文件统计增删行
125+
declare -A FILE_ADDS
126+
declare -A FILE_DELS
127+
128+
for f in $FILES; do
129+
if [ -n "$f" ]; then
130+
ADDS=$(git diff origin/${GITHUB_BASE_REF} HEAD -- $f | grep '^+' | grep -v '^+++' | wc -l)
131+
DELS=$(git diff origin/${GITHUB_BASE_REF} HEAD -- $f | grep '^-' | grep -v '^---' | wc -l)
132+
FILE_ADDS[$f]=$ADDS
133+
FILE_DELS[$f]=$DELS
134+
TOTAL_ADDS=$((TOTAL_ADDS + ADDS))
135+
TOTAL_DELS=$((TOTAL_DELS + DELS))
136+
fi
137+
done
138+
139+
# 输出统计表
140+
for f in "${!FILE_ADDS[@]}"; do
141+
echo "| $f | ${FILE_ADDS[$f]} | ${FILE_DELS[$f]} |" >> storyboard_diff.txt
142+
done
143+
144+
# 输出折叠 diff
145+
for f in $FILES; do
146+
if [ -n "$f" ]; then
147+
echo "" >> storyboard_diff.txt
148+
echo "<details>" >> storyboard_diff.txt
149+
echo "<summary>$f (+${FILE_ADDS[$f]}/-${FILE_DELS[$f]})</summary>" >> storyboard_diff.txt
150+
echo '```diff' >> storyboard_diff.txt
151+
git diff origin/${GITHUB_BASE_REF} HEAD -- $f >> storyboard_diff.txt
152+
echo '```' >> storyboard_diff.txt
153+
echo "</details>" >> storyboard_diff.txt
154+
fi
155+
done
156+
157+
echo "" >> storyboard_diff.txt
158+
echo "Total changes: +${TOTAL_ADDS}/-${TOTAL_DELS}" >> storyboard_diff.txt
159+
echo "::set-output name=diff_exists::true"
160+
161+
- name: Comment PR with storyboard diff
162+
if: github.event_name == 'pull_request'
163+
uses: peter-evans/create-or-update-comment@v4
164+
with:
165+
token: ${{ secrets.GITHUB_TOKEN }}
166+
repository: ${{ github.repository }}
167+
issue-number: ${{ github.event.pull_request.number }}
168+
body-path: storyboard_diff.txt
169+
edit-mode: replace
170+
comment-id: storyboard-diff-check

apps/test/src/Pages/TestObjectProp.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export default function TestObjectProp() {
55
const { serviceNodes } = useContext(LayoutContext);
66

77
return (
8-
<div>
8+
<div className="test-object-prop" style={{ padding: "20px" }}>
99
<eo-table dataSource={{ list: serviceNodes }} />
1010
</div>
1111
);

0 commit comments

Comments
 (0)