-
Notifications
You must be signed in to change notification settings - Fork 158
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
37 changed files
with
986 additions
and
892 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
name: Test (Ubuntu) | ||
|
||
# Controls when the action will run. | ||
on: | ||
# Triggers the workflow on pull request events but only for the main branch | ||
pull_request: | ||
branches: [main] | ||
|
||
push: | ||
branches: [main] | ||
paths: | ||
- "packages/doctor-*" | ||
paths-ignore: | ||
- "*.md" | ||
- "*.mdx" | ||
|
||
merge_group: | ||
|
||
# Allows you to run this workflow manually from the Actions tab | ||
workflow_dispatch: | ||
|
||
# A workflow run is made up of one or more jobs that can run sequentially or in parallel | ||
jobs: | ||
# ===== e2e for doctor ======= | ||
e2e-ubuntu-doctor: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
# Rsbuild need to compat Node.js 16 | ||
node-version: [16.x] | ||
|
||
# Steps represent a sequence of tasks that will be executed as part of the job | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 10 | ||
|
||
- name: Install Pnpm | ||
run: corepack enable | ||
|
||
- name: Check skip CI | ||
run: echo "RESULT=$(node ./scripts/skipCI.js)" >> "$GITHUB_OUTPUT" | ||
id: skip-ci | ||
|
||
- name: Log skip CI result | ||
run: echo "${{steps.skip-ci.outputs.RESULT}}" | ||
|
||
- name: Setup Node.js ${{ matrix.node-version }} | ||
if: ${{steps.skip-ci.outputs.RESULT != 'true'}} | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
cache: 'pnpm' | ||
|
||
- name: Install Dependencies | ||
if: ${{steps.skip-ci.outputs.RESULT != 'true'}} | ||
run: pnpm install && cd ./e2e && npx playwright install | ||
|
||
- name: E2E Test | ||
if: ${{steps.skip-ci.outputs.RESULT != 'true'}} | ||
run: pnpm run e2e:doctor |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
name: Test (Windows) | ||
|
||
# Controls when the action will run. | ||
on: | ||
# Triggers the workflow on pull request events but only for the main branch | ||
pull_request: | ||
branches: [main] | ||
|
||
push: | ||
branches: [main] | ||
paths: | ||
- "packages/doctor-*" | ||
paths-ignore: | ||
- "*.md" | ||
- "*.mdx" | ||
|
||
merge_group: | ||
|
||
# Allows you to run this workflow manually from the Actions tab | ||
workflow_dispatch: | ||
|
||
# A workflow run is made up of one or more jobs that can run sequentially or in parallel | ||
jobs: | ||
# ======== e2e for doctor======== | ||
e2e-windows-doctor: | ||
runs-on: windows-latest | ||
strategy: | ||
matrix: | ||
node-version: [18.x] | ||
|
||
# Steps represent a sequence of tasks that will be executed as part of the job | ||
steps: | ||
- name: Git config | ||
shell: bash | ||
run: | | ||
git config --system core.longpaths true | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 10 | ||
|
||
- name: Install Pnpm | ||
run: corepack enable | ||
|
||
- name: Check skip CI | ||
shell: bash | ||
run: echo "RESULT=$(node ./scripts/skipCI.js)" >> "$GITHUB_OUTPUT" | ||
id: skip-ci | ||
|
||
- name: Log skip CI result | ||
run: echo "${{steps.skip-ci.outputs.RESULT}}" | ||
|
||
- name: Setup Node.js ${{ matrix.node-version }} | ||
if: ${{steps.skip-ci.outputs.RESULT != 'true'}} | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
cache: 'pnpm' | ||
|
||
- name: Install Dependencies | ||
if: ${{steps.skip-ci.outputs.RESULT != 'true'}} | ||
run: pnpm install && cd ./e2e && npx playwright install | ||
|
||
- name: E2E Test | ||
if: ${{steps.skip-ci.outputs.RESULT != 'true'}} | ||
run: pnpm run e2e:doctor |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
import { expect, test } from '@playwright/test'; | ||
import { getSDK } from '@rsbuild/doctor-core/plugins'; | ||
import { compileByRspack } from '@rsbuild/test-helper'; | ||
import { Compiler } from '@rspack/core'; | ||
import os from 'os'; | ||
import path from 'path'; | ||
import { createDoctorPlugin } from './test-utils'; | ||
|
||
async function rspackCompile(tapName: string, compile: typeof compileByRspack) { | ||
const file = path.resolve(__dirname, './fixtures/a.js'); | ||
const loader = path.resolve(__dirname, './fixtures/loaders/comment.js'); | ||
const res = await compile(file, { | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.js/, | ||
use: loader, | ||
}, | ||
], | ||
}, | ||
plugins: [ | ||
// @ts-ignore | ||
createDoctorPlugin({}), | ||
{ | ||
name: tapName, | ||
apply(compiler: Compiler) { | ||
compiler.hooks.done.tapPromise(tapName, async () => { | ||
// nothing | ||
}); | ||
compiler.hooks.thisCompilation.tap(tapName, (compilation) => { | ||
compilation.hooks.processAssets.tap(tapName, () => { | ||
return 'processAssets end'; | ||
}); | ||
}); | ||
}, | ||
}, | ||
], | ||
}); | ||
|
||
return res; | ||
} | ||
|
||
test('rspack plugin intercept', async () => { | ||
const tapName = 'XXX'; | ||
await rspackCompile(tapName, compileByRspack); | ||
const sdk = getSDK(); | ||
const { done, thisCompilation } = sdk.getStoreData().plugin; | ||
const doneData = done.filter((e) => e.tapName === tapName); | ||
expect(doneData).toHaveLength(1); | ||
expect(doneData[0].type).toEqual('promise'); | ||
expect(doneData[0].result).toBeNull(); | ||
|
||
const sealData = thisCompilation.filter((e) => e.tapName === tapName); | ||
expect(sealData).toHaveLength(1); | ||
expect(sealData[0].type).toEqual('sync'); | ||
expect(sealData[0].result).toBeNull(); | ||
}); | ||
|
||
test('rspack data store', async () => { | ||
const tapName = 'XXX'; | ||
await rspackCompile(tapName, compileByRspack); | ||
const sdk = getSDK(); | ||
const datas = sdk.getStoreData(); | ||
expect(datas.errors.length).toBe(0); | ||
const graphData = datas.moduleGraph; | ||
|
||
os.EOL === '\n' | ||
? expect( | ||
graphData.modules[0].webpackId.indexOf('tests/fixtures/a.js'), | ||
).toBeGreaterThan(0) | ||
: expect( | ||
graphData.modules[0].webpackId.indexOf('\\tests\\fixtures\\a.js'), | ||
).toBeGreaterThan(0); | ||
|
||
graphData.modules.forEach((mod) => (mod.webpackId = '')); | ||
expect(graphData.modules[0].size).toEqual({ | ||
sourceSize: 33, | ||
transformedSize: 33, | ||
parsedSize: 0, | ||
}); | ||
expect(graphData.modules[0].path).toMatch('tests/fixtures/a.js'); | ||
}); |
This file contains 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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Oops, something went wrong.