Skip to content

Commit 02dfd34

Browse files
authored
test: use unified github action yml (#285)
1 parent fd5d656 commit 02dfd34

File tree

5 files changed

+23
-129
lines changed

5 files changed

+23
-129
lines changed

.github/workflows/main.yml

Lines changed: 5 additions & 114 deletions
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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ lib/
88
yarn.lock
99
package-lock.json
1010
!tests/__mocks__/rc-util/lib
11+
bun.lockb
1112

1213
# umi
1314
.umi

bunfig.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[install]
2+
peer = false

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@
6363
"np": "^5.0.3",
6464
"rc-animate": "^2.9.1",
6565
"rc-test": "^7.0.15",
66-
"react": "^v16.9.0-alpha.0",
67-
"react-dom": "^v16.9.0-alpha.0",
66+
"react": "16.14.0",
67+
"react-dom": "16.14.0",
6868
"typescript": "^5.0.0"
6969
},
7070
"dependencies": {

tests/scroll.test.js

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1+
import '@testing-library/jest-dom';
2+
import { createEvent, fireEvent, render } from '@testing-library/react';
3+
import { mount } from 'enzyme';
4+
import { _rs as onLibResize } from 'rc-resize-observer/lib/utils/observerUtil';
5+
import { resetWarned } from 'rc-util/lib/warning';
16
import React from 'react';
27
import { act } from 'react-dom/test-utils';
3-
import { mount } from 'enzyme';
4-
import { spyElementPrototypes } from './utils/domHook';
58
import List from '../src';
6-
import { createEvent, fireEvent, render } from '@testing-library/react';
7-
import { resetWarned } from 'rc-util/lib/warning';
8-
import { _rs as onLibResize } from 'rc-resize-observer/lib/utils/observerUtil';
9-
import '@testing-library/jest-dom';
9+
import { spyElementPrototypes } from './utils/domHook';
1010

1111
function genData(count) {
1212
return new Array(count).fill(null).map((_, index) => ({ id: String(index) }));
@@ -478,20 +478,20 @@ describe('List.Scroll', () => {
478478
jest.useRealTimers();
479479
const { container } = genList(
480480
// set itemHeight * data.length < height, but sum of actual height > height
481-
{
482-
itemHeight: 8,
483-
height: 100,
484-
data: genData(10)
485-
},
481+
{
482+
itemHeight: 8,
483+
height: 100,
484+
data: genData(10),
485+
},
486486
render,
487487
);
488-
488+
489489
await act(async () => {
490490
await new Promise((resolve) => {
491491
setTimeout(resolve, 10);
492492
});
493493
});
494494

495-
expect(container.querySelector('.rc-virtual-list-scrollbar-thumb')).toBeVisible()
495+
expect(container.querySelector('.rc-virtual-list-scrollbar-thumb')).toBeVisible();
496496
});
497497
});

0 commit comments

Comments
 (0)