Prechádzať zdrojové kódy

test: Combine Test code coverage (#931)

* test: update test.yml

* test: remove cypress run spec test

* test: update merge output dir

* test: skip anchor show tooltip

Co-authored-by: linyan <[email protected]>
走鹃 3 rokov pred
rodič
commit
51e7f0c71c

+ 53 - 6
.github/workflows/test.yml

@@ -4,25 +4,72 @@ name: test
 
 on:
   push:
-    branches: [ main, release ]
+    branches: [ main, release, test-code-coverage ]
   pull_request:
     branches: [ main, release ]
 
   workflow_dispatch:
 
 jobs:
-  test:
+  jest:
     runs-on: ubuntu-latest
     steps:
       - uses: actions/checkout@v2
       - uses: actions/setup-node@v2
         with:
           node-version: '14'
-
       - name: Run install
         run: npm i -g lerna && npm run bootstrap
-
-      - name: Run test
+      - name: Run Jest test
         run: npm run test:coverage
+      - name: Archive Jest coverage
+        uses: actions/upload-artifact@v3
+        with:
+          if-no-files-found: error
+          name: jest
+          path: test/coverage/coverage-final.json
+  cypress:
+    runs-on: ubuntu-latest
+    steps:
+      - uses: actions/checkout@v2
+      - uses: actions/setup-node@v2
+        with:
+          node-version: '14'
+      - name: Run install
+        run: |
+          npm i -g lerna
+          npm run bootstrap
+      - name: Build storybook
+        run: |
+          npm run pre-story
+          TEST_ENV=test npm run build-storybook
+      - name: Serve storybook
+        run: nohup npx http-server -p 6006 storybook-static &
+      - name: Run Cypress test
+        run: npx wait-on http://127.0.0.1:6006 && ./node_modules/.bin/cypress run
+      - name: Archive Cypress coverage
+        uses: actions/upload-artifact@v3
+        with:
+          if-no-files-found: error
+          name: cypress
+          path: cypress/coverage/coverage-final.json
+  coverage:
+    runs-on: ubuntu-latest
+    needs: [jest, cypress]
+    steps:
+      - uses: actions/checkout@v2
+      - uses: actions/setup-node@v2
+        with:
+          node-version: '14'
+      - name: Download Jest coverage
+        uses: actions/download-artifact@v3
+        with:
+          # upload jest and cypress coverage to output dir
+          path: output
+      - name: Code coverage merge
+        run: |
+          tree output
+          npx istanbul-merge --out output/coverage-final.json output/jest/coverage-final.json output/cypress/coverage-final.json
+          tree output
       - name: Run codecov
-        run: npx codecov --token=${{ secrets.CODECOV_TOKEN }}
+        run: npx codecov --token=${{ secrets.CODECOV_TOKEN }} --file=output/coverage-final.json

+ 1 - 1
cypress/integration/anchor.spec.js

@@ -1,5 +1,5 @@
 describe('anchor', () => {
-    it('show tooltip', () => {
+    it.skip('show tooltip', () => {
         cy.visit('http://127.0.0.1:6006/iframe.html?id=anchor--show-tooltip&args=&viewMode=story');
         cy.get('.semi-anchor-link').contains('工具提示是一个有用的工具').trigger('mouseover');
         cy.get('.semi-portal').contains('工具提示是一个有用的工具');