Skip to content
Merged
Changes from 1 commit
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
17 changes: 14 additions & 3 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,9 @@ async function installPackagesAndGetCommands(
repoDir: string,
monorepoPackages: readonly string[],
cleanOnFailure: boolean,
diagnosticOutput: boolean): Promise<ip.InstallCommand[] | undefined> {
diagnosticOutput: boolean,
gitAddInstalled: boolean,
): Promise<ip.InstallCommand[] | undefined> {
const packageInstallStart = performance.now();
try {
console.log("Installing packages if absent");
Expand All @@ -178,6 +180,11 @@ async function installPackagesAndGetCommands(
/*monorepoPackages*/ monorepoPackages,
repo.types);
await installPackages(repoDir, commands, packageTimeout);
if (gitAddInstalled) {
// Force add all of the ignored files we just installed so we can git clean to go back to this state later.
console.log("Staging all installed files");
await execAsync(repoDir, "git add --force .");
Copy link
Member Author

Choose a reason for hiding this comment

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

On second thought, I should probably just move this out into the tsc runner.

}
return commands;
}
catch (err) {
Expand Down Expand Up @@ -223,7 +230,7 @@ async function getTsServerRepoResult(

// Presumably, people occasionally browse repos without installing the packages first
const installCommands = (prng.random() > 0.2) && monorepoPackages
? (await installPackagesAndGetCommands(repo, downloadDir, repoDir, monorepoPackages, /*cleanOnFailure*/ true, diagnosticOutput))!
? (await installPackagesAndGetCommands(repo, downloadDir, repoDir, monorepoPackages, /*cleanOnFailure*/ true, diagnosticOutput, /*gitAddInstalled*/ false))!
: [];

const replayScriptName = path.basename(replayScriptArtifactPath);
Expand Down Expand Up @@ -510,7 +517,7 @@ export async function getTscRepoResult(
const repoDir = path.join(downloadDir, repo.name);
const monorepoPackages = await getMonorepoPackages(repoDir);

if (!monorepoPackages || !await installPackagesAndGetCommands(repo, downloadDir, repoDir, monorepoPackages, /*cleanOnFailure*/ false, diagnosticOutput)) {
if (!monorepoPackages || !await installPackagesAndGetCommands(repo, downloadDir, repoDir, monorepoPackages, /*cleanOnFailure*/ false, diagnosticOutput, /*gitAddInstalled*/ true)) {
return { status: "Package install failed" };
}

Expand Down Expand Up @@ -558,6 +565,10 @@ export async function getTscRepoResult(
summary += `**${oldFailuresMessage}**\n`;
}

console.log("Restoring repo");
await execAsync(repoDir, "git restore .");
await execAsync(repoDir, "git clean -xdff");

console.log(`Building with ${newTscPath} (new)`);
const newErrors = await ge.buildAndGetErrors(repoDir, monorepoPackages, isUserTestRepo, newTscPath, executionTimeout, /*skipLibCheck*/ true);

Expand Down