-
-
Notifications
You must be signed in to change notification settings - Fork 4
chore(ci): add test workflow #91
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
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
0aabb57
chore(ci): add test workflow
chenjiahan 5f2d776
fix(test): restore test suite compatibility
chenjiahan fa457ef
fix(test): skip watch cases on Windows
chenjiahan 9271af9
refactor(test): migrate tests to Rstest and Rspack
chenjiahan d8edc34
fix(ci): review core-js build script
chenjiahan 4ed9faf
refactor(test): migrate Rspack configs to ESM
chenjiahan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| name: Test | ||
|
|
||
| on: | ||
| pull_request: | ||
| branches: [main] | ||
| push: | ||
| branches: [main] | ||
| workflow_dispatch: | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| test: | ||
| runs-on: ${{ matrix.os }} | ||
| strategy: | ||
| matrix: | ||
| os: [ubuntu-latest, windows-latest] | ||
|
|
||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7 | ||
|
|
||
| - name: Setup Node.js | ||
| uses: actions/setup-node@249970729cb0ef3589644e2896645e5dc5ba9c38 # v6 | ||
| with: | ||
| node-version: 24.19.0 | ||
| package-manager-cache: false | ||
|
|
||
| - name: Install Pnpm | ||
| uses: pnpm/action-setup@0977fd99725f1db4007ccb2928dbb4e90d06cc86 # v6.0.10 | ||
| with: | ||
| run_install: true | ||
|
|
||
| - name: Run Test | ||
| run: node --run test | ||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,7 @@ | ||
| node_modules/ | ||
| /dist/ | ||
| /coverage/ | ||
| /examples/*/dist/ | ||
| npm-debug.*.log | ||
| yarn.lock | ||
| package-lock.json | ||
|
|
||
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
This file was deleted.
Oops, something went wrong.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| import { readdir, rm } from 'node:fs/promises'; | ||
| import path from 'node:path'; | ||
| import { fileURLToPath, pathToFileURL } from 'node:url'; | ||
| import { rspack, rspackVersion } from '@rspack/core'; | ||
|
|
||
| const examplesDirectory = fileURLToPath(new URL('.', import.meta.url)); | ||
| const rspackMajorVersion = rspackVersion.split('.')[0]; | ||
| const examples = (await readdir(examplesDirectory, { withFileTypes: true })) | ||
| .filter((entry) => entry.isDirectory()) | ||
| .map((entry) => entry.name); | ||
|
|
||
| async function buildExample(exampleName) { | ||
| const examplePath = path.join(examplesDirectory, exampleName); | ||
| const configUrl = pathToFileURL(path.join(examplePath, 'rspack.config.mjs')); | ||
| const { default: config } = await import(configUrl.href); | ||
|
|
||
| config.mode = 'production'; | ||
| config.optimization = config.optimization || {}; | ||
| config.optimization.minimizer = []; | ||
|
|
||
| await rm(path.join(examplePath, 'dist', `rspack-${rspackMajorVersion}`), { | ||
| force: true, | ||
| recursive: true, | ||
| }); | ||
|
|
||
| return new Promise((resolve, reject) => { | ||
| rspack(config, (error, stats) => { | ||
| if (error) { | ||
| reject(error); | ||
| return; | ||
| } | ||
|
|
||
| if (!stats || stats.hasErrors()) { | ||
| reject( | ||
| new Error( | ||
| stats | ||
| ? stats.toString({ colors: true }) | ||
| : 'Rspack did not return compilation stats.', | ||
| ), | ||
| ); | ||
| return; | ||
| } | ||
|
|
||
| resolve(); | ||
| }); | ||
| }); | ||
| } | ||
|
|
||
| try { | ||
| await Promise.all(examples.map(buildExample)); | ||
| } catch (error) { | ||
| console.error(error); | ||
| process.exitCode = 1; | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.