diff --git a/.github/workflows/build_test_deploy.yml b/.github/workflows/build_test_deploy.yml index 3b437677a4bd..36cf13f4807b 100644 --- a/.github/workflows/build_test_deploy.yml +++ b/.github/workflows/build_test_deploy.yml @@ -1245,6 +1245,47 @@ jobs: run: cd packages/next-swc && cargo nextest run -p next-dev-tests --release --no-fail-fast if: ${{needs.build.outputs.docsChange == 'nope'}} + test-bench-native-integration: + name: Bench Integration Test Native Code + runs-on: ubuntu-latest-16-core-oss + needs: build + + env: + CARGO_PROFILE_RELEASE_LTO: false + TURBOPACK_BENCH_COUNTS: 10 + TURBOPACK_BENCH_CACHED: 1 + TURBOPACK_BENCH_PROGRESS: 1 + + steps: + - uses: actions/cache@v3 + timeout-minutes: 5 + id: restore-build + with: + path: ./* + key: ${{ github.sha }}-${{ github.run_number }} + + - run: echo "${{needs.build.outputs.docsChange == 'nope'}}" + + - name: Install Rust toolchain + if: ${{needs.build.outputs.docsChange == 'nope'}} + uses: actions-rs/toolchain@v1 + with: + toolchain: ${{ env.RUST_TOOLCHAIN }} + profile: minimal + + - name: Install nextest + uses: taiki-e/install-action@nextest + + - name: Build tests + timeout-minutes: 60 + run: cd packages/next-swc && cargo test --benches -p next-dev --release --no-run + if: ${{needs.build.outputs.docsChange == 'nope'}} + + - name: Run tests + timeout-minutes: 60 + run: cd packages/next-swc && cargo test --benches -p next-dev --release --no-fail-fast + if: ${{needs.build.outputs.docsChange == 'nope'}} + test-wasm: name: Test the wasm build runs-on: ubuntu-latest diff --git a/packages/next-swc/crates/next-core/js/src/ipc/index.ts b/packages/next-swc/crates/next-core/js/src/ipc/index.ts index e50096854cdb..f664d92644c9 100644 --- a/packages/next-swc/crates/next-core/js/src/ipc/index.ts +++ b/packages/next-swc/crates/next-core/js/src/ipc/index.ts @@ -83,6 +83,12 @@ function createIpc( } }) }) + // When the socket is closed, this process is no longer needed. + // This might happen e. g. when parent process is killed or + // node.js pool is garbage collected. + socket.once('close', () => { + process.exit(0) + }) function send(message: any): Promise { const packet = Buffer.from(JSON.stringify(message), 'utf8') diff --git a/packages/next-swc/crates/next-dev/benches/bundlers/turbopack/mod.rs b/packages/next-swc/crates/next-dev/benches/bundlers/turbopack/mod.rs index 9b25f494d51d..0547f0366a73 100644 --- a/packages/next-swc/crates/next-dev/benches/bundlers/turbopack/mod.rs +++ b/packages/next-swc/crates/next-dev/benches/bundlers/turbopack/mod.rs @@ -46,15 +46,17 @@ impl Bundler for Turbopack { } fn prepare(&self, install_dir: &Path) -> Result<()> { - npm::install( - install_dir, - &[ - NpmPackage::new("next", "13.2.4-canary.7"), - // Dependency on this is inserted by swc's preset_env - NpmPackage::new("@swc/helpers", "^0.4.11"), - ], - ) - .context("failed to install from npm")?; + let package_json = include_str!("../../../../../../next/package.json"); + let data: serde_json::Value = serde_json::from_str(package_json)?; + let version = data + .as_object() + .unwrap() + .get("version") + .unwrap() + .as_str() + .unwrap(); + npm::install(install_dir, &[NpmPackage::new("next", version)]) + .context("failed to install from npm")?; fs::write( install_dir.join("next.config.js"), diff --git a/packages/next-swc/crates/next-dev/benches/util/npm.rs b/packages/next-swc/crates/next-dev/benches/util/npm.rs index 6ea2533051c3..1ba159a96279 100644 --- a/packages/next-swc/crates/next-dev/benches/util/npm.rs +++ b/packages/next-swc/crates/next-dev/benches/util/npm.rs @@ -9,24 +9,24 @@ use serde_json::json; use crate::util::command; -pub struct NpmPackage { - pub name: &'static str, - pub version: &'static str, +pub struct NpmPackage<'a> { + pub name: &'a str, + pub version: &'a str, } -impl NpmPackage { - pub fn new(name: &'static str, version: &'static str) -> Self { +impl<'a> NpmPackage<'a> { + pub fn new(name: &'a str, version: &'a str) -> Self { NpmPackage { name, version } } } -impl std::fmt::Display for NpmPackage { +impl<'a> std::fmt::Display for NpmPackage<'a> { fn fmt(&self, fmt: &mut std::fmt::Formatter) -> std::fmt::Result { fmt.write_fmt(format_args!("{}@{}", self.name, self.version)) } } -pub fn install(install_dir: &Path, packages: &[NpmPackage]) -> Result<()> { +pub fn install(install_dir: &Path, packages: &[NpmPackage<'_>]) -> Result<()> { if !fs::metadata(install_dir.join("package.json")) .map(|metadata| metadata.is_file()) .unwrap_or(false)