Skip to content

Commit bb535b4

Browse files
HaixingOoOliweijie0812HeisingCopilotuyarn
authored
chore: add pnpm workspace and pnpm manage limit (#3404)
* chore(Package): add pnpm workspace and pnpm manage limit * chore: move site into packages/tdesign-react * chore(package.json): adjust pnpm cmd * ci(pr): use pnpm * chore: fix build * chore: render docs site * chore: reset vscode setting * chore: adjust package lint-staged cmd * chore: adjust demos display * chore: adjust code * Update packages/components/hooks/useDebounce.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * chore: adjust doc path * chore: format json file * chore: rm useless log * chroe: add packageManager * chore: fix build * fix: build site * chore: update gitignore * chore: revert change * chore: revert change * chore: remove devDependencies from packages/tdesign-react * chore: correct bundle path * chore: update contributing * chore: update contributing --------- Co-authored-by: 黎伟杰 <674416404@qq.com> Co-authored-by: Heising <heising@travelconnect.cn> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: Uyarn <uyarnchen@gmail.com>
1 parent 7a18622 commit bb535b4

117 files changed

Lines changed: 1420 additions & 938 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/preview-publish.yml

Lines changed: 79 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,82 @@ on:
99
- completed
1010

1111
jobs:
12-
call-preview:
13-
uses: Tencent/tdesign/.github/workflows/preview.yml@main
14-
secrets:
15-
TDESIGN_SURGE_TOKEN: ${{ secrets.TDESIGN_SURGE_TOKEN }}
12+
preview-success:
13+
runs-on: ubuntu-latest
14+
if: >
15+
github.event.workflow_run.event == 'pull_request' &&
16+
github.event.workflow_run.conclusion == 'success'
17+
steps:
18+
- name: download pr artifact
19+
uses: dawidd6/action-download-artifact@v6
20+
with:
21+
workflow: ${{ github.event.workflow_run.workflow_id }}
22+
run_id: ${{ github.event.workflow_run.id }}
23+
name: pr
24+
- name: save PR id
25+
id: pr
26+
run: echo "id=$(<pr-id.txt)" >> $GITHUB_OUTPUT
27+
- name: download site artifact
28+
uses: dawidd6/action-download-artifact@v6
29+
with:
30+
workflow: ${{ github.event.workflow_run.workflow_id }}
31+
run_id: ${{ github.event.workflow_run.id }}
32+
name: site
33+
- run: |
34+
unzip site.zip
35+
36+
- name: Upload surge service and generate preview URL
37+
id: deploy
38+
run: |
39+
repository=${{github.repository}}
40+
project_name=${repository#*/}
41+
export DEPLOY_DOMAIN=https://preview-pr-${{ steps.pr.outputs.id }}-$project_name.surge.sh
42+
npx surge --project ./packages/tdesign-react/site/dist --domain $DEPLOY_DOMAIN --token ${{ secrets.TDESIGN_SURGE_TOKEN }}
43+
echo the preview URL is $DEPLOY_DOMAIN
44+
echo "url=$DEPLOY_DOMAIN" >> $GITHUB_OUTPUT
45+
- name: update status comment
46+
uses: actions-cool/maintain-one-comment@v3
47+
with:
48+
token: ${{ secrets.GITHUB_TOKEN }}
49+
body: |
50+
<a href="${{steps.deploy.outputs.url}}"><img height="96" alt="完成" src="https://user-images.githubusercontent.com/15634204/150816437-9f5bb788-cd67-4cbc-9897-b82d74e9aa65.png" /></a>
51+
<!-- [工作流地址](${{github.server_url}}/${{github.repository}}/actions/runs/${{github.run_id}}) -->
52+
<!-- AUTO_PREVIEW_HOOK -->
53+
number: ${{ steps.pr.outputs.id }}
54+
body-include: "<!-- AUTO_PREVIEW_HOOK -->"
55+
56+
- name: The job failed
57+
if: ${{ failure() }}
58+
uses: actions-cool/maintain-one-comment@v3
59+
with:
60+
token: ${{ secrets.GITHUB_TOKEN }}
61+
body: |
62+
[<img height="96" alt="失败" src="https://user-images.githubusercontent.com/5378891/75333447-1e63a280-58c1-11ea-975d-235367fd1522.png">](${{github.server_url}}/${{github.repository}}/actions/runs/${{github.run_id}})
63+
<!-- AUTO_PREVIEW_HOOK -->
64+
number: ${{ steps.pr.outputs.id }}
65+
body-include: "<!-- AUTO_PREVIEW_HOOK -->"
66+
67+
preview-failed:
68+
runs-on: ubuntu-latest
69+
if: >
70+
github.event.workflow_run.event == 'pull_request' &&
71+
github.event.workflow_run.conclusion == 'failure'
72+
steps:
73+
- name: download pr artifact
74+
uses: dawidd6/action-download-artifact@v6
75+
with:
76+
workflow: ${{ github.event.workflow_run.workflow_id }}
77+
run_id: ${{ github.event.workflow_run.id }}
78+
name: pr
79+
- name: save PR id
80+
id: pr
81+
run: echo "id=$(<pr-id.txt)" >> $GITHUB_OUTPUT
82+
- name: The job failed
83+
uses: actions-cool/maintain-one-comment@v3
84+
with:
85+
token: ${{ secrets.GITHUB_TOKEN }}
86+
body: |
87+
[<img height="96" alt="失败" src="https://user-images.githubusercontent.com/5378891/75333447-1e63a280-58c1-11ea-975d-235367fd1522.png">](${{github.server_url}}/${{github.repository}}/actions/runs/${{github.run_id}})
88+
<!-- AUTO_PREVIEW_HOOK -->
89+
number: ${{ steps.pr.outputs.id }}
90+
body-include: "<!-- AUTO_PREVIEW_HOOK -->"

.github/workflows/pull-request.yml

Lines changed: 158 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# 文件名建议统一为 pull-request.yml
1+
# 文件名建议统一为 pull-request.yml
22
# 应用 test-build.yml 的 demo
33

44
name: MAIN_PULL_REQUEST
@@ -9,5 +9,160 @@ on:
99
types: [opened, synchronize, reopened]
1010

1111
jobs:
12-
call-test-build:
13-
uses: Tencent/tdesign/.github/workflows/test-build.yml@main
12+
check:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v4
16+
- name: check_github_primary_email
17+
run: |
18+
log_emails=$(git log --pretty=format:"%ae %ce" -1)
19+
if [[ ${log_emails} =~ 'tdesign@tencent.com' ]];then
20+
echo "$log_emails 跳过验证"
21+
exit 0
22+
fi
23+
if [[ ${log_emails} =~ '@tencent.com' ]];then
24+
echo "默认邮箱 $log_emails 校验非法,可以去 https://github.com/settings/emails 更改"
25+
exit 2;
26+
else
27+
echo "邮箱 $log_emails 校验通过";
28+
fi
29+
- uses: actions/checkout@v4
30+
with:
31+
ref: ${{ github.event.pull_request.head.sha }}
32+
- name: check_local_email
33+
run: |
34+
log_emails=$(git log --pretty=format:"%ae %ce" -1)
35+
if [[ ${log_emails} =~ 'tdesign@tencent.com' ]];then
36+
echo "$log_emails 跳过验证"
37+
exit 0
38+
fi
39+
if [[ ${log_emails} =~ '@tencent.com' ]];then
40+
echo "本地提交邮箱 $log_emails 校验非法,需要本地更改重新提交"
41+
exit 2;
42+
else
43+
echo "邮箱 $log_emails 校验通过";
44+
fi
45+
46+
test:
47+
# needs: check
48+
runs-on: ubuntu-latest
49+
steps:
50+
- uses: actions/checkout@v4
51+
with:
52+
submodules: recursive
53+
- uses: pnpm/action-setup@v4
54+
55+
- uses: actions/setup-node@v4
56+
with:
57+
node-version-file: .node-version
58+
59+
- name: Get pnpm store directory
60+
id: pnpm-cache
61+
run: |
62+
echo "pnpm_cache_dir=$(pnpm store path)" >> $GITHUB_OUTPUT
63+
64+
- uses: actions/cache@v4
65+
with:
66+
# 缓存路径
67+
path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }}
68+
# 缓存键
69+
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
70+
# 恢复缓存的备用键
71+
restore-keys: |
72+
${{ runner.os }}-pnpm-store-
73+
74+
- run: pnpm install
75+
- run: pnpm run lint
76+
- run: pnpm run test
77+
# upload report to codecov
78+
- uses: codecov/codecov-action@v2
79+
with:
80+
token: ${{ secrets.CODECOV_TOKEN }}
81+
82+
site:
83+
runs-on: ubuntu-latest
84+
# needs: test
85+
steps:
86+
- uses: actions/checkout@v4
87+
with:
88+
submodules: recursive
89+
90+
- uses: pnpm/action-setup@v4
91+
92+
- uses: actions/setup-node@v4
93+
with:
94+
node-version-file: .node-version
95+
96+
- name: Get pnpm store directory
97+
id: pnpm-cache
98+
run: |
99+
echo "pnpm_cache_dir=$(pnpm store path)" >> $GITHUB_OUTPUT
100+
101+
- uses: actions/cache@v4
102+
with:
103+
# 缓存路径
104+
path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }}
105+
# 缓存键
106+
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
107+
# 恢复缓存的备用键
108+
restore-keys: |
109+
${{ runner.os }}-pnpm-store-
110+
111+
- run: pnpm install
112+
113+
- name: Build site
114+
run: pnpm site:preview
115+
116+
- run: |
117+
zip -r site.zip packages/tdesign-react/site/dist
118+
119+
- name: upload site artifact
120+
uses: actions/upload-artifact@v4
121+
with:
122+
name: site
123+
path: site.zip
124+
retention-days: 5
125+
126+
- name: Save PR number
127+
if: ${{ always() }}
128+
run: echo ${{ github.event.number }} > ./pr-id.txt
129+
130+
- name: Upload PR number
131+
if: ${{ always() }}
132+
uses: actions/upload-artifact@v4
133+
with:
134+
name: pr
135+
path: ./pr-id.txt
136+
137+
build:
138+
runs-on: ubuntu-latest
139+
# needs: build
140+
steps:
141+
- uses: actions/checkout@v4
142+
with:
143+
submodules: recursive
144+
145+
- uses: pnpm/action-setup@v4
146+
147+
- uses: actions/setup-node@v4
148+
with:
149+
node-version-file: .node-version
150+
- name: Get pnpm store directory
151+
id: pnpm-cache
152+
run: |
153+
echo "pnpm_cache_dir=$(pnpm store path)" >> $GITHUB_OUTPUT
154+
155+
- uses: actions/cache@v4
156+
with:
157+
# 缓存路径
158+
path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }}
159+
# 缓存键
160+
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
161+
# 恢复缓存的备用键
162+
restore-keys: |
163+
${{ runner.os }}-pnpm-store-
164+
165+
- run: pnpm install
166+
167+
- name: Build
168+
run: pnpm run build

