From 2cba4d5ef1855156d093d3cdb0d4af74ede826c5 Mon Sep 17 00:00:00 2001 From: Avan Date: Sun, 18 Aug 2024 10:18:33 +0800 Subject: [PATCH] test: use unified github action yml (#476) --- .github/workflows/main.yml | 118 ++----------------------------------- .gitignore | 1 + docs/examples/case.tsx | 6 +- docs/examples/nested.tsx | 6 +- docs/examples/point.tsx | 4 +- docs/examples/simple.tsx | 34 ++--------- 6 files changed, 20 insertions(+), 149 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index a23ad090..f860ff10 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -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: '16' - - - 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 - - - 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 i - - 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 run coverage && bash <(curl -s https://codecov.io/bash) - - needs: setup \ No newline at end of file + test: + uses: react-component/rc-test/.github/workflows/test.yml@main + secrets: inherit diff --git a/.gitignore b/.gitignore index 65899cf1..f44d17fe 100644 --- a/.gitignore +++ b/.gitignore @@ -27,6 +27,7 @@ es coverage yarn.lock package-lock.json +bun.lockb # dumi .umi diff --git a/docs/examples/case.tsx b/docs/examples/case.tsx index 2d24a8e4..695f0db2 100644 --- a/docs/examples/case.tsx +++ b/docs/examples/case.tsx @@ -2,7 +2,7 @@ import React from 'react'; import type { CSSMotionProps } from 'rc-motion'; -import type { BuildInPlacements } from 'rc-trigger'; +import type { ActionType, BuildInPlacements } from 'rc-trigger'; import Trigger from 'rc-trigger'; import './case.less'; @@ -115,6 +115,8 @@ const Demo = () => { click, contextMenu, }; + + const actionsKeys = Object.keys(actions).filter((action) => actions[action]) as ActionType[]; return ( @@ -203,7 +205,7 @@ const Demo = () => { maskMotion={motion ? MaskMotion : null} maskClosable={maskClosable} stretch={stretch} - action={Object.keys(actions).filter((action) => actions[action])} + action={actionsKeys} builtinPlacements={builtinPlacements} forceRender={forceRender} popupStyle={{ diff --git a/docs/examples/nested.tsx b/docs/examples/nested.tsx index 3412438e..259ea0a3 100644 --- a/docs/examples/nested.tsx +++ b/docs/examples/nested.tsx @@ -67,7 +67,7 @@ const Test = () => { getPopupContainer={() => containerRef.current} popup={
I am inner Trigger Popup
} > - + clickToShowInnerTrigger @@ -94,7 +94,7 @@ const Test = () => { builtinPlacements={builtinPlacements} popup={
i am a hover popup
} > - + trigger @@ -108,7 +108,7 @@ const Test = () => { builtinPlacements={builtinPlacements} popup={innerTrigger} > - + trigger diff --git a/docs/examples/point.tsx b/docs/examples/point.tsx index 228fb182..c2b48b8f 100644 --- a/docs/examples/point.tsx +++ b/docs/examples/point.tsx @@ -1,7 +1,7 @@ /* eslint no-console:0 */ import React from 'react'; -import Trigger from 'rc-trigger'; +import Trigger, { ActionType } from 'rc-trigger'; import '../../assets/index.less'; import './point.less'; @@ -17,7 +17,7 @@ const innerTrigger = ( class Test extends React.Component { state = { - action: 'click', + action: 'click' as ActionType, mouseEnterDelay: 0, }; diff --git a/docs/examples/simple.tsx b/docs/examples/simple.tsx index 31b53881..59a2641e 100644 --- a/docs/examples/simple.tsx +++ b/docs/examples/simple.tsx @@ -1,6 +1,6 @@ /* eslint no-console:0 */ -import Trigger from 'rc-trigger'; +import Trigger, { ActionType } from 'rc-trigger'; import React from 'react'; import '../../assets/index.less'; @@ -199,6 +199,9 @@ class Test extends React.Component { if (state.destroyed) { return null; } + + const actions = Object.keys(state.trigger) as ActionType[] + return (
@@ -359,7 +362,7 @@ class Test extends React.Component { maskAnimation="fade" // mouseEnterDelay={0.1} // mouseLeaveDelay={0.1} - action={Object.keys(state.trigger)} + action={actions} builtinPlacements={builtinPlacements} arrow popupStyle={{ @@ -370,33 +373,6 @@ class Test extends React.Component { }} popup={
i am a popup
} popupTransitionName={state.transitionName} - mobile={ - state.mobile - ? { - popupMotion: { - motionName: 'rc-trigger-popup-mobile-fade', - }, - popupClassName: 'rc-trigger-popup-mobile', - popupStyle: { - padding: 16, - borderTop: '1px solid red', - background: '#FFF', - textAlign: 'center', - }, - popupRender: (node) => ( - <> -
- -
- {node} - - ), - } - : null - } >