From 95c1be21b7a5192ee0c173332a3808a2f8ee4f17 Mon Sep 17 00:00:00 2001 From: xrkffgg Date: Fri, 8 Jan 2021 13:35:59 +0800 Subject: [PATCH 1/5] chore: use github actions --- .github/workflows/react-component-ci.yml | 114 +++++++++++++++++++++++ 1 file changed, 114 insertions(+) create mode 100644 .github/workflows/react-component-ci.yml diff --git a/.github/workflows/react-component-ci.yml b/.github/workflows/react-component-ci.yml new file mode 100644 index 0000000..432a3fb --- /dev/null +++ b/.github/workflows/react-component-ci.yml @@ -0,0 +1,114 @@ +name: CI + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + setup: + runs-on: ubuntu-latest + steps: + - name: checkout + uses: actions/checkout@master + + - uses: actions/setup-node@v1 + with: + node-version: '12' + + - 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 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 From ec29219ee22ae29aac5cf911f4f9bf6bc254b4c7 Mon Sep 17 00:00:00 2001 From: xrkffgg Date: Fri, 8 Jan 2021 13:38:16 +0800 Subject: [PATCH 2/5] add --- .travis.yml | 26 -------------------------- README.md | 6 +++--- 2 files changed, 3 insertions(+), 29 deletions(-) delete mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 2fbc8bf..0000000 --- a/.travis.yml +++ /dev/null @@ -1,26 +0,0 @@ -language: node_js - -sudo: false - -notifications: - email: - - yiminghe@gmail.com - -node_js: -- 12 - -script: -- | - if [ "$TEST_TYPE" = test ]; then - npm test -- --coverage && \ - bash <(curl -s https://codecov.io/bash) - else - npm run $TEST_TYPE - fi - -env: - matrix: - - TEST_TYPE=lint - - TEST_TYPE=test - - TEST_TYPE=coverage - - TEST_TYPE=compile diff --git a/README.md b/README.md index b268cdf..40f2ada 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ Progress Bar. [![NPM version][npm-image]][npm-url] -[![build status][travis-image]][travis-url] +[![build status][github-actions-image]][github-actions-url] [![Test coverage][coveralls-image]][coveralls-url] [![Dependencies][david-image]](david-url) [![DevDependencies][david-dev-image]][david-dev-url] @@ -12,8 +12,8 @@ Progress Bar. [npm-image]: http://img.shields.io/npm/v/rc-progress.svg?style=flat-square [npm-url]: http://npmjs.org/package/rc-progress -[travis-image]: https://img.shields.io/travis/react-component/progress/master?style=flat-square -[travis-url]: https://travis-ci.org/react-component/progress +[github-actions-image]: https://github.com/react-component/progress/workflows/CI/badge.svg +[github-actions-url]: https://github.com/react-component/progress/actions [circleci-image]: https://img.shields.io/circleci/react-component/progress/master?style=flat-square [circleci-url]: https://circleci.com/gh/react-component/progress [coveralls-image]: https://img.shields.io/coveralls/react-component/progress.svg?style=flat-square From 34c59b8bf83ab096f146010702355922363042f1 Mon Sep 17 00:00:00 2001 From: xrkffgg Date: Fri, 8 Jan 2021 13:44:27 +0800 Subject: [PATCH 3/5] remove type --- src/Circle.tsx | 2 +- src/Line.tsx | 2 +- src/common.ts | 2 +- src/index.ts | 2 +- src/interface.ts | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Circle.tsx b/src/Circle.tsx index 6779175..c645332 100644 --- a/src/Circle.tsx +++ b/src/Circle.tsx @@ -1,7 +1,7 @@ import * as React from 'react'; import classNames from 'classnames'; import { useTransitionDuration, defaultProps } from './common'; -import type { ProgressProps, GapPositionType } from './interface'; +import { ProgressProps, GapPositionType } from './interface'; let gradientSeed = 0; diff --git a/src/Line.tsx b/src/Line.tsx index 88e3a82..9c0706b 100644 --- a/src/Line.tsx +++ b/src/Line.tsx @@ -1,7 +1,7 @@ import * as React from 'react'; import classNames from 'classnames'; import { useTransitionDuration, defaultProps } from './common'; -import type { ProgressProps } from './interface'; +import { ProgressProps } from './interface'; const Line: React.FC = ({ className, diff --git a/src/common.ts b/src/common.ts index 6b99877..4b7e6fe 100644 --- a/src/common.ts +++ b/src/common.ts @@ -1,5 +1,5 @@ import { useRef, useEffect } from 'react'; -import type { ProgressProps } from './interface'; +import { ProgressProps } from './interface'; export const defaultProps: Partial = { className: '', diff --git a/src/index.ts b/src/index.ts index 88e552d..cf24363 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,6 +1,6 @@ import Line from './Line'; import Circle from './Circle'; -import type { ProgressProps } from './interface'; +import { ProgressProps } from './interface'; export { Line, Circle, ProgressProps }; diff --git a/src/interface.ts b/src/interface.ts index dc5daa6..8599290 100644 --- a/src/interface.ts +++ b/src/interface.ts @@ -1,4 +1,4 @@ -import type * as React from 'react'; +import * as React from 'react'; export interface ProgressProps { strokeWidth?: number; From 1f1be610253e661981c9fbbc9b7643b8a4b983ff Mon Sep 17 00:00:00 2001 From: xrkffgg Date: Fri, 8 Jan 2021 13:54:02 +0800 Subject: [PATCH 4/5] add test --- tests/__snapshots__/index.spec.js.snap | 117 ++++++++++++++++++++++++- tests/index.spec.js | 14 ++- 2 files changed, 129 insertions(+), 2 deletions(-) diff --git a/tests/__snapshots__/index.spec.js.snap b/tests/__snapshots__/index.spec.js.snap index 80c0365..0b5ddf8 100644 --- a/tests/__snapshots__/index.spec.js.snap +++ b/tests/__snapshots__/index.spec.js.snap @@ -60,7 +60,6 @@ Array [ /> , -
, , + + + + + + , + + + + + + , ] `; diff --git a/tests/index.spec.js b/tests/index.spec.js index f40c1db..2361e9e 100644 --- a/tests/index.spec.js +++ b/tests/index.spec.js @@ -88,7 +88,6 @@ describe('Progress', () => { strokeWidth="6" strokeLinecap="square" /> -
{ strokeWidth="6" strokeLinecap="square" /> + + , ); From b754a70c2a7f217bd8b14dee0249bf7814f558e4 Mon Sep 17 00:00:00 2001 From: xrkffgg Date: Fri, 8 Jan 2021 14:00:08 +0800 Subject: [PATCH 5/5] add test --- tests/__snapshots__/index.spec.js.snap | 142 +++++++++++++++++++++++++ tests/index.spec.js | 13 +++ 2 files changed, 155 insertions(+) diff --git a/tests/__snapshots__/index.spec.js.snap b/tests/__snapshots__/index.spec.js.snap index 0b5ddf8..cb0ce76 100644 --- a/tests/__snapshots__/index.spec.js.snap +++ b/tests/__snapshots__/index.spec.js.snap @@ -1,5 +1,147 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP +exports[` 1`] = ` +Array [ + + + + + + , +
, + + + + + + , +
, + + + + + + , +] +`; + exports[`Progress Circle should show right gapPosition 1`] = ` Array [ { }); }); + describe('Diff Line', () => { + const wrapper = mount( + <> + +
+ +
+ + + ); + expect(wrapper).toMatchSnapshot(); + }) + describe('Circle', () => { it('change with animation', () => { class Demo extends React.Component {