Skip to content

Commit

Permalink
Revert replay file and added replay script location (#159)
Browse files Browse the repository at this point in the history
* Revert "Download replay file instead of RepoResult.zip file (#158)"

This reverts commit b8f135a.

* Added Replay script location as text

---------

Co-authored-by: Armando Aguirre Sepulveda <araguir@microsoft.com>
  • Loading branch information
armanio123 and armanio123 authored May 21, 2024
1 parent b8f135a commit f600628
Show file tree
Hide file tree
Showing 12 changed files with 44 additions and 437 deletions.
4 changes: 2 additions & 2 deletions azure-pipelines-gitTests-template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ jobs:
npm run build
npm install -g pnpm
mkdir 'RepoResults$(System.JobPositionInPhase)'
node dist/checkGithubRepos ${{ parameters.ENTRYPOINT }} ${{ parameters.OLD_VERSION }} ${{ parameters.NEW_VERSION }} '$(Pipeline.Workspace)/RepoList/repos.json' $(System.TotalJobsInPhase) $(System.JobPositionInPhase) 'RepoResults$(System.JobPositionInPhase)' ${{ parameters.DIAGNOSTIC_OUTPUT }} ${{ parameters.PRNG_SEED }} $(Build.BuildId) '$(System.TeamFoundationCollectionUri)' '$(System.TeamProject)'
node dist/checkGithubRepos ${{ parameters.ENTRYPOINT }} ${{ parameters.OLD_VERSION }} ${{ parameters.NEW_VERSION }} '$(Pipeline.Workspace)/RepoList/repos.json' $(System.TotalJobsInPhase) $(System.JobPositionInPhase) 'RepoResults$(System.JobPositionInPhase)' ${{ parameters.DIAGNOSTIC_OUTPUT }} ${{ parameters.PRNG_SEED }}
displayName: 'Run TypeScript on repos'
continueOnError: true
env:
Expand All @@ -91,7 +91,7 @@ jobs:
- script: |
npm ci
npm run build
node dist/postGithubIssue ${{ parameters.ENTRYPOINT }} ${{ parameters.LANGUAGE }} ${{ parameters.REPO_COUNT }} ${{ parameters.REPO_START_INDEX }} '$(Pipeline.Workspace)' '$(System.TeamFoundationCollectionUri)$(System.TeamProject)/_build/results?buildId=$(Build.BuildId)' '$(System.TeamFoundationCollectionUri)$(System.TeamProject)/_build/results?buildId=$(Build.BuildId)&view=artifacts&type=publishedArtifacts' ${{ parameters.POST_RESULT }}
node dist/postGithubIssue ${{ parameters.ENTRYPOINT }} ${{ parameters.LANGUAGE }} ${{ parameters.REPO_COUNT }} ${{ parameters.REPO_START_INDEX }} '$(Pipeline.Workspace)' '$(System.TeamFoundationCollectionUri)$(System.TeamProject)/_build/results?buildId=$(Build.BuildId)' '$(System.TeamFoundationCollectionUri)$(System.TeamProject)/_build/results?buildId=$(Build.BuildId)&view=artifacts&type=publishedArtifacts' ${{ parameters.POST_RESULT }} '$(System.TeamFoundationCollectionUri)$(System.TeamProject)/_apis/build/builds/$(Build.BuildId)/artifacts'
displayName: 'Create issue from new errors'
env:
GITHUB_PAT: $(GITHUB_PAT)
4 changes: 2 additions & 2 deletions azure-pipelines-userTests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ jobs:
npm run build
npm install -g pnpm
mkdir 'RepoResults$(System.JobPositionInPhase)'
node dist/checkUserTestRepos ${{ parameters.ENTRYPOINT }} ${{ parameters.OLD_TS_REPO_URL }} ${{ parameters.OLD_HEAD_REF }} ${{ parameters.SOURCE_ISSUE }} ${{ parameters.TOP_REPOS }} '$(Pipeline.Workspace)/RepoList/repos.json' $(System.TotalJobsInPhase) $(System.JobPositionInPhase) 'RepoResults$(System.JobPositionInPhase)' ${{ parameters.DIAGNOSTIC_OUTPUT }} ${{ parameters.PRNG_SEED }} $(Build.BuildId) '$(System.TeamFoundationCollectionUri)' '$(System.TeamProject)'
node dist/checkUserTestRepos ${{ parameters.ENTRYPOINT }} ${{ parameters.OLD_TS_REPO_URL }} ${{ parameters.OLD_HEAD_REF }} ${{ parameters.SOURCE_ISSUE }} ${{ parameters.TOP_REPOS }} '$(Pipeline.Workspace)/RepoList/repos.json' $(System.TotalJobsInPhase) $(System.JobPositionInPhase) 'RepoResults$(System.JobPositionInPhase)' ${{ parameters.DIAGNOSTIC_OUTPUT }} ${{ parameters.PRNG_SEED }}
displayName: 'Run user tests'
env:
GITHUB_PAT: $(GITHUB_PAT)
Expand All @@ -123,7 +123,7 @@ jobs:
- script: |
npm ci
npm run build
node dist/postGithubComments ${{ parameters.REQUESTING_USER }} ${{ parameters.SOURCE_ISSUE }} ${{ parameters.STATUS_COMMENT }} ${{ parameters.DISTINCT_ID }} ${{ parameters.TOP_REPOS }} '$(Pipeline.Workspace)' '$(System.TeamFoundationCollectionUri)$(System.TeamProject)/_build/results?buildId=$(Build.BuildId)&view=artifacts&type=publishedArtifacts' ${{ parameters.POST_RESULT }} ${{ parameters.REPO_COUNT }}
node dist/postGithubComments ${{ parameters.REQUESTING_USER }} ${{ parameters.SOURCE_ISSUE }} ${{ parameters.STATUS_COMMENT }} ${{ parameters.DISTINCT_ID }} ${{ parameters.TOP_REPOS }} '$(Pipeline.Workspace)' '$(System.TeamFoundationCollectionUri)$(System.TeamProject)/_build/results?buildId=$(Build.BuildId)&view=artifacts&type=publishedArtifacts' ${{ parameters.POST_RESULT }} ${{ parameters.REPO_COUNT }} '$(System.TeamFoundationCollectionUri)$(System.TeamProject)/_apis/build/builds/$(Build.BuildId)/artifacts'
displayName: 'Update PR comment with new errors'
env:
GITHUB_PAT: $(GITHUB_PAT)
348 changes: 5 additions & 343 deletions package-lock.json

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
"@typescript/github-link": "^0.2.2",
"@typescript/server-harness": "^0.3.5",
"@typescript/server-replay": "^0.2.12",
"azure-devops-node-api": "^13.0.0",
"glob": "^10.3.10",
"js-yaml": "^4.1.0",
"json5": "^2.2.3",
Expand Down
9 changes: 3 additions & 6 deletions src/checkGithubRepos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ import { mainAsync, reportError, TsEntrypoint } from "./main";

const { argv } = process;

if (argv.length !== 14) {
console.error(`Usage: ${path.basename(argv[0])} ${path.basename(argv[1])} <ts_entrypoint> <old_ts_npm_version> <new_ts_npm_version> <repo_list_path> <worker_count> <worker_number> <result_dir_name> <diagnostic_output> <prng_seed> <buildId> <teamFoundationCollectionUri> <teamProject>`);
if (argv.length !== 11) {
console.error(`Usage: ${path.basename(argv[0])} ${path.basename(argv[1])} <ts_entrypoint> <old_ts_npm_version> <new_ts_npm_version> <repo_list_path> <worker_count> <worker_number> <result_dir_name> <diagnostic_output> <prng_seed>`);
process.exit(-1);
}

const [, , entrypoint, oldTsNpmVersion, newTsNpmVersion, repoListPath, workerCount, workerNumber, resultDirName, diagnosticOutput, prngSeed, buildId, teamFoundationCollectionUri, teamProject] = argv;
const [,, entrypoint, oldTsNpmVersion, newTsNpmVersion, repoListPath, workerCount, workerNumber, resultDirName, diagnosticOutput, prngSeed] = argv;

mainAsync({
testType: "github",
Expand All @@ -23,9 +23,6 @@ mainAsync({
newTsNpmVersion,
resultDirName,
prngSeed: prngSeed.toLowerCase() === "n/a" ? undefined : prngSeed,
buildId: +buildId,
teamFoundationCollectionUri,
teamProject,
}).catch(err => {
reportError(err, "Unhandled exception");
process.exit(1);
Expand Down
9 changes: 3 additions & 6 deletions src/checkUserTestRepos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ import { mainAsync, reportError, TsEntrypoint } from "./main";

const { argv } = process;

if (argv.length !== 16) {
console.error(`Usage: ${path.basename(argv[0])} ${path.basename(argv[1])} <ts_entrypoint> <old_ts_repo_url> <old_head_ref> <pr_number> <is_top_repos> <repo_list_path> <worker_count> <worker_number> <result_dir_name> <diagnostic_output> <prng_seed> <buildId> <teamFoundationCollectionUri> <teamProject>`);
if (argv.length !== 13) {
console.error(`Usage: ${path.basename(argv[0])} ${path.basename(argv[1])} <ts_entrypoint> <old_ts_repo_url> <old_head_ref> <pr_number> <is_top_repos> <repo_list_path> <worker_count> <worker_number> <result_dir_name> <diagnostic_output> <prng_seed>`);
process.exit(-1);
}

const [,, entrypoint, oldTsRepoUrl, oldHeadRef, prNumber, buildWithNewWhenOldFails, repoListPath, workerCount, workerNumber, resultDirName, diagnosticOutput, prngSeed, buildId, teamFoundationCollectionUri, teamProject] = argv;
const [,, entrypoint, oldTsRepoUrl, oldHeadRef, prNumber, buildWithNewWhenOldFails, repoListPath, workerCount, workerNumber, resultDirName, diagnosticOutput, prngSeed] = argv;

mainAsync({
testType: "user",
Expand All @@ -24,9 +24,6 @@ mainAsync({
resultDirName,
diagnosticOutput: diagnosticOutput.toLowerCase() === "true",
prngSeed: prngSeed.toLowerCase() === "n/a" ? undefined : prngSeed,
buildId: +buildId,
teamFoundationCollectionUri,
teamProject,
}).catch(err => {
reportError(err, "Unhandled exception");
process.exit(1);
Expand Down
31 changes: 10 additions & 21 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@ import mdEscape = require("markdown-escape");
import randomSeed = require("random-seed");
import { getErrorMessageFromStack, getHash, getHashForStack } from "./utils/hashStackTrace";
import { createCopyingOverlayFS, createTempOverlayFS, OverlayBaseFS } from "./utils/overlayFS";
import { getReplayScriptDownloadUrl } from "./utils/devOpsUtils";

export interface Params {
interface Params {
/**
* Store test repos on a tmpfs.
* Basically, the only reason not to do this would be lack of `sudo`.
Expand Down Expand Up @@ -55,18 +54,6 @@ export interface Params {
* Pass undefined to have a seed generated.
*/
prngSeed: string | undefined;
/**
* Build number to reference when downloading files.
*/
buildId: number;
/**
* URL of the DevOps organization.
*/
teamFoundationCollectionUri: string;
/**
* Name of the project that contains the build.
*/
teamProject: string;
}
export interface GitParams extends Params {
testType: "github";
Expand Down Expand Up @@ -109,7 +96,7 @@ interface TSServerResult {
installCommands: ip.InstallCommand[];
}

export interface Summary {
interface Summary {
tsServerResult: TSServerResult;
repo: git.Repo;
oldTsEntrypointPath: string;
Expand Down Expand Up @@ -442,7 +429,7 @@ ${oldServerError}
return text;
}

async function createNewErrorSummaryAsync(summaries: Summary[], params: Params): Promise<string> {
async function createNewErrorSummaryAsync(summaries: Summary[]): Promise<string> {
let text = `<h2>${getErrorMessage(summaries[0].tsServerResult.newSpawnResult.stdout)}</h2>
\`\`\`
Expand All @@ -458,7 +445,8 @@ ${prettyPrintServerHarnessOutput(summaries[0].tsServerResult.newSpawnResult.stdo
text += `
<details>
<summary><a href="${url}">${owner + mdEscape(summary.repo.name)}</a></summary>
Raw error text: <code>${summary.rawErrorArtifactPath}</code> in the <a href="${artifactFolderUrlPlaceholder}">artifact folder</a>
Raw error text: <code>${summary.rawErrorArtifactPath}</code> in the <a href="${artifactFolderUrlPlaceholder}">artifact folder</a> <br />
Replay commands: <code>${summary.replayScriptArtifactPath}</code> in the <a href="${artifactFolderUrlPlaceholder}">artifact folder</a>
<h4>Last few requests</h4>
\`\`\`json
Expand Down Expand Up @@ -496,9 +484,9 @@ ${summary.replayScript}
text += `${command.tool} ${workingDirFlag} "${command.directory}" ${command.arguments.join(" ")}\n`;
}

const replayScriptUrl = await getReplayScriptDownloadUrl(summary, params);

text += `wget -O ${summary.replayScriptName} "${replayScriptUrl!.toString()}"
text += `downloadUrl=$(curl -s "${getArtifactsApiUrlPlaceholder}?artifactName=${summary.resultDirName}&api-version=7.0" | jq -r ".resource.downloadUrl")
wget -O ${summary.resultDirName}.zip "$downloadUrl"
unzip -p ${summary.resultDirName}.zip ${summary.resultDirName}/${summary.replayScriptName} > ${summary.replayScriptName}
npm install --no-save @typescript/server-replay
\`\`\`
Expand Down Expand Up @@ -723,6 +711,7 @@ export const resultFileNameSuffix = "results.txt";
export const replayScriptFileNameSuffix = "replay.txt";
export const rawErrorFileNameSuffix = "rawError.txt";
export const artifactFolderUrlPlaceholder = "PLACEHOLDER_ARTIFACT_FOLDER";
export const getArtifactsApiUrlPlaceholder = "PLACEHOLDER_GETARTIFACTS_API";

export type StatusCounts = {
[P in RepoStatus]?: number
Expand Down Expand Up @@ -858,7 +847,7 @@ export async function mainAsync(params: GitParams | UserParams): Promise<void> {
}

for (let [key, value] of groupedNewErrors) {
const summary = await createNewErrorSummaryAsync(value, params);
const summary = await createNewErrorSummaryAsync(value);
const resultFileName = `${key}.${resultFileNameSuffix}`;

await fs.promises.writeFile(path.join(resultDirPath, resultFileName), summary, { encoding: "utf-8" });
Expand Down
11 changes: 6 additions & 5 deletions src/postGithubComments.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import fs = require("fs");
import path = require("path");
import { artifactFolderUrlPlaceholder, Metadata, metadataFileName, RepoStatus, resultFileNameSuffix } from "./main";
import { artifactFolderUrlPlaceholder, getArtifactsApiUrlPlaceholder, Metadata, metadataFileName, RepoStatus, resultFileNameSuffix } from "./main";
import git = require("./utils/gitUtils");
import pu = require("./utils/packageUtils");

const { argv } = process;

if (argv.length !== 11) {
console.error(`Usage: ${path.basename(argv[0])} ${path.basename(argv[1])} <user_to_tag> <pr_number> <comment_number> <distinct_id> <is_top_repos_run> <result_dir_path> <artifacts_uri> <post_result> <repo_count>`);
if (argv.length !== 12) {
console.error(`Usage: ${path.basename(argv[0])} ${path.basename(argv[1])} <user_to_tag> <pr_number> <comment_number> <distinct_id> <is_top_repos_run> <result_dir_path> <artifacts_uri> <post_result> <repo_count> <get_artifacts_api>`);
process.exit(-1);
}

const [, , userToTag, prNumber, commentNumber, distinctId, isTop, resultDirPath, artifactsUri, post, repoCount] = argv;
const [, , userToTag, prNumber, commentNumber, distinctId, isTop, resultDirPath, artifactsUri, post, repoCount, getArtifactsApi] = argv;
const isTopReposRun = isTop.toLowerCase() === "true";
const postResult = post.toLowerCase() === "true";

Expand Down Expand Up @@ -72,7 +72,8 @@ const hasOldErrors = pu.glob(resultDirPath, `**/!*.${resultFileNameSuffix}`).len
const resultPaths = pu.glob(resultDirPath, `**/*.${resultFileNameSuffix}`).sort((a, b) => path.basename(a).localeCompare(path.basename(b)));
const outputs = resultPaths.map(p =>
fs.readFileSync(p, { encoding: "utf-8" })
.replaceAll(artifactFolderUrlPlaceholder, artifactsUri));
.replaceAll(artifactFolderUrlPlaceholder, artifactsUri)
.replaceAll(getArtifactsApiUrlPlaceholder, getArtifactsApi));

const suiteDescription = isTopReposRun ? `top ${repoCount} repos` : "user tests";
let header = `@${userToTag} Here are the results of running the ${suiteDescription} comparing \`${oldTscResolvedVersion}\` and \`${newTscResolvedVersion}\`:
Expand Down
11 changes: 6 additions & 5 deletions src/postGithubIssue.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import fs = require("fs");
import path = require("path");
import { artifactFolderUrlPlaceholder, Metadata, metadataFileName, RepoStatus, resultFileNameSuffix, StatusCounts, TsEntrypoint } from "./main";
import { artifactFolderUrlPlaceholder, getArtifactsApiUrlPlaceholder, Metadata, metadataFileName, RepoStatus, resultFileNameSuffix, StatusCounts, TsEntrypoint } from "./main";
import git = require("./utils/gitUtils");
import pu = require("./utils/packageUtils");

const { argv } = process;

if (argv.length !== 10) {
console.error(`Usage: ${path.basename(argv[0])} ${path.basename(argv[1])} <ts_entrypoint> <language> <repo_count> <repo_start_index> <result_dir_path> <log_uri> <artifacts_uri> <post_result>`);
if (argv.length !== 11) {
console.error(`Usage: ${path.basename(argv[0])} ${path.basename(argv[1])} <ts_entrypoint> <language> <repo_count> <repo_start_index> <result_dir_path> <log_uri> <artifacts_uri> <post_result> <get_artifacts_api>`);
process.exit(-1);
}

const [, , ep, language, repoCount, repoStartIndex, resultDirPath, logUri, artifactsUri, post] = argv;
const [, , ep, language, repoCount, repoStartIndex, resultDirPath, logUri, artifactsUri, post, getArtifactsApi] = argv;
const postResult = post.toLowerCase() === "true";
const entrypoint = ep as TsEntrypoint;

Expand Down Expand Up @@ -74,7 +74,8 @@ ${Object.keys(statusCounts).sort().map(status => `| ${status} | ${statusCounts[s
const resultPaths = pu.glob(resultDirPath, `**/*.${resultFileNameSuffix}`).sort((a, b) => path.basename(a).localeCompare(path.basename(b)));
const outputs = resultPaths.map(p =>
fs.readFileSync(p, { encoding: "utf-8" })
.replaceAll(artifactFolderUrlPlaceholder, artifactsUri));
.replaceAll(artifactFolderUrlPlaceholder, artifactsUri)
.replaceAll(getArtifactsApiUrlPlaceholder, getArtifactsApi));

for (let i = 0; i < outputs.length; i++) {
const resultPath = resultPaths[i];
Expand Down
31 changes: 0 additions & 31 deletions src/utils/devOpsUtils.ts

This file was deleted.

7 changes: 5 additions & 2 deletions test/__snapshots__/main.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ Req #123 - cursedCommand
<h4>Affected repos</h4>
<details>
<summary><a href="https://github.com/MockRepoOwner/MockRepoName">MockRepoOwner/MockRepoName</a></summary>
Raw error text: <code>RepoResults123/MockRepoOwner.MockRepoName.rawError.txt</code> in the <a href="PLACEHOLDER_ARTIFACT_FOLDER">artifact folder</a>
Raw error text: <code>RepoResults123/MockRepoOwner.MockRepoName.rawError.txt</code> in the <a href="PLACEHOLDER_ARTIFACT_FOLDER">artifact folder</a> <br />
Replay commands: <code>RepoResults123/MockRepoOwner.MockRepoName.replay.txt</code> in the <a href="PLACEHOLDER_ARTIFACT_FOLDER">artifact folder</a>
<h4>Last few requests</h4>
\`\`\`json
Expand All @@ -51,7 +52,9 @@ git -C "./MockRepoName" reset --hard 57b462387e88aa7e363af0daf867a5dc1e83a935
npm --prefix "./dirA" install --prefer-offline --no-audit --no-progress --legacy-peer-deps --ignore-scripts -q
npm --prefix "./dirB/dirC" install --prefer-offline --no-audit --no-progress --legacy-peer-deps --ignore-scripts -q
npm --prefix "./dirD/dirE/dirF" install --prefer-offline --no-audit --no-progress --legacy-peer-deps --ignore-scripts -q
wget -O MockRepoOwner.MockRepoName.replay.txt "http://anazuredevops.buildpage.com_teamproject_atypescriptproject_buildid_1/?artifactName=RepoResults123&fileId=999&fileName=MockRepoOwner.MockRepoName.replay.txt"
downloadUrl=$(curl -s "PLACEHOLDER_GETARTIFACTS_API?artifactName=RepoResults123&api-version=7.0" | jq -r ".resource.downloadUrl")
wget -O RepoResults123.zip "$downloadUrl"
unzip -p RepoResults123.zip RepoResults123/MockRepoOwner.MockRepoName.replay.txt > MockRepoOwner.MockRepoName.replay.txt
npm install --no-save @typescript/server-replay
\`\`\`
Expand Down
15 changes: 2 additions & 13 deletions test/main.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getTscRepoResult, downloadTsRepoAsync, mainAsync, Params, Summary } from '../src/main'
import { getTscRepoResult, downloadTsRepoAsync, mainAsync } from '../src/main'
import { execSync } from "child_process"
import path = require("path")
import { createCopyingOverlayFS } from '../src/utils/overlayFS'
Expand Down Expand Up @@ -109,14 +109,6 @@ jest.mock('../src/utils/installPackages', () => {
}
}
});
jest.mock('../src/utils/devOpsUtils', () => ({
getReplayScriptDownloadUrl: async (summary: Summary, params: Params) => {
var url = new URL(`${params.teamFoundationCollectionUri}_teamProject_${params.teamProject}_buildId_${params.buildId}`);
url.search = `artifactName=${summary.resultDirName}&fileId=999&fileName=${summary.replayScriptName}`;

return url;
}
}));

describe("main", () => {
jest.setTimeout(10 * 60 * 1000);
Expand Down Expand Up @@ -167,9 +159,6 @@ describe("main", () => {
newTsNpmVersion: 'next',
resultDirName: 'RepoResults123',
prngSeed: 'testSeed',
buildId: 1,
teamFoundationCollectionUri: "http://anAzureDevOps.buildPage.com",
teamProject: "ATypeScriptProject"
});

// Remove all references to the base path so that snapshot pass successfully.
Expand All @@ -179,4 +168,4 @@ describe("main", () => {

expect(mockedFs.promises.writeFile).toMatchSnapshot();
});
});
})

0 comments on commit f600628

Please sign in to comment.