Skip to content

chore(wasm): enable wasm test ci #10757

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 33 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
fea5e23
Disable other tests
CPunisher Jun 23, 2025
3fa090b
Enable wasm test
CPunisher Jun 23, 2025
9e3dd8f
Disable test_required_check
CPunisher Jun 23, 2025
e5d07c5
Suppress warnings
CPunisher Jun 23, 2025
6f3b35e
Suppress warnings
CPunisher Jun 23, 2025
f71113d
Revert ci
CPunisher Jun 23, 2025
ea88864
Add timeout for @rspack/cli
CPunisher Jun 23, 2025
cabe4bf
Skip profile in @rspack/cli
CPunisher Jun 23, 2025
a8437fc
Skip snapshots in @rspack/test-tools
CPunisher Jun 23, 2025
85c7790
Skip Error in @rspack/test-tools
CPunisher Jun 23, 2025
92dd07a
use u64 hash
CPunisher Jun 23, 2025
09f3381
use node 20 for wasm
CPunisher Jun 24, 2025
5538575
Skip Diagnotics in @rspack/test-tools
CPunisher Jun 24, 2025
1fedd54
Fix clippy
CPunisher Jun 24, 2025
94a85cb
Skip StatsAPI
CPunisher Jun 25, 2025
614b6c2
Revert "Fix clippy"
CPunisher Jun 25, 2025
f790ea1
Revert "use u64 hash"
CPunisher Jun 25, 2025
da788c3
Setup wasm to skip snapshots
CPunisher Jun 25, 2025
d39684e
Wasm skips
CPunisher Jun 25, 2025
26a9a05
Ts ignore
CPunisher Jun 25, 2025
ccdd2ac
Test: disable watch concurrent
CPunisher Jun 25, 2025
90266b9
Disable concurrent watch in wasm
CPunisher Jun 25, 2025
4da8a31
Temporarily skip watch and hot
CPunisher Jun 26, 2025
89a1d5d
Disable concurrent mode for wasm
CPunisher Jun 26, 2025
36e8b60
Skip swc plugin, browserslist, pnpm related tests
CPunisher Jun 26, 2025
c6e3415
Skip timeout
CPunisher Jun 26, 2025
0986445
Fix
CPunisher Jun 26, 2025
f974dee
passWithNoTests
CPunisher Jun 26, 2025
a0aa60e
Max worker = 1
CPunisher Jun 26, 2025
5efcc49
Max concurrency = 1
CPunisher Jun 26, 2025
04bfc33
Debugger
CPunisher Jun 26, 2025
483ecb8
Force exit
CPunisher Jun 26, 2025
da7b9cc
Build dev
CPunisher Jun 26, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ jobs:
target: wasm32-wasip1-threads
profile: "ci"
runner: ${{ vars.LINUX_SELF_HOSTED_RUNNER_LABELS || '"ubuntu-22.04"' }}
test: false
test: true

check-codspeed:
name: Check Bench Result
Expand All @@ -118,7 +118,15 @@ jobs:
# When code changed, it will check if any of the test jobs failed.
# When *only* doc changed, it will run as success directly
name: Test Required Check
needs: [check-codspeed, test-linux, test-windows, test-mac, check-changed]
needs:
[
check-codspeed,
test-linux,
test-windows,
test-mac,
test-wasm,
check-changed
]
if: ${{ always() && !cancelled() }}
runs-on: ubuntu-latest
steps:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/reusable-build-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ jobs:
if: ${{ inputs.target == 'wasm32-wasip1-threads' }}
run: |
unset CC_x86_64_unknown_linux_gnu && unset CC # for jemallocator to compile
DISABLE_PLUGIN=1 RUST_TARGET=wasm32-wasip1-threads pnpm --filter @rspack/binding build:${{ inputs.profile }}
DISABLE_PLUGIN=1 RUST_TARGET=wasm32-wasip1-threads pnpm --filter @rspack/binding build:dev

- name: Diff artifact
run: |
Expand Down
16 changes: 15 additions & 1 deletion .github/workflows/reusable-build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,12 @@ jobs:
strategy:
fail-fast: true # for better utilize ci runners
matrix:
node: ${{ fromJSON(contains(inputs.target, 'linux') && github.ref_name == 'main' && '[16, 18, 20]' || '[18]' )}}
node: ${{ fromJSON(
inputs.target == 'wasm32-wasip1-threads'
&& '[20]'
|| (contains(inputs.target, 'linux') && github.ref_name == 'main'
&& '[16, 18, 20]'
|| '[18]') )}}
name: Test Node ${{ matrix.node }}
defaults:
run:
Expand Down Expand Up @@ -128,6 +133,15 @@ jobs:
if: ${{ inputs.target == 'x86_64-pc-windows-msvc' }}
run: pnpm run test:ci

### WASM
- name: Test WASM
timeout-minutes: 15 # Tests should finish within 15 mins, please fix your tests instead of changing this to a higher timeout.
if: ${{ inputs.target == 'wasm32-wasip1-threads' }}
run: |
export NODE_NO_WARNINGS=1
export WASM=1
pnpm run test:ci