.gitignore

Lines changed: 32 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,42 @@
1-
node_modules
1+
22
.DS_Store
3+
.idea
4+
temp*
5+
robotMsg.json
6+
.history
7+
8+
## node modules
9+
node_modules
10+
11+
# bundle files
12+
es/
13+
esm/
14+
cjs/
15+
lib/
16+
dist/
17+
18+
19+
## test files
320
coverage
21+
cypress-coverage
22+
cy-report
423
test/scripts/cypress/screenshots
524
test/scripts/cypress/videos
625
test/scripts/cypress/results
726
test/scripts/cypress/support
827
results/
28+
29+
## site files
930
site/dist
10-
.idea
11-
es
12-
lib
13-
dist
14-
yarn.lock
15-
esm
16-
cjs
17-
robotMsg
18-
.gitlogmap
19-
_site/
31+
_static_site
32+
packages/components/**/_example-js/
33+
34+
35+
## lock files
2036
package-lock.json
37+
yarn.lock
2138
pnpm-lock.yaml
22-
temp*
23-
robotMsg.json
24-
.nyc_output
25-
cypress-coverage
26-
instrumented
27-
cy-report
28-
.history
29-
packages/components/**/_example-js/
39+
40+
41+
42+

.node-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
18

.npmrc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# 提升依赖项到根目录,以避免重复安装相同的包
2+
shamefully-hoist=true

.nvmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
v18

.vscode/settings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,4 +75,4 @@
7575
"tsconfig.json": "tsconfig.*.json",
7676
"vitest.config.ts": "babel.config.js, postcss.config.js"
7777
},
78-
}
78+
}

0 commit comments

Comments
 (0)