From c1095a2995e3ce6a324f92942754a2aa4390fcdd Mon Sep 17 00:00:00 2001 From: MadCcc <1075746765@qq.com> Date: Wed, 16 Mar 2022 15:10:28 +0800 Subject: [PATCH] chore: use github action ci (#92) * chore: use github action ci * chore: code clean * test: fix ci --- .github/workflows/main.yml | 114 +++++++++++++++++++++++++++++++++++++ package.json | 6 +- tests/Mentions.spec.jsx | 4 +- 3 files changed, 121 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..0b2ccda --- /dev/null +++ b/.github/workflows/main.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 diff --git a/package.json b/package.json index 85e1b5e..651e8f7 100644 --- a/package.json +++ b/package.json @@ -47,11 +47,13 @@ "@umijs/fabric": "^2.0.8", "enzyme": "^3.11.0", "enzyme-to-json": "^3.1.4", - "eslint": "^8.9.0", + "eslint": "^7.0.0", "father": "^2.13.6", + "jest": "^24.9.0", "lodash.debounce": "^4.0.8", "np": "^7.0.0", - "react": "^17.0.2", + "prettier": "^2.0.5", + "react": "^16.0.0", "react-dom": "^16.0.0", "typescript": "^4.0.3" }, diff --git a/tests/Mentions.spec.jsx b/tests/Mentions.spec.jsx index 4d6729c..81496ba 100644 --- a/tests/Mentions.spec.jsx +++ b/tests/Mentions.spec.jsx @@ -153,7 +153,9 @@ describe('Mentions', () => { .find('li.rc-mentions-dropdown-menu-item') .last() .simulate('mouseEnter'); - expect(wrapper.find('Menu').props().activeKey).toBe('cat'); + expect( + wrapper.find('.rc-mentions-dropdown-menu-item-active').first().text(), + ).toBe('Cat'); }); }); });