Skip to content
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

Run bench tests as part of CI #47849

Merged
merged 7 commits into from Apr 5, 2023
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
41 changes: 41 additions & 0 deletions .github/workflows/build_test_deploy.yml
Expand Up @@ -1244,6 +1244,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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sokra This fails when we publish a new version

npm ERR! notarget No matching version found for next@13.3.1.

https://github.com/vercel/next.js/actions/runs/4769164009/jobs/8479317012#step:7:21

Should we skip in that case?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it's currently using the latest canary in benchmarks. So it's failing during publish since the version in package.json is already incremented but it's not yet published.
We need to improve that to use the local packaged build of next.js instead, but i was too lazy for that...

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
sokra marked this conversation as resolved.
Show resolved Hide resolved
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
Expand Down
6 changes: 6 additions & 0 deletions packages/next-swc/crates/next-core/js/src/ipc/index.ts
Expand Up @@ -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> {
const packet = Buffer.from(JSON.stringify(message), 'utf8')
Expand Down
Expand Up @@ -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"),
Expand Down
14 changes: 7 additions & 7 deletions packages/next-swc/crates/next-dev/benches/util/npm.rs
Expand Up @@ -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)
Expand Down