Skip to content

Commit

Permalink
test: use unified github action yml (#285)
Browse files Browse the repository at this point in the history
  • Loading branch information
Layouwen authored Aug 18, 2024
1 parent fd5d656 commit 02dfd34
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 129 deletions.
119 changes: 5 additions & 114 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,115 +1,6 @@
name: CI

on: ['push', 'pull_request']

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

- uses: actions/setup-node@v4
with:
node-version: '20'

- name: cache package-lock.json
uses: actions/cache@v4
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@v4
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@v4

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

- name: restore cache from node_modules
uses: actions/cache@v4
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@v4

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

- name: restore cache from node_modules
uses: actions/cache@v4
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@v4

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

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

- name: coverage
run: npm test -- --coverage

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}

needs: setup
test:
uses: react-component/rc-test/.github/workflows/test.yml@main
secrets: inherit
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ lib/
yarn.lock
package-lock.json
!tests/__mocks__/rc-util/lib
bun.lockb

# umi
.umi
Expand Down
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
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@
"np": "^5.0.3",
"rc-animate": "^2.9.1",
"rc-test": "^7.0.15",
"react": "^v16.9.0-alpha.0",
"react-dom": "^v16.9.0-alpha.0",
"react": "16.14.0",
"react-dom": "16.14.0",
"typescript": "^5.0.0"
},
"dependencies": {
Expand Down
26 changes: 13 additions & 13 deletions tests/scroll.test.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import '@testing-library/jest-dom';
import { createEvent, fireEvent, render } from '@testing-library/react';
import { mount } from 'enzyme';
import { _rs as onLibResize } from 'rc-resize-observer/lib/utils/observerUtil';
import { resetWarned } from 'rc-util/lib/warning';
import React from 'react';
import { act } from 'react-dom/test-utils';
import { mount } from 'enzyme';
import { spyElementPrototypes } from './utils/domHook';
import List from '../src';
import { createEvent, fireEvent, render } from '@testing-library/react';
import { resetWarned } from 'rc-util/lib/warning';
import { _rs as onLibResize } from 'rc-resize-observer/lib/utils/observerUtil';
import '@testing-library/jest-dom';
import { spyElementPrototypes } from './utils/domHook';

function genData(count) {
return new Array(count).fill(null).map((_, index) => ({ id: String(index) }));
Expand Down Expand Up @@ -478,20 +478,20 @@ describe('List.Scroll', () => {
jest.useRealTimers();
const { container } = genList(
// set itemHeight * data.length < height, but sum of actual height > height
{
itemHeight: 8,
height: 100,
data: genData(10)
},
{
itemHeight: 8,
height: 100,
data: genData(10),
},
render,
);

await act(async () => {
await new Promise((resolve) => {
setTimeout(resolve, 10);
});
});

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

0 comments on commit 02dfd34

Please sign in to comment.