test-coverage.yml 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. # This is a basic workflow to help you get started with Actions
  2. name: test-coverage
  3. on:
  4. push:
  5. branches: [main, release, test-code-coverage]
  6. pull_request:
  7. branches: [main, release]
  8. workflow_dispatch:
  9. jobs:
  10. jest:
  11. runs-on: ubuntu-latest
  12. steps:
  13. - uses: actions/checkout@v4
  14. - uses: actions/setup-node@v4
  15. with:
  16. node-version: '20'
  17. - name: Run install
  18. run: npm i -g lerna@^6 && npm run bootstrap
  19. - name: Run Jest test
  20. run: npm run test:coverage
  21. - name: Archive Jest coverage
  22. uses: actions/upload-artifact@v4
  23. with:
  24. if-no-files-found: error
  25. name: jest
  26. path: test/coverage/coverage-final.json
  27. cypress:
  28. runs-on: ubuntu-latest
  29. steps:
  30. - uses: actions/checkout@v4
  31. - uses: actions/setup-node@v4
  32. with:
  33. node-version: '20'
  34. - name: Run install
  35. run: |
  36. npm i -g lerna@^6
  37. npm run bootstrap
  38. - name: Build storybook
  39. run: |
  40. npm run pre-story
  41. TEST_ENV=test npm run build-storybook
  42. - name: Serve storybook
  43. run: nohup npx http-server -p 6006 storybook-static &
  44. - name: Run Cypress test
  45. run: npx wait-on http://127.0.0.1:6006 && ./node_modules/.bin/cypress run
  46. - name: Archive Cypress coverage
  47. uses: actions/upload-artifact@v4
  48. with:
  49. if-no-files-found: error
  50. name: cypress
  51. path: cypress/coverage/coverage-final.json
  52. coverage:
  53. runs-on: ubuntu-latest
  54. needs: [jest, cypress]
  55. steps:
  56. - uses: actions/checkout@v4
  57. - uses: actions/setup-node@v4
  58. with:
  59. node-version: '20'
  60. - name: Download Jest coverage
  61. uses: actions/download-artifact@v4
  62. with:
  63. # upload jest and cypress coverage to output dir
  64. path: output
  65. - name: Code coverage merge
  66. run: |
  67. tree output
  68. npx istanbul-merge --out output/coverage-final.json output/jest/coverage-final.json output/cypress/coverage-final.json
  69. tree output
  70. - name: Run codecov
  71. run: npx codecov --token=${{ secrets.CODECOV_TOKEN }} --file=output/coverage-final.json