Skip to content

Commit 471c86b

Browse files
authored
test: use unified github action yml (#868)
1 parent edb2ab7 commit 471c86b

File tree

8 files changed

+28
-767
lines changed

8 files changed

+28
-767
lines changed

.github/workflows/main.yml

+5-114
Original file line numberDiff line numberDiff line change
@@ -1,115 +1,6 @@
1-
name: CI
2-
3-
on: ['push', 'pull_request']
4-
1+
name: ✅ test
2+
on: [push, pull_request]
53
jobs:
6-
setup:
7-
runs-on: ubuntu-latest
8-
steps:
9-
- name: checkout
10-
uses: actions/checkout@v4
11-
12-
- uses: actions/setup-node@v4
13-
with:
14-
node-version: '20'
15-
16-
- name: cache package-lock.json
17-
uses: actions/cache@v4
18-
with:
19-
path: package-temp-dir
20-
key: lock-${{ github.sha }}
21-
22-
- name: create package-lock.json
23-
run: npm i --package-lock-only --ignore-scripts
24-
25-
- name: hack for singe file
26-
run: |
27-
if [ ! -d "package-temp-dir" ]; then
28-
mkdir package-temp-dir
29-
fi
30-
cp package-lock.json package-temp-dir
31-
32-
- name: cache node_modules
33-
id: node_modules_cache_id
34-
uses: actions/cache@v4
35-
with:
36-
path: node_modules
37-
key: node_modules-${{ hashFiles('**/package-temp-dir/package-lock.json') }}
38-
39-
- name: install
40-
if: steps.node_modules_cache_id.outputs.cache-hit != 'true'
41-
run: npm ci
42-
43-
lint:
44-
runs-on: ubuntu-latest
45-
steps:
46-
- name: checkout
47-
uses: actions/checkout@v4
48-
49-
- name: restore cache from package-lock.json
50-
uses: actions/cache@v4
51-
with:
52-
path: package-temp-dir
53-
key: lock-${{ github.sha }}
54-
55-
- name: restore cache from node_modules
56-
uses: actions/cache@v4
57-
with:
58-
path: node_modules
59-
key: node_modules-${{ hashFiles('**/package-temp-dir/package-lock.json') }}
60-
61-
- name: lint
62-
run: npm run lint
63-
64-
needs: setup
65-
66-
compile:
67-
runs-on: ubuntu-latest
68-
steps:
69-
- name: checkout
70-
uses: actions/checkout@v4
71-
72-
- name: restore cache from package-lock.json
73-
uses: actions/cache@v4
74-
with:
75-
path: package-temp-dir
76-
key: lock-${{ github.sha }}
77-
78-
- name: restore cache from node_modules
79-
uses: actions/cache@v4
80-
with:
81-
path: node_modules
82-
key: node_modules-${{ hashFiles('**/package-temp-dir/package-lock.json') }}
83-
84-
- name: compile
85-
run: npm run compile
86-
87-
needs: setup
88-
89-
coverage:
90-
runs-on: ubuntu-latest
91-
steps:
92-
- name: checkout
93-
uses: actions/checkout@v4
94-
95-
- name: restore cache from package-lock.json
96-
uses: actions/cache@v4
97-
with:
98-
path: package-temp-dir
99-
key: lock-${{ github.sha }}
100-
101-
- name: restore cache from node_modules
102-
uses: actions/cache@v4
103-
with:
104-
path: node_modules
105-
key: node_modules-${{ hashFiles('**/package-temp-dir/package-lock.json') }}
106-
107-
- name: coverage
108-
run: npm test -- --coverage
109-
110-
- name: Upload coverage to Codecov
111-
uses: codecov/codecov-action@v4
112-
with:
113-
token: ${{ secrets.CODECOV_TOKEN }}
114-
115-
needs: setup
4+
test:
5+
uses: react-component/rc-test/.github/workflows/test.yml@main
6+
secrets: inherit

.gitignore

+3-1
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,6 @@ coverage/
4040

4141
# dumi
4242
.dumi/tmp
43-
.dumi/tmp-production
43+
.dumi/tmp-production
44+
45+
bun.lockb

bunfig.toml

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[install]
2+
peer = false

docs/examples/cellRender.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ export default () => {
150150
{...sharedProps}
151151
locale={zhCN}
152152
picker="time"
153-
cellRender={(current, info) =>
153+
cellRender={(current: number | string, info) =>
154154
React.cloneElement(
155155
info.originNode,
156156
{
@@ -173,13 +173,13 @@ export default () => {
173173
allowClear
174174
showTime
175175
style={{ width: 580 }}
176-
cellRender={(current: Moment, info) => {
176+
cellRender={(current, info) => {
177177
return (
178178
<div
179179
title={info.type}
180180
style={{ background: info.type === 'time' ? 'green' : 'yellow' }}
181181
>
182-
{info.type === 'time' ? current : current.get('date')}
182+
{info.type === 'time' ? (current as number) : (current as Moment).get('date')}
183183
</div>
184184
);
185185
}}

docs/examples/customize.tsx

+1-33
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,9 @@ interface DateRangeState {
1212
endOpen: boolean;
1313
initValue: Moment;
1414
}
15-
type PanelMode = 'time' | 'datetime' | 'date' | 'week' | 'month' | 'year' | 'decade';
1615

1716
const now = moment();
1817

19-
function disabledDate(current: Moment) {
20-
// Can not select days before today
21-
return current && current < moment().subtract(1, 'days').endOf('day');
22-
}
23-
function changePanelCallBack(value: Moment, mode: PanelMode) {
24-
console.log(value, mode);
25-
}
2618
class Customize extends React.Component<{}, DateRangeState> {
2719
poupContainerRef: React.RefObject<HTMLDivElement>;
2820

@@ -109,7 +101,7 @@ class Customize extends React.Component<{}, DateRangeState> {
109101
);
110102

111103
render() {
112-
const { startValue, endValue, endOpen, initValue } = this.state;
104+
const { startValue, endValue, endOpen } = this.state;
113105
console.log('->', endOpen);
114106
return (
115107
<div>
@@ -141,30 +133,6 @@ class Customize extends React.Component<{}, DateRangeState> {
141133
/>
142134
<div ref={this.poupContainerRef} />
143135
</div>
144-
<div>
145-
<h3>renderExtraFooter</h3>
146-
<PickerPanel
147-
generateConfig={momentGenerateConfig}
148-
locale={zhCN}
149-
showToday
150-
disabledDate={disabledDate}
151-
onSelect={this.handleSelect}
152-
value={initValue}
153-
onPanelChange={changePanelCallBack}
154-
renderExtraFooter={(mode: PanelMode) => <div>{mode} extra footer</div>}
155-
/>
156-
</div>
157-
<div>
158-
<h3>month picker</h3>
159-
<PickerPanel
160-
generateConfig={momentGenerateConfig}
161-
locale={zhCN}
162-
picker="month"
163-
defaultValue={now}
164-
onSelect={this.handleSelectMonth}
165-
renderExtraFooter={() => <div>extra footer</div>}
166-
/>
167-
</div>
168136
<div>
169137
<h3>monthCellRender</h3>
170138
<PickerPanel

docs/examples/rtl.tsx

+10-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
import moment, { type Moment } from 'moment';
22
import React from 'react';
33
import '../../assets/index.less';
4+
import type { PickerRef } from '../../src/';
45
import { Picker, PickerPanel, RangePicker } from '../../src/';
56
import momentGenerateConfig from '../../src/generate/moment';
67
import enUS from '../../src/locale/en_US';
78
import jaJP from '../../src/locale/ja_JP';
89
import zhCN from '../../src/locale/zh_CN';
10+
import type { RangePickerRef } from '@/interface';
11+
import type { NoUndefinedRangeValueType } from '@/PickerInput/RangePicker';
912

1013
const defaultValue = moment();
1114

@@ -16,13 +19,16 @@ function formatDate(date: Moment | null) {
1619
export default () => {
1720
const [value, setValue] = React.useState<Moment | null>(defaultValue);
1821

19-
const weekRef = React.useRef<Picker<Moment>>(null);
22+
const weekRef = React.useRef<PickerRef>(null);
2023

2124
const onSelect = (newValue: Moment) => {
2225
console.log('Select:', newValue);
2326
};
2427

25-
const onChange = (newValue: Moment | null, formatString?: string) => {
28+
const onChange = (
29+
newValue: NoUndefinedRangeValueType<Moment>,
30+
formatString?: string | [string, string],
31+
) => {
2632
const lastValue = Array.isArray(newValue) ? newValue[1] : newValue;
2733
console.log('Change:', lastValue, newValue, formatString);
2834
setValue(lastValue);
@@ -33,10 +39,10 @@ export default () => {
3339
value,
3440
onSelect,
3541
onChange,
36-
direction: 'rtl',
42+
direction: 'rtl' as const,
3743
};
3844

39-
const rangePickerRef = React.useRef<RangePicker<Moment>>(null);
45+
const rangePickerRef = React.useRef<RangePickerRef>(null);
4046

4147
return (
4248
<div dir="rtl">

0 commit comments

Comments
 (0)