### write the latest metric into branch gh-pages
### Note that, We can't merge this script, because this script only runs on main branch
### [Note] This step requires push permission and should be refactored.
Expand Down
10 changes: 9 additions & 1 deletion packages/rspack-cli/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
/** @type {import('ts-jest/dist/types').JestConfigWithTsJest} */
const wasmConfig = process.env.WASM && {
testPathIgnorePatterns: ["profile.test.ts"],
maxWorkers: 1,
maxConcurrency: 1
};

/** @type {import('ts-jest/dist/types').JestConfigWithTsJest} */
const config = {
preset: "ts-jest",
Expand All @@ -10,7 +17,8 @@ const config = {
"^.+\\.(ts)?$": ["ts-jest", { tsconfig: "<rootDir>/tests/tsconfig.json" }]
},
cache: false,
prettierPath: require.resolve("prettier-2")
prettierPath: require.resolve("prettier-2"),
...(wasmConfig || {})
};

module.exports = config;
32 changes: 26 additions & 6 deletions packages/rspack-test-tools/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,32 @@
const path = require("node:path");

const root = path.resolve(__dirname, "../../");

const setupFilesAfterEnv = [
"@rspack/test-tools/setup-expect",
"@rspack/test-tools/setup-env"
];

/** @type {import('jest').Config} */
const wasmConfig = process.env.WASM && {
setupFilesAfterEnv: [...setupFilesAfterEnv, "@rspack/test-tools/setup-wasm"],
passWithNoTests: true,
testPathIgnorePatterns: [
"Diagnostics.test.js",
"Error.test.js",
"StatsAPI.test.js",
"StatsOutput.test.js",
"Cache.test.js"
],
maxWorkers: 1,
maxConcurrency: 1,
detectOpenHandles: true,
forceExit: true
};

/** @type {import('jest').Config} */
const config = {
testEnvironment: "../../scripts/test/patch-node-env.cjs",
setupFilesAfterEnv: [
"@rspack/test-tools/setup-expect",
"@rspack/test-tools/setup-env"
],
setupFilesAfterEnv,
reporters: [
["../../scripts/test/ignore-snapshot-default-reporter.cjs", null],
"../../scripts/test/ignore-snapshot-summary-reporter.cjs"
Expand Down Expand Up @@ -43,7 +62,8 @@ const config = {
]
: undefined,
printLogger: process.argv.includes("--verbose")
}
},
...(wasmConfig || {})
};

module.exports = config;
1 change: 1 addition & 0 deletions packages/rspack-test-tools/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
},
"./setup-expect": "./dist/helper/setup-expect.js",
"./setup-env": "./dist/helper/setup-env.js",
"./setup-wasm": "./dist/helper/setup-wasm.js",
"./package.json": "./package.json"
},
"scripts": {
Expand Down
37 changes: 37 additions & 0 deletions packages/rspack-test-tools/src/helper/setup-wasm.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
function toMatchSnapshot() {
return { pass: true, message: () => "" };
}

function toMatchInlineSnapshot() {
return { pass: true, message: () => "" };
}

function toMatchFileSnapshot() {
return { pass: true, message: () => "" };
}

expect.extend({
toMatchSnapshot,
toMatchInlineSnapshot,
toMatchFileSnapshot
});

// @ts-ignore
globalThis.WasmSkips = {
Normals: [/pnpm-workspace/],
Compilers: [
/swc-api/,
// Unknowntimeout (only in ci)
/persist-build-inf/,
/single-file/
],
Defaults: [/browserslist/],
Configs: [
/swc-loader-incompatible-wasm-plugin/,
/swc-plugin/,
/browserslist-config-env/,
/pnp-enable/,
// Unknown long string
/loader-raw-string/
]
};
6 changes: 3 additions & 3 deletions packages/rspack-test-tools/src/test/creator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ export class BasicCaseCreator<T extends ECompilerType> {

const run = this.shouldRun(name);
const tester = this.createTester(name, src, dist, temp, testConfig);
const concurrent =
testConfig.concurrent ?? this._options.concurrent ?? false;

const concurrent = process.env.WASM
? false
: testConfig.concurrent || this._options.concurrent;
if (this._options.describe) {
if (run) {
if (concurrent) {
Expand Down
3 changes: 2 additions & 1 deletion packages/rspack-test-tools/tests/Compiler.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ describeByWalk(
},
{
level: 1,
type: "file"
type: "file",
exclude: globalThis.WasmSkips?.Compilers || []
}
);
12 changes: 9 additions & 3 deletions packages/rspack-test-tools/tests/Config.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
const { describeByWalk, createConfigCase } = require("..");

describeByWalk(__filename, (name, src, dist) => {
createConfigCase(name, src, dist);
});
describeByWalk(
__filename,
(name, src, dist) => {
createConfigCase(name, src, dist);
},
{
exclude: globalThis.WasmSkips?.Configs || []
}
);
3 changes: 2 additions & 1 deletion packages/rspack-test-tools/tests/Defaults.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ describeByWalk(
createDefaultsCase(name, src);
},
{
type: "file"
type: "file",
exclude: globalThis.WasmSkips?.Defaults || []
}
);
12 changes: 9 additions & 3 deletions packages/rspack-test-tools/tests/Normal.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
const { createNormalCase, describeByWalk } = require("..");

describeByWalk(__filename, (name, src, dist) => {
createNormalCase(name, src, dist);
});
describeByWalk(
__filename,
(name, src, dist) => {
createNormalCase(name, src, dist);
},
{
exclude: globalThis.WasmSkips?.Normals || []
}
);
Loading