Skip to content

Commit

Permalink
ci: add some workflows (#385)
Browse files Browse the repository at this point in the history
* ci: add some workflows

* fix: fix spelling errors
  • Loading branch information
anlyyao authored Jul 17, 2024
1 parent c699c43 commit d119b97
Show file tree
Hide file tree
Showing 21 changed files with 269 additions and 52 deletions.
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @anlyyao @ZWkang @jarmywang
5 changes: 5 additions & 0 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
blank_issues_enabled: true
contact_links:
- name: 使用 issue-helper 新建
url: https://Tencent.github.io/tdesign/issue-helper/?lang=zh-CN&repo=Tencent/tdesign-mobile-react
about: 使用 https://Tencent.github.io/tdesign/issue-helper/ 创建 issue,其中包含 bug 和 feature,表单提交更加严格。
8 changes: 8 additions & 0 deletions .github/issue-shoot.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
## IssueShoot
- 预估时长: {{ .duration }}
- 期望完成时间: {{ .deadline }}
- 开发难度: {{ .level }}
- 参与人数: 1
- 需求对接人: anlyyao
- 验收标准: 实现期望改造效果,提 PR 并通过验收无误
- 备注: 最终激励以实际提交 `pull request` 并合并为准
50 changes: 50 additions & 0 deletions .github/workflows/issue-label.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: issue on label
on:
issues:
types: ['labeled']
jobs:
add-issueshoot-template:
runs-on: ubuntu-latest
if: contains(fromJSON('["easy", "middle", "hard"]'), github.event.label.name)
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Get token
id: token
run: |
label=${{ github.event.label.name }}
if [[ $label = "easy" ]]
then
echo "level=低" >> $GITHUB_OUTPUT
echo "duration=1" >> $GITHUB_OUTPUT
deadline=$(date -d "+3 days" +'%Y-%m-%d')
echo "deadline=${deadline}" >> $GITHUB_OUTPUT
elif [[ $label = "middle" ]]
then
echo "level=中" >> $GITHUB_OUTPUT
echo "duration=3" >> $GITHUB_OUTPUT
deadline=$(date -d "+7 days" +'%Y-%m-%d')
echo "deadline=${deadline}" >> $GITHUB_OUTPUT
else
echo "level=高" >> $GITHUB_OUTPUT
echo "duration=5" >> $GITHUB_OUTPUT
deadline=$(date -d "+10 days" +'%Y-%m-%d')
echo "deadline=${deadline}" >> $GITHUB_OUTPUT
fi
- name: Create template
id: template
uses: chuhlomin/[email protected]
with:
template: .github/issue-shoot.md
vars: |
level: ${{ steps.token.outputs.level }}
duration: ${{ steps.token.outputs.duration }}
deadline: ${{ steps.token.outputs.deadline }}
- name: Update issue
uses: actions-cool/issues-helper@v3
with:
actions: 'update-issue'
token: ${{ secrets.GITHUB_TOKEN }}
issue-number: ${{ github.event.issue.number }}
body: ${{ steps.template.outputs.result }}
update-mode: 'append'
95 changes: 95 additions & 0 deletions .github/workflows/pr-comment-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
name: PR_COMMENT_CI

on:
issue_comment:
types: [created]

jobs:
check:
runs-on: ubuntu-latest
outputs:
next_action: ${{ steps.get-action.outputs.next_action }}
if: ${{ github.event.issue.pull_request }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 1
- uses: actions/github-script@v7
id: get-action
with:
script: |
const user = context.payload.comment.user.login
core.debug(`user: ${user}`)
const fs = require('fs')
const CODEOWNERS = fs.readFileSync('.github/CODEOWNERS', 'utf8')
core.debug(`CODEOWNERS: ${CODEOWNERS}`)
let isReviewer = false;
CODEOWNERS.match(/@\w+/g).forEach((owner) => {
if (owner === `@${user}`) {
isReviewer = true
}
})
let next_action = ''
if (isReviewer) {
const body = context.payload.comment.body
core.info(`body: ${body}`)
if (body.startsWith('/update-common')) {
next_action='update-common'
}
if (body.startsWith('/update-snapshot')) {
next_action='update-snapshot'
}
} else {
core.warning('You are not collaborator');
}
core.info(`next_action: ${next_action}`)
core.setOutput('next_action', next_action)
update-common:
needs: check
runs-on: ubuntu-latest
if: ${{ needs.check.outputs.next_action == 'update-common' }}
steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.PERSONAL_TOKEN }}
- name: gh checkout pr
env:
GH_TOKEN: ${{ secrets.PERSONAL_TOKEN }}
run: gh pr checkout ${{ github.event.issue.number }} --recurse-submodules
- run: git submodule update --remote --merge
- name: Commit Common
run: |
git add .
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git commit -m "chore: update common"
git push
update-snapshot:
needs: check
runs-on: ubuntu-latest
if: ${{ needs.check.outputs.next_action == 'update-snapshot' }}
steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.PERSONAL_TOKEN }}
- name: gh checkout pr
env:
GH_TOKEN: ${{ secrets.PERSONAL_TOKEN }}
run: gh pr checkout ${{ github.event.issue.number }} --recurse-submodules
- uses: actions/setup-node@v4
with:
node-version: 18
- run: npm install
- run: npm run test:update
- name: Commit Snapshot
run: |
git add .
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git commit -m "chore: update snapshot"
git push
18 changes: 18 additions & 0 deletions .github/workflows/pr-compressed-size.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Compressed Size

on:
pull_request:
types: [opened, synchronize]

jobs:
compressed-size:
runs-on: ubuntu-latest
if: startsWith(github.head_ref, 'release/')
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
- uses: 94dreamer/compressed-size-action@master
with:
repo-token: '${{ secrets.GITHUB_TOKEN }}'
pattern: './dist/**/*.{js,css}'
13 changes: 13 additions & 0 deletions .github/workflows/pr-spelling.template.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: pr-spell-check
on: [pull_request]

jobs:
run:
name: Spell Check with Typos
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Check spelling
uses: crate-ci/typos@master
with:
config: .github/workflows/typos-config.toml
8 changes: 8 additions & 0 deletions .github/workflows/typos-config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
default.check-filename = true

[default.extend-words]
actived = "actived"
colum = "colum"

[files]
extend-exclude = ["CHANGELOG.md", "*.snap"]
49 changes: 35 additions & 14 deletions site/plugin-tdoc/md-to-react.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,14 @@ export default function mdToReact(options) {
return (
<>
${
mdSegment.tdDocHeader ?
`<td-doc-header
mdSegment.tdDocHeader
? `<td-doc-header
slot="doc-header"
ref={tdDocHeader}
spline="${mdSegment.spline}"
platform="mobile"
></td-doc-header>` : ''
></td-doc-header>`
: ''
}
{
isComponent ? (
Expand All @@ -95,15 +96,26 @@ export default function mdToReact(options) {
${mdSegment.demoMd.replace(/class=/g, 'className=')}
<td-doc-phone ref={tdDocPhone}>
<iframe src="${mdSegment.mobileUrl}" frameBorder="0" width="100%" height="100%" style={{ borderRadius: '0 0 6px 6px' }}></iframe>
<iframe src="${
mdSegment.mobileUrl
}" frameBorder="0" width="100%" height="100%" style={{ borderRadius: '0 0 6px 6px' }}></iframe>
</td-doc-phone>
<td-contributors platform="mobile" framework="react" component-name="${mdSegment.componentName}" ></td-contributors>
<td-contributors platform="mobile" framework="react" component-name="${
mdSegment.componentName
}" ></td-contributors>
</div>
<div style={isShow('api')} name="API" dangerouslySetInnerHTML={{ __html: \`${mdSegment.apiMd}\` }}></div>
<div style={isShow('design')} name="DESIGN" dangerouslySetInnerHTML={{ __html: \`${mdSegment.designMd}\` }}></div>
<div style={isShow('api')} name="API" dangerouslySetInnerHTML={{ __html: \`${
mdSegment.apiMd
}\` }}></div>
<div style={isShow('design')} name="DESIGN" dangerouslySetInnerHTML={{ __html: \`${
mdSegment.designMd
}\` }}></div>
</>
) : <div name="DOC" className="${mdSegment.docClass}">${mdSegment.docMd.replace(/class=/g, 'className=')}</div>
) : <div name="DOC" className="${mdSegment.docClass}">${mdSegment.docMd.replace(
/class=/g,
'className=',
)}</div>
}
<div style={{ marginTop: 48 }}>
<td-doc-history time="${mdSegment.lastUpdated}"></td-doc-history>
Expand All @@ -126,7 +138,7 @@ export default function mdToReact(options) {
return { code: result.code, map: result.map };
}

const DEAULT_TABS = [
const DEFAULT_TABS = [
{ tab: 'demo', name: '示例' },
{ tab: 'api', name: 'API' },
{ tab: 'design', name: '指南' },
Expand All @@ -145,7 +157,7 @@ function customRender({ source, file, md }) {
description: '',
isComponent: false,
tdDocHeader: true,
tdDocTabs: DEAULT_TABS,
tdDocTabs: DEFAULT_TABS,
apiFlag: /#+\s*API/i,
docClass: '',
lastUpdated: Math.round(fs.statSync(file).mtimeMs),
Expand All @@ -161,7 +173,7 @@ function customRender({ source, file, md }) {

// fix table | render error
demoMd = demoMd.replace(/`([^`]+)`/g, (str, codeStr) => {
codeStr = codeStr.replace(/"/g, '\'');
codeStr = codeStr.replace(/"/g, "'");
return `<td-code text="${codeStr}"></td-code>`;
});

Expand All @@ -181,10 +193,19 @@ function customRender({ source, file, md }) {
};

if (pageData.isComponent) {
mdSegment.demoMd = md.render.call(md, `${pageData.toc ? '[toc]\n' : ''}${demoMd.replace(/<!--[\s\S]+?-->/g, '')}`).html;
mdSegment.apiMd = md.render.call(md, `${pageData.toc ? '[toc]\n' : ''}${apiMd.replace(/<!--[\s\S]+?-->/g, '')}`).html;
mdSegment.demoMd = md.render.call(
md,
`${pageData.toc ? '[toc]\n' : ''}${demoMd.replace(/<!--[\s\S]+?-->/g, '')}`,
).html;
mdSegment.apiMd = md.render.call(
md,
`${pageData.toc ? '[toc]\n' : ''}${apiMd.replace(/<!--[\s\S]+?-->/g, '')}`,
).html;
} else {
mdSegment.docMd = md.render.call(md, `${pageData.toc ? '[toc]\n' : ''}${content.replace(/<!--[\s\S]+?-->/g, '')}`).html;
mdSegment.docMd = md.render.call(
md,
`${pageData.toc ? '[toc]\n' : ''}${content.replace(/<!--[\s\S]+?-->/g, '')}`,
).html;
}

// 移动端路由地址
Expand Down
4 changes: 2 additions & 2 deletions site/plugin-tdoc/transforms.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ let demoCodesImports = {};

export default {
before({ source, file }) {
const resouceDir = path.dirname(file);
const resourceDir = path.dirname(file);
const reg = file.match(/src\/([\w-]+)\/([\w-]+)\.md/);
const name = reg && reg[1];
demoCodesImports = {};
Expand All @@ -26,7 +26,7 @@ export default {

// 替换成对应 demo 文件
source = source.replace(/\{\{\s+(.+)\s+\}\}/g, (demoStr, demoFileName) => {
const demoPath = path.resolve(resouceDir, `./_example/${demoFileName}.jsx`);
const demoPath = path.resolve(resourceDir, `./_example/${demoFileName}.jsx`);
if (!fs.existsSync(demoPath)) {
console.log('\x1B[36m%s\x1B[0m', `${name} 组件需要实现 _example/${demoFileName}.jsx 示例!`);
return '\n<h3>DEMO (🚧建设中)...</h3>';
Expand Down
24 changes: 12 additions & 12 deletions site/style/vars.less
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
@primary-color-darken-3: darken(@primary-color, (43 - 19) * 1%);
@primary-color-darken-4: darken(@primary-color, (43 - 11) * 1%);

@primary-color-ligher-1: lighten(@primary-color, (51 - 43) * 1%);
@primary-color-ligher-2: lighten(@primary-color, (59 - 43) * 1%);
@primary-color-ligher-3: lighten(@primary-color, (67 - 43) * 1%);
@primary-color-ligher-4: lighten(@primary-color, (75 - 43) * 1%);
@primary-color-ligher-5: lighten(@primary-color, (83 - 43) * 1%);
@primary-color-ligher-6: lighten(@primary-color, (91 - 43) * 1%);
@primary-color-ligher-7: lighten(@primary-color, (96 - 43) * 1%);
// @primary-color-ligher-6: hsl(217, 100, 91);
@primary-color-lighter-1: lighten(@primary-color, (51 - 43) * 1%);
@primary-color-lighter-2: lighten(@primary-color, (59 - 43) * 1%);
@primary-color-lighter-3: lighten(@primary-color, (67 - 43) * 1%);
@primary-color-lighter-4: lighten(@primary-color, (75 - 43) * 1%);
@primary-color-lighter-5: lighten(@primary-color, (83 - 43) * 1%);
@primary-color-lighter-6: lighten(@primary-color, (91 - 43) * 1%);
@primary-color-lighter-7: lighten(@primary-color, (96 - 43) * 1%);
// @primary-color-lighter-6: hsl(217, 100, 91);

// 状态色
@success-color: #3ecc36;
Expand All @@ -39,10 +39,11 @@

@font-size-base: 14px;
@line-height-base: 1.5;
@font-family: "PingFang SC", -apple-system, "Helvetica Neue", Helvetica, BlinkMacSystemFont, "Microsoft YaHei", tahoma, Arial, "Open Sans", "Hiragino Sans GB", "Heiti SC", "WenQuanYi Micro Hei", sans-serif;
@font-family: 'PingFang SC', -apple-system, 'Helvetica Neue', Helvetica, BlinkMacSystemFont, 'Microsoft YaHei', tahoma,
Arial, 'Open Sans', 'Hiragino Sans GB', 'Heiti SC', 'WenQuanYi Micro Hei', sans-serif;

/**
* 文字部分
* 文字部分
* size 大小,line 行高, color 颜色
*/
// 字体大小
Expand Down Expand Up @@ -99,7 +100,6 @@
@shadow-level-1: 3px 3px 8px 2px rgba(0, 0, 0, 0.06);
@shadow-level-2: 6px 6px 12px 6px rgba(0, 0, 0, 0.08);


// border
@border-color: #d9d9d9;
@border-main: 1px solid @border-color;
Expand All @@ -118,7 +118,7 @@
// layout
@layoutMargin: 10px;

// header
// header
@headerHeight: 81px;

// footer
Expand Down
Loading

0 comments on commit d119b97

Please sign in to comment.