Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,7 @@ jobs:
strategy:
fail-fast: false
matrix:
# These tests can generate a significant amount of temp files, especially when
# flaky targets are retried. The larger machine type comes with 2x more SSD space.
os: [ubuntu-latest-4core]
os: [ubuntu-latest]
node: [22]
subset: [yarn, pnpm]
shard: [0, 1, 2]
Expand Down
4 changes: 1 addition & 3 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -178,9 +178,7 @@ jobs:
strategy:
fail-fast: false
matrix:
# These tests can generate a significant amount of temp files, especially when
# flaky targets are retried. The larger machine type comes with 2x more SSD space.
os: [ubuntu-latest-4core]
os: [ubuntu-latest]
node: [22]
subset: [yarn, pnpm]
shard: [0, 1, 2]
Expand Down
12 changes: 7 additions & 5 deletions tests/legacy-cli/e2e/utils/assets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { getGlobalVariable } from './env';
import { resolve } from 'node:path';
import { copyFile } from './fs';
import { installWorkspacePackages, setRegistry } from './packages';
import { useBuiltPackagesVersions } from './project';
import { getTestProjectDir, useBuiltPackagesVersions } from './project';

export function assetDir(assetName: string) {
return join(__dirname, '../e2e/assets', assetName);
Expand All @@ -21,7 +21,7 @@ export function copyProjectAsset(assetName: string, to?: string) {

export function copyAssets(assetName: string, to?: string) {
const seed = +Date.now();
const tempRoot = join(getGlobalVariable('projects-root'), 'assets', assetName + '-' + seed);
const tempRoot = join(getTestAssetsDir(), assetName + '-' + seed);
const root = assetDir(assetName);

return Promise.resolve()
Expand All @@ -30,9 +30,7 @@ export function copyAssets(assetName: string, to?: string) {

return allFiles.reduce((promise, filePath) => {
const toPath =
to !== undefined
? resolve(getGlobalVariable('projects-root'), 'test-project', to, filePath)
: join(tempRoot, filePath);
to !== undefined ? resolve(getTestProjectDir(), to, filePath) : join(tempRoot, filePath);

return promise
.then(() => copyFile(join(root, filePath), toPath))
Expand Down Expand Up @@ -65,3 +63,7 @@ export async function createProjectFromAsset(

return () => setRegistry(true /** useTestRegistry */);
}

export function getTestAssetsDir(): string {
return join(getGlobalVariable('projects-root'), 'assets');
}
5 changes: 5 additions & 0 deletions tests/legacy-cli/e2e/utils/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { gitCommit } from './git';
import { findFreePort } from './network';
import { installWorkspacePackages, PkgInfo } from './packages';
import { execAndWaitForOutputToMatch, git, ng } from './process';
import { join } from 'node:path';

export function updateJsonFile(filePath: string, fn: (json: any) => any | void) {
return readFile(filePath).then((tsConfigJson) => {
Expand Down Expand Up @@ -270,3 +271,7 @@ export function updateServerFileForEsbuild(filepath: string): Promise<void> {
`,
);
}

export function getTestProjectDir(): string {
return join(getGlobalVariable('projects-root'), 'test-project');
}
15 changes: 12 additions & 3 deletions tests/legacy-cli/e2e_runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import colors from 'ansi-colors';
import glob from 'fast-glob';
import * as path from 'node:path';
import * as fs from 'node:fs';
import { rm } from 'node:fs/promises';
import { getGlobalVariable, setGlobalVariable } from './e2e/utils/env';
import { gitClean } from './e2e/utils/git';
import { createNpmRegistry } from './e2e/utils/registry';
Expand All @@ -13,7 +14,7 @@ import { findFreePort } from './e2e/utils/network';
import { extractFile } from './e2e/utils/tar';
import { realpathSync } from 'node:fs';
import { PkgInfo } from './e2e/utils/packages';
import { rm } from 'node:fs/promises';
import { getTestProjectDir } from './e2e/utils/project';

Error.stackTraceLimit = Infinity;

Expand Down Expand Up @@ -271,6 +272,14 @@ Promise.all([findFreePort(), findFreePort(), findPackageTars()])
} finally {
registryProcess.kill();
secureRegistryProcess.kill();

await rm(getGlobalVariable('projects-root'), {
recursive: true,
force: true,
maxRetries: 3,
}).catch(() => {
// If this fails it is not fatal.
});
}
})
.catch((err) => {
Expand Down Expand Up @@ -334,7 +343,7 @@ function runInitializer(absoluteName: string): Promise<void> {
* Run a file from the main 'test-project' directory in a subprocess via launchTestProcess().
*/
async function runTest(absoluteName: string): Promise<void> {
process.chdir(join(getGlobalVariable('projects-root'), 'test-project'));
process.chdir(getTestProjectDir());

await launchTestProcess(absoluteName);
await cleanTestProject();
Expand All @@ -343,7 +352,7 @@ async function runTest(absoluteName: string): Promise<void> {
async function cleanTestProject() {
await gitClean();

const testProject = join(getGlobalVariable('projects-root'), 'test-project');
const testProject = getTestProjectDir();

// Note: Dist directory is not cleared between tests, as `git clean`
// doesn't delete it.
Expand Down
Loading