diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index dd7551aa9c27..9d5e49f8c70b 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -104,9 +104,9 @@ jobs: strategy: fail-fast: false matrix: - os: [ubuntu-latest] + os: [windows-latest] node: [22] - subset: [npm, esbuild] + subset: [npm] shard: [0, 1, 2, 3, 4, 5] runs-on: ${{ matrix.os }} steps: diff --git a/tests/legacy-cli/e2e/tests/build/rebuild-dot-dirname.ts b/tests/legacy-cli/e2e/tests/build/rebuild-dot-dirname.ts index 3a24ca0bcab5..a276a4189f86 100644 --- a/tests/legacy-cli/e2e/tests/build/rebuild-dot-dirname.ts +++ b/tests/legacy-cli/e2e/tests/build/rebuild-dot-dirname.ts @@ -18,7 +18,7 @@ export default async function () { try { process.chdir('./.subdirectory'); - await ng('new', 'subdirectory-test-project', '--skip-install'); + await ng('new', 'subdirectory-test-project', '--skip-install', '--skip-git'); process.chdir('./subdirectory-test-project'); await useSha(); diff --git a/tests/legacy-cli/e2e/utils/process.ts b/tests/legacy-cli/e2e/utils/process.ts index 5b7ad3d8dcd5..7767c1fe5ce1 100644 --- a/tests/legacy-cli/e2e/utils/process.ts +++ b/tests/legacy-cli/e2e/utils/process.ts @@ -3,7 +3,6 @@ import { spawn, SpawnOptions } from 'child_process'; import * as child_process from 'child_process'; import { concat, defer, EMPTY, from, lastValueFrom, catchError, repeat } from 'rxjs'; import { getGlobalVariable, getGlobalVariablesEnv } from './env'; -import treeKill from 'tree-kill'; import { delimiter, join, resolve } from 'path'; interface ExecOptions { @@ -232,29 +231,13 @@ export function waitForAnyProcessOutputToMatch( return Promise.race(matchPromises.concat([timeoutPromise])); } -export async function killAllProcesses(signal = 'SIGTERM'): Promise { - const processesToKill: Promise[] = []; - +export async function killAllProcesses(): Promise { while (_processes.length) { const childProc = _processes.pop(); - if (!childProc || childProc.pid === undefined) { - continue; + if (childProc && !childProc.killed) { + childProc.kill(); } - - processesToKill.push( - new Promise((resolve) => { - treeKill(childProc.pid!, signal, () => { - // Ignore all errors. - // This is due to a race condition with the `waitForMatch` logic. - // where promises are resolved on matches and not when the process terminates. - // Also in some cases in windows we get `The operation attempted is not supported`. - resolve(); - }); - }), - ); } - - await Promise.all(processesToKill); } export function exec(cmd: string, ...args: string[]) { diff --git a/tests/legacy-cli/e2e_runner.ts b/tests/legacy-cli/e2e_runner.ts index 507515219f6c..a40868594e0f 100644 --- a/tests/legacy-cli/e2e_runner.ts +++ b/tests/legacy-cli/e2e_runner.ts @@ -6,7 +6,7 @@ import * as path from 'path'; import { getGlobalVariable, setGlobalVariable } from './e2e/utils/env'; import { gitClean } from './e2e/utils/git'; import { createNpmRegistry } from './e2e/utils/registry'; -import { launchTestProcess } from './e2e/utils/process'; +import { killAllProcesses, launchTestProcess } from './e2e/utils/process'; import { delimiter, dirname, join } from 'path'; import { findFreePort } from './e2e/utils/network'; import { extractFile } from './e2e/utils/tar'; @@ -328,6 +328,8 @@ async function runTest(absoluteName: string): Promise { process.chdir(join(getGlobalVariable('projects-root'), 'test-project')); await launchTestProcess(absoluteName); + // Ensure that we kill all sub-processes of tests. (Such as `ng serve`). + await killAllProcesses(); await gitClean(); }