Skip to content

Commit

Permalink
test: use unified github action yml (#476)
Browse files Browse the repository at this point in the history
  • Loading branch information
Layouwen authored and zombieJ committed Sep 3, 2024
1 parent 72982dd commit 2cba4d5
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 149 deletions.
118 changes: 5 additions & 113 deletions .github/workflows/main.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: '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
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 @@ -27,6 +27,7 @@ es
coverage
yarn.lock
package-lock.json
bun.lockb

# dumi
.umi
Expand Down
6 changes: 4 additions & 2 deletions docs/examples/case.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -115,6 +115,8 @@ const Demo = () => {
click,
contextMenu,
};

const actionsKeys = Object.keys(actions).filter((action) => actions[action]) as ActionType[];

return (
<React.StrictMode>
Expand Down Expand Up @@ -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={{
Expand Down
6 changes: 3 additions & 3 deletions docs/examples/nested.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ const Test = () => {
getPopupContainer={() => containerRef.current}
popup={<div style={popupBorderStyle}>I am inner Trigger Popup</div>}
>
<span href="#" style={{ margin: 20 }}>
<span style={{ margin: 20 }}>
clickToShowInnerTrigger
</span>
</Trigger>
Expand All @@ -94,7 +94,7 @@ const Test = () => {
builtinPlacements={builtinPlacements}
popup={<div style={popupBorderStyle}>i am a hover popup</div>}
>
<span href="#" style={{ margin: 20 }}>
<span style={{ margin: 20 }}>
trigger
</span>
</Trigger>
Expand All @@ -108,7 +108,7 @@ const Test = () => {
builtinPlacements={builtinPlacements}
popup={innerTrigger}
>
<span href="#" style={{ margin: 20 }}>
<span style={{ margin: 20 }}>
trigger
</span>
</Trigger>
Expand Down
4 changes: 2 additions & 2 deletions docs/examples/point.tsx
Original file line number Diff line number Diff line change
@@ -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';

Expand All @@ -17,7 +17,7 @@ const innerTrigger = (

class Test extends React.Component {
state = {
action: 'click',
action: 'click' as ActionType,
mouseEnterDelay: 0,
};

Expand Down
34 changes: 5 additions & 29 deletions docs/examples/simple.tsx
Original file line number Diff line number Diff line change
@@ -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';

Expand Down Expand Up @@ -199,6 +199,9 @@ class Test extends React.Component<any, TestState> {
if (state.destroyed) {
return null;
}

const actions = Object.keys(state.trigger) as ActionType[]

return (
<div>
<div style={{ margin: '10px 20px' }}>
Expand Down Expand Up @@ -359,7 +362,7 @@ class Test extends React.Component<any, TestState> {
maskAnimation="fade"
// mouseEnterDelay={0.1}
// mouseLeaveDelay={0.1}
action={Object.keys(state.trigger)}
action={actions}
builtinPlacements={builtinPlacements}
arrow
popupStyle={{
Expand All @@ -370,33 +373,6 @@ class Test extends React.Component<any, TestState> {
}}
popup={<div>i am a popup</div>}
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) => (
<>
<div>
<input
style={{ width: '100%' }}
placeholder="additional content"
/>
</div>
{node}
</>
),
}
: null
}
>
<RefTarget />
</Trigger>
Expand Down

0 comments on commit 2cba4d5

Please sign in to comment.