diff --git a/.eslintrc.js b/.eslintrc.js index 97d861b..ed45d7c 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,9 +1,6 @@ -const base = require('@umijs/fabric/dist/eslint'); - module.exports = { - ...base, + extends: [require.resolve('@umijs/fabric/dist/eslint')], rules: { - ...base.rules, 'no-template-curly-in-string': 0, 'prefer-promise-reject-errors': 0, 'react/no-array-index-key': 0, diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..3e6e49d --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,113 @@ +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: '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 --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 diff --git a/.husky/pre-commit b/.husky/pre-commit index 798e8b4..759436f 100755 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -2,4 +2,3 @@ . "$(dirname "$0")/_/husky.sh" npx --no-install lint-staged --quiet -npx --no-install jest diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 3c38d88..0000000 --- a/.travis.yml +++ /dev/null @@ -1,18 +0,0 @@ -language: node_js - -sudo: false - -node_js: -- 12 - -script: -- | - npm run $TEST_TYPE -env: - matrix: - - TEST_TYPE=lint - - TEST_TYPE=test - - TEST_TYPE=coverage - -after_success: - - bash <(curl -s https://codecov.io/bash) -e TRAVIS_NODE_VERSION \ No newline at end of file diff --git a/jest.config.ts b/jest.config.ts index 91070fd..6bf8ca5 100644 --- a/jest.config.ts +++ b/jest.config.ts @@ -5,6 +5,7 @@ import type { Config } from '@umijs/test'; const config: Config.InitialOptions = { ...createConfig(), testEnvironment: 'jsdom', + collectCoverageFrom: ['src/**/*'], }; export default config; diff --git a/package.json b/package.json index e2afe5d..6a7bb16 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,7 @@ "compile": "father build && lessc assets/index.less assets/index.css", "coverage": "jest --coverage", "gh-pages": "npm run build && father doc deploy -d .docs", - "lint": "eslint . --ext='jsx'", + "lint": "eslint src/ --ext .tsx,.ts", "prepare": "husky install && dumi setup", "prepublishOnly": "npm run compile && np --yolo --no-publish", "start": "dumi dev",