Unverified Commit e643d52e authored by Tobias Koppers's avatar Tobias Koppers Committed by GitHub

Run bench tests as part of CI (#47849)

### What?

enables the benchmark tests from turbopack again

### Why?

It tests common scenarios like HMR

fixes WEB-792

---------
Co-authored-by: 's avatarAlex Kirszenberg <alex.kirszenberg@vercel.com>
parent 89b4605f
...@@ -1245,6 +1245,47 @@ jobs: ...@@ -1245,6 +1245,47 @@ jobs:
run: cd packages/next-swc && cargo nextest run -p next-dev-tests --release --no-fail-fast run: cd packages/next-swc && cargo nextest run -p next-dev-tests --release --no-fail-fast
if: ${{needs.build.outputs.docsChange == 'nope'}} 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: test-wasm:
name: Test the wasm build name: Test the wasm build
runs-on: ubuntu-latest runs-on: ubuntu-latest
......
...@@ -83,6 +83,12 @@ function createIpc<TIncoming, TOutgoing>( ...@@ -83,6 +83,12 @@ function createIpc<TIncoming, TOutgoing>(
} }
}) })
}) })
// 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<void> { function send(message: any): Promise<void> {
const packet = Buffer.from(JSON.stringify(message), 'utf8') const packet = Buffer.from(JSON.stringify(message), 'utf8')
......
...@@ -46,15 +46,17 @@ impl Bundler for Turbopack { ...@@ -46,15 +46,17 @@ impl Bundler for Turbopack {
} }
fn prepare(&self, install_dir: &Path) -> Result<()> { fn prepare(&self, install_dir: &Path) -> Result<()> {
npm::install( let package_json = include_str!("../../../../../../next/package.json");
install_dir, let data: serde_json::Value = serde_json::from_str(package_json)?;
&[ let version = data
NpmPackage::new("next", "13.2.4-canary.7"), .as_object()
// Dependency on this is inserted by swc's preset_env .unwrap()
NpmPackage::new("@swc/helpers", "^0.4.11"), .get("version")
], .unwrap()
) .as_str()
.context("failed to install from npm")?; .unwrap();
npm::install(install_dir, &[NpmPackage::new("next", version)])
.context("failed to install from npm")?;
fs::write( fs::write(
install_dir.join("next.config.js"), install_dir.join("next.config.js"),
......
...@@ -9,24 +9,24 @@ use serde_json::json; ...@@ -9,24 +9,24 @@ use serde_json::json;
use crate::util::command; use crate::util::command;
pub struct NpmPackage { pub struct NpmPackage<'a> {
pub name: &'static str, pub name: &'a str,
pub version: &'static str, pub version: &'a str,
} }
impl NpmPackage { impl<'a> NpmPackage<'a> {
pub fn new(name: &'static str, version: &'static str) -> Self { pub fn new(name: &'a str, version: &'a str) -> Self {
NpmPackage { name, version } 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 { fn fmt(&self, fmt: &mut std::fmt::Formatter) -> std::fmt::Result {
fmt.write_fmt(format_args!("{}@{}", self.name, self.version)) 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")) if !fs::metadata(install_dir.join("package.json"))
.map(|metadata| metadata.is_file()) .map(|metadata| metadata.is_file())
.unwrap_or(false) .unwrap_or(false)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment