feat: 添加 react 组件单测配置 #17284
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: test | |
| on: [push, pull_request] | |
| permissions: | |
| contents: read | |
| pull-requests: read | |
| jobs: | |
| tsc: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - run: npm i && npm run build:tsc | |
| lint: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - run: npm i && npm run lint | |
| unit: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: detect RN component changes | |
| id: changes | |
| uses: dorny/paths-filter@v4 | |
| with: | |
| filters: | | |
| rn_components: | |
| - 'packages/webpack-plugin/lib/runtime/components/react/**' | |
| - 'packages/webpack-plugin/test/runtime/react-native/components/**' | |
| - 'packages/webpack-plugin/test/__mocks__/**' | |
| - 'packages/webpack-plugin/jest.config.react.json' | |
| - name: Cache node modules | |
| id: cache | |
| uses: actions/cache@v4 | |
| env: | |
| cache-name: cache-node-modules | |
| with: | |
| path: | | |
| ~/.npm | |
| node_modules | |
| test/e2e/miniprogram-project/node_modules | |
| test/e2e/plugin-project/node_modules | |
| packages/webpack-plugin/node_modules | |
| packages/core/node_modules | |
| packages/api-proxy/node_modules | |
| packages/perf/node_modules | |
| packages/unocss-base/node_modules | |
| packages/unocss-plugin/node_modules | |
| key: ${{ runner.os }}-build-v2-${{ env.cache-name }}-${{ hashFiles('**/package.json') }} | |
| restore-keys: | | |
| ${{ runner.os }}-build-v2-${{ env.cache-name }}- | |
| ${{ runner.os }}-build-v2- | |
| ${{ runner.os }}- | |
| - name: install deps | |
| if: steps.cache.outputs.cache-hit != 'true' | |
| run: npm i && npm i --prefix test/e2e/miniprogram-project && npm i --prefix test/e2e/plugin-project | |
| - name: copy-webpack-plugin | |
| run: npm run copyPlugin --prefix test/e2e/miniprogram-project && npm run copyPlugin --prefix test/e2e/plugin-project | |
| - name: build-miniprogram | |
| run: npm run build:cross --prefix test/e2e/miniprogram-project | |
| - name: build-plugin | |
| run: npm run build --prefix test/e2e/plugin-project | |
| - name: build-tsc | |
| run: npm run build:tsc | |
| - name: exec unit test | |
| run: npm run test:base && npm t --prefix test/e2e/miniprogram-project && npm t --prefix test/e2e/plugin-project | |
| - name: exec RN component unit test | |
| if: steps.changes.outputs.rn_components == 'true' | |
| run: npm run test:react -w @mpxjs/webpack-plugin |