From 2cf8a5b0eb2eaee4899cb2568c260ecda1a38c2a Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Wed, 25 Oct 2023 16:19:35 +0200 Subject: [PATCH] Build the node package only once in debug In the ci and on workstations the steps are the same: 1. Install (without building, which would build release) 2. Build debug 3. Run tests Previously only on Windows the tests were run in debug, because the "npm install" step in the nodejs test driver would overwrite a previously created debug build. On windows they are separate DLLs, and thus co-exist. With this patch we always build debug. --- .github/workflows/ci.yaml | 8 ++++---- tests/driver/nodejs/nodejs.rs | 14 +++++++++++++- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 2430d9746..c1a4a28fb 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -128,13 +128,13 @@ jobs: key: x-napi-v2-${{ steps.node-install.outputs.node-version }} # the cache key consists of a manually bumpable version and the node version, as the cached rustc artifacts contain linking information where to find node.lib, which is in a versioned directory. - name: Run npm install working-directory: ./api/node - run: npm install - - name: Typescript check - working-directory: ./api/node - run: npm run syntax_check + run: npm install --ignore-scripts - name: Build node plugin in debug run: npm run build:debug working-directory: ./api/node + - name: Typescript check + working-directory: ./api/node + run: npm run syntax_check - name: Run node tests working-directory: ./api/node run: npm test diff --git a/tests/driver/nodejs/nodejs.rs b/tests/driver/nodejs/nodejs.rs index deda54160..5dba02f1d 100644 --- a/tests/driver/nodejs/nodejs.rs +++ b/tests/driver/nodejs/nodejs.rs @@ -12,16 +12,28 @@ lazy_static::lazy_static! { // it tries to emulate CreateProcess. let npm = which::which("npm").unwrap(); - // builds and installs the slint node package + // installs the slint node package dependencies std::process::Command::new(npm.clone()) .arg("install") .arg("--no-audit") + .arg("--ignore-scripts") .current_dir(node_dir.clone()) .stdout(std::process::Stdio::piped()) .stderr(std::process::Stdio::piped()) .output() .map_err(|err| format!("Could not launch npm install: {}", err)).unwrap(); + // builds the slint node package in debug + std::process::Command::new(npm.clone()) + .arg("run") + .arg("build:debug") + .current_dir(node_dir.clone()) + .stdout(std::process::Stdio::piped()) + .stderr(std::process::Stdio::piped()) + .output() + .map_err(|err| format!("Could not launch npm install: {}", err)).unwrap(); + + node_dir.join("index.js") }; }