Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: use codecov/codecov-action #554

Merged
merged 8 commits into from
Aug 23, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
118 changes: 5 additions & 113 deletions .github/workflows/react-component-ci.yml
Original file line number Diff line number Diff line change
@@ -1,114 +1,6 @@
name: CI

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

name: ✅ test
on: [push, pull_request]
jobs:
setup:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@master

- uses: actions/setup-node@v1
with:
node-version: '18'

- name: cache package-lock.json
uses: actions/cache@v2
with:
path: package-temp-dir
key: lock-${{ github.sha }}

- name: create package-lock.json
run: npm i --package-lock-only --ignore-scripts

- name: hack for singe file
run: |
if [ ! -d "package-temp-dir" ]; then
mkdir package-temp-dir
fi
cp package-lock.json package-temp-dir

- name: cache node_modules
id: node_modules_cache_id
uses: actions/cache@v2
with:
path: node_modules
key: node_modules-${{ hashFiles('**/package-temp-dir/package-lock.json') }}

- name: install
if: steps.node_modules_cache_id.outputs.cache-hit != 'true'
run: npm ci

lint:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@master

- name: restore cache from package-lock.json
uses: actions/cache@v2
with:
path: package-temp-dir
key: lock-${{ github.sha }}

- name: restore cache from node_modules
uses: actions/cache@v2
with:
path: node_modules
key: node_modules-${{ hashFiles('**/package-temp-dir/package-lock.json') }}

- name: lint
run: npm run lint

needs: setup

compile:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@master

- name: restore cache from package-lock.json
uses: actions/cache@v2
with:
path: package-temp-dir
key: lock-${{ github.sha }}

- name: restore cache from node_modules
uses: actions/cache@v2
with:
path: node_modules
key: node_modules-${{ hashFiles('**/package-temp-dir/package-lock.json') }}

- name: compile
run: npm run compile

needs: setup

coverage:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@master

- name: restore cache from package-lock.json
uses: actions/cache@v2
with:
path: package-temp-dir
key: lock-${{ github.sha }}

- name: restore cache from node_modules
uses: actions/cache@v2
with:
path: node_modules
key: node_modules-${{ hashFiles('**/package-temp-dir/package-lock.json') }}

- name: coverage
run: npm test -- --coverage && bash <(curl -s https://codecov.io/bash)

needs: setup
test:
uses: react-component/rc-test/.github/workflows/test.yml@main
secrets: inherit
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,5 @@ es/*
.dumi/tmp-test
.dumi/tmp-production
.env.local

bun.lockb
2 changes: 2 additions & 0 deletions bunfig.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[install]
peer = false
2 changes: 1 addition & 1 deletion examples/dynamic.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class Demo extends React.Component {

loadData = treeNode => {
console.log('trigger load:', treeNode);
return new Promise(resolve => {
return new Promise<void>(resolve => {
setTimeout(() => {
let { treeData } = this.state;
treeData = treeData.slice();
Expand Down
4 changes: 2 additions & 2 deletions examples/utils/dataUtil.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable no-plusplus, no-mixed-operators, no-underscore-dangle */
export function generateData(x = 3, y = 2, z = 1, gData = []) {
// x:每一级下的节点总数。y:每级节点里有y个节点、存在子节点。z:树的level层级数(0表示一级)
function _loop(_level, _preKey, _tns) {
function _loop(_level, _preKey?, _tns?) {
const preKey = _preKey || '0';
const tns = _tns || gData;

Expand Down Expand Up @@ -88,7 +88,7 @@ export function getNewTreeData(treeData, curKey, child, level) {
}

function loopData(data, callback) {
const loop = (d, level = 0) => {
const loop = (d, level = '0') => {
d.forEach((item, index) => {
const pos = `${level}-${index}`;
if (item.children) {
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@
"rc-virtual-list": "^3.0.0",
"react": "^16.8.0",
"react-dom": "^16.8.0",
"typescript": "^5.0.0"
"typescript": "^5.0.0",
"cheerio": "1.0.0-rc.12"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

},
"peerDependencies": {
"react": "*",
Expand Down
2 changes: 1 addition & 1 deletion tests/Select.checkable.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ describe('TreeSelect.checkable', () => {
describe('labelInValue', () => {
it('basic', () => {
const wrapper = mount(
<TreeSelect checkable labelInValue value={[{ value: '0-0' }]}>
<TreeSelect labelInValue value={[{ value: '0-0' }]}>
afc163 marked this conversation as resolved.
Show resolved Hide resolved
<TreeNode key="0-0" value="0-0" title="0-0">
<TreeNode key="0-0-0" value="0-0-0" title="0-0-0" />
</TreeNode>
Expand Down
6 changes: 3 additions & 3 deletions tests/Select.multiple.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ describe('TreeSelect.multiple', () => {

it('remove by backspace key', () => {
const wrapper = mount(createSelect({ defaultValue: ['0', '1'] }));
wrapper.find('input').first().simulate('keyDown', { which: KeyCode.BACKSPACE });
wrapper.find('input').first().simulate('keyDown', { which: KeyCode.BACKSPACE, key: 'Backspace' });
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

expect(wrapper.getSelection()).toHaveLength(1);
expect(wrapper.getSelection(0).text()).toBe('label0');
});
Expand All @@ -59,9 +59,9 @@ describe('TreeSelect.multiple', () => {
}
}
const wrapper = mount(<App />);
wrapper.find('input').first().simulate('keyDown', { which: KeyCode.BACKSPACE });
wrapper.find('input').first().simulate('keyDown', { which: KeyCode.BACKSPACE, key: 'Backspace' });
wrapper.selectNode(1);
wrapper.find('input').first().simulate('keyDown', { which: KeyCode.BACKSPACE });
wrapper.find('input').first().simulate('keyDown', { which: KeyCode.BACKSPACE, key: 'Backspace' });
expect(wrapper.getSelection()).toHaveLength(1);
expect(wrapper.getSelection(0).text()).toBe('label0');
});
Expand Down
Loading