Skip to content

Commit b27f2d6

Browse files
committed
Get green
1 parent e34a3a5 commit b27f2d6

File tree

5 files changed

+190
-78
lines changed

5 files changed

+190
-78
lines changed

dist/index.js

+120-13
Original file line numberDiff line numberDiff line change
@@ -2058,6 +2058,8 @@ const updatesIssue_1 = __webpack_require__(700);
20582058
const runTwoslashRuns_1 = __webpack_require__(303);
20592059
const api_1 = __webpack_require__(105);
20602060
const downloadTSVersions_1 = __webpack_require__(580);
2061+
const getPreviousRunInfo_1 = __webpack_require__(707);
2062+
const setupBreakingInfo_1 = __webpack_require__(406);
20612063
async function run() {
20622064
const ctx = (0, getContext_1.getContext)();
20632065
console.log(`Context: ${JSON.stringify(ctx, null, ' ')}`);
@@ -2070,8 +2072,10 @@ async function run() {
20702072
console.log('');
20712073
const runs = (0, issuesToTwoslashRuns_1.issueToTwoslashRun)(ctx)(issue);
20722074
const results = (0, runTwoslashRuns_1.runTwoslashRuns)(issue, runs);
2075+
const runInfo = (0, getPreviousRunInfo_1.getPreviousRunInfo)(issue);
2076+
const breakage = (runInfo && runInfo.breakageInfo) || (await (0, setupBreakingInfo_1.getBreakageInfo)(runs, results));
20732077
const api = (0, api_1.createAPI)(ctx);
2074-
await (0, updatesIssue_1.updateIssue)(ctx, issue, results, api);
2078+
await (0, updatesIssue_1.updateIssue)(ctx, issue, results, breakage, api);
20752079
}
20762080
}
20772081
process.stdout.write('.');
@@ -4195,7 +4199,7 @@ exports.paginateRest = paginateRest;
41954199
"use strict";
41964200

41974201
Object.defineProperty(exports, "__esModule", { value: true });
4198-
exports.runTwoSlash = exports.runTwoSlashOnOlderVersions = exports.runTwoslashRuns = void 0;
4202+
exports.runTwoSlash = exports.runTwoSlashOnOlderVersions = exports.requireTS = exports.runTwoslashRuns = void 0;
41994203
const twoslash_1 = __webpack_require__(689);
42004204
const fs_1 = __webpack_require__(747);
42014205
const path_1 = __webpack_require__(622);
@@ -4214,6 +4218,13 @@ function runTwoslashRuns(issue, runs) {
42144218
}
42154219
}
42164220
exports.runTwoslashRuns = runTwoslashRuns;
4221+
const requireTS = (version) => {
4222+
// dev prod
4223+
const possibleTSRoots = [(0, path_1.join)(__dirname, '..', 'dist', 'ts'), (0, path_1.join)(__dirname, 'ts')];
4224+
const tsRoot = possibleTSRoots.find(f => (0, fs_1.existsSync)(f));
4225+
return require((0, path_1.join)(tsRoot, version));
4226+
};
4227+
exports.requireTS = requireTS;
42174228
const runTwoSlashOnOlderVersions = (run) => {
42184229
// dev prod
42194230
const possibleTSRoots = [(0, path_1.join)(__dirname, '..', 'dist', 'ts'), (0, path_1.join)(__dirname, 'ts')];
@@ -7322,6 +7333,91 @@ exports.knownLibFilesForCompilerOptions = knownLibFilesForCompilerOptions;
73227333
//# sourceMappingURL=vfs.cjs.development.js.map
73237334

73247335

7336+
/***/ }),
7337+
7338+
/***/ 406:
7339+
/***/ (function(__unusedmodule, exports, __webpack_require__) {
7340+
7341+
"use strict";
7342+
7343+
Object.defineProperty(exports, "__esModule", { value: true });
7344+
exports.getBreakageInfo = exports.binarySearch = exports.extractDateAndVersionMetadata = void 0;
7345+
const downloadTSVersions_1 = __webpack_require__(580);
7346+
const runTwoslashRuns_1 = __webpack_require__(303);
7347+
// Grab every version of TypeScript
7348+
const downloadAllTSVersions = async () => {
7349+
const response = await fetch('http://registry.npmjs.org/typescript');
7350+
const json = await response.json();
7351+
return (0, exports.extractDateAndVersionMetadata)(json);
7352+
};
7353+
/** So we can have much less of that 14mb json file in memory */
7354+
const extractDateAndVersionMetadata = (packument) => {
7355+
const time = packument.time;
7356+
delete time['modified'];
7357+
delete time['created'];
7358+
return Object.keys(time).map(key => [key, time[key]]);
7359+
};
7360+
exports.extractDateAndVersionMetadata = extractDateAndVersionMetadata;
7361+
async function binarySearch(ar, func) {
7362+
var m = 0;
7363+
var n = ar.length - 1;
7364+
while (m <= n) {
7365+
var k = (n + m) >> 1;
7366+
var cmp = await func(ar[k]);
7367+
if (cmp > 0) {
7368+
m = k + 1;
7369+
}
7370+
else if (cmp < 0) {
7371+
n = k - 1;
7372+
}
7373+
else {
7374+
return ar[k];
7375+
}
7376+
}
7377+
return ar[m - 1];
7378+
}
7379+
exports.binarySearch = binarySearch;
7380+
const compareResults = (run, todaysResult) => async (version) => {
7381+
(0, downloadTSVersions_1.ensureTSVersionExists)(version[0]);
7382+
const ts = (0, runTwoslashRuns_1.requireTS)(version[0]);
7383+
const newResults = run.codeBlocksToRun.map(code => (0, runTwoslashRuns_1.runTwoSlash)('Check for breakage')(code, ts));
7384+
let same = true;
7385+
// Look to make sure that every result from today's run include a corresponding result for yesterday's run
7386+
newResults.forEach(res => {
7387+
if (!todaysResult.some(todays => resultsSame(res, todays))) {
7388+
same = false;
7389+
}
7390+
});
7391+
return same === true ? 1 : -1;
7392+
};
7393+
const getBreakageInfo = async (run, results) => {
7394+
const latestResults = getLatest(results);
7395+
const allVersions = await downloadAllTSVersions();
7396+
const comparer = compareResults(run, latestResults);
7397+
const version = await binarySearch(allVersions, comparer);
7398+
const info = {
7399+
estimatedVersion: version[0],
7400+
estimatedDate: version[1]
7401+
};
7402+
return info;
7403+
};
7404+
exports.getBreakageInfo = getBreakageInfo;
7405+
const getLatest = (runs) => runs.filter(r => r.label === 'Nightly');
7406+
const resultsSame = (lhs, rhs) => {
7407+
if (lhs.description != rhs.description)
7408+
return false;
7409+
if (lhs.state != rhs.state)
7410+
return false;
7411+
if (lhs.fails != rhs.fails)
7412+
return false;
7413+
if (lhs.assertions != rhs.assertions)
7414+
return false;
7415+
if (lhs.exception != rhs.exception)
7416+
return false;
7417+
return true;
7418+
};
7419+
7420+
73257421
/***/ }),
73267422

73277423
/***/ 408:
@@ -11683,7 +11779,7 @@ const github_1 = __webpack_require__(469);
1168311779
async function getIssues(context) {
1168411780
const octokit = (0, github_1.getOctokit)(context.token);
1168511781
const req = issuesQuery(context.owner, context.name, context.label);
11686-
const initialIssues = (await octokit.graphql(req.query, Object.assign({}, req.vars)));
11782+
const initialIssues = (await octokit.graphql(req.query, { ...req.vars }));
1168711783
// TODO: check if nodes length == 100, then start looping
1168811784
return initialIssues.repository.issues.nodes;
1168911785
}
@@ -12794,7 +12890,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
1279412890
return (mod && mod.__esModule) ? mod : { "default": mod };
1279512891
};
1279612892
Object.defineProperty(exports, "__esModule", { value: true });
12797-
exports.downloadTypeScriptVersions = void 0;
12893+
exports.ensureTSVersionExists = exports.downloadTSVersion = exports.downloadTypeScriptVersions = void 0;
1279812894
const child_process_1 = __webpack_require__(129);
1279912895
const fs_1 = __webpack_require__(747);
1280012896
const node_fetch_1 = __importDefault(__webpack_require__(454));
@@ -12804,10 +12900,9 @@ const downloadTypeScriptVersions = async () => {
1280412900
const releases = await downloadReleases();
1280512901
const usableReleases = reduceToMajMin(releases);
1280612902
const mostRecentFive = usableReleases.sort().reverse().slice(0, 5);
12807-
console.log('Grabbing at: ', mostRecentFive);
12903+
console.log('Grabbing: ', mostRecentFive);
1280812904
for (const version of mostRecentFive) {
12809-
downloadTSVersion(version);
12810-
extractTSVersion(version);
12905+
(0, exports.ensureTSVersionExists)(version);
1281112906
}
1281212907
};
1281312908
exports.downloadTypeScriptVersions = downloadTypeScriptVersions;
@@ -12828,6 +12923,14 @@ const downloadTSVersion = (version) => {
1282812923
const toFile = (0, path_1.join)(zips, version + '.tgz');
1282912924
(0, child_process_1.execSync)(`curl ${url} > ${toFile}`);
1283012925
};
12926+
exports.downloadTSVersion = downloadTSVersion;
12927+
const ensureTSVersionExists = (version) => {
12928+
if ((0, fs_1.existsSync)((0, path_1.join)(__dirname, '..', 'dist', version)))
12929+
return;
12930+
(0, exports.downloadTSVersion)(version);
12931+
extractTSVersion(version);
12932+
};
12933+
exports.ensureTSVersionExists = ensureTSVersionExists;
1283112934
// Grab the versions the playground uses
1283212935
const downloadReleases = async () => {
1283312936
const response = await (0, node_fetch_1.default)('https://typescript.azureedge.net/indexes/releases.json');
@@ -14213,29 +14316,30 @@ Object.defineProperty(exports, "__esModule", { value: true });
1421314316
exports.makeMessageForMainRuns = exports.updateIssue = void 0;
1421414317
const getPreviousRunInfo_1 = __webpack_require__(707);
1421514318
const getTypeScriptMeta_1 = __webpack_require__(772);
14216-
const updateIssue = async (_ctx, issue, newRuns, api) => {
14319+
const updateIssue = async (_ctx, issue, newRuns, breakage, api) => {
1421714320
process.stdout.write(`\nUpdating issue ${issue.number}: `);
1421814321
if (newRuns.length === 0)
1421914322
return;
14220-
await updateMainComment(newRuns, api, issue);
14323+
await updateMainComment(newRuns, breakage, api, issue);
1422114324
};
1422214325
exports.updateIssue = updateIssue;
14223-
async function updateMainComment(newRuns, api, issue) {
14326+
async function updateMainComment(newRuns, breakage, api, issue) {
1422414327
const nightlyNew = getLatest(newRuns);
1422514328
const runInfo = (0, getPreviousRunInfo_1.getPreviousRunInfo)(issue);
1422614329
const introduction = intro(nightlyNew.length);
1422714330
const above = (0, exports.makeMessageForMainRuns)(nightlyNew);
1422814331
const groupedBySource = groupBy(newRuns, ts => ts.commentID || '__body');
1422914332
const bottom = makeMessageForOlderRuns(groupedBySource);
1423014333
const newTSMeta = await (0, getTypeScriptMeta_1.getTypeScriptMeta)();
14334+
const commentID = runInfo && runInfo.commentID;
1423114335
const embedded = (0, getPreviousRunInfo_1.runInfoString)({
1423214336
runs: newRuns,
14233-
commentID: runInfo === null || runInfo === void 0 ? void 0 : runInfo.commentID,
14337+
commentID,
1423414338
typescriptNightlyVersion: newTSMeta.version,
1423514339
typescriptSHA: newTSMeta.sha
1423614340
});
1423714341
const msg = `${introduction}\n\n${above}\n\n${bottom}\n\n${embedded}`;
14238-
await api.editOrCreateComment(issue.id, runInfo === null || runInfo === void 0 ? void 0 : runInfo.commentID, msg);
14342+
await api.editOrCreateComment(issue.id, commentID, msg);
1423914343
}
1424014344
const intro = (runLength) => {
1424114345
const repros = runLength === 1 ? 'repro' : `${runLength} repros`;
@@ -14360,7 +14464,10 @@ const getPreviousRunInfo = (issue) => {
1436014464
const json = JSON.parse(jsonString);
1436114465
if ("typescriptNightlyVersion" in json === false)
1436214466
return undefined;
14363-
return Object.assign(Object.assign({}, json), { commentID: botComment.id });
14467+
return {
14468+
...json,
14469+
commentID: botComment.id
14470+
};
1436414471
}
1436514472
catch (error) {
1436614473
return undefined;

src/_main.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import {updateIssue} from './updatesIssue'
55
import {runTwoslashRuns} from './runTwoslashRuns'
66
import {createAPI} from './utils/api'
77
import {downloadTypeScriptVersions} from './downloadTSVersions'
8-
import { getPreviousRunInfo } from './utils/getPreviousRunInfo'
9-
import { getBreakageInfo } from './setupBreakingInfo'
8+
import {getPreviousRunInfo} from './utils/getPreviousRunInfo'
9+
import {getBreakageInfo} from './setupBreakingInfo'
1010

1111
async function run() {
1212
const ctx = getContext()
@@ -24,9 +24,9 @@ async function run() {
2424
const runs = issueToTwoslashRun(ctx)(issue)
2525

2626
const results = runTwoslashRuns(issue, runs)
27-
27+
2828
const runInfo = getPreviousRunInfo(issue)
29-
const breakage = runInfo?.breakageInfo || await getBreakageInfo(runs, results)
29+
const breakage = (runInfo && runInfo.breakageInfo) || (await getBreakageInfo(runs, results))
3030

3131
const api = createAPI(ctx)
3232
await updateIssue(ctx, issue, results, breakage, api)

src/downloadTSVersions.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export const downloadTSVersion = (version: string) => {
3939

4040
export const ensureTSVersionExists = (version: string) => {
4141
if (existsSync(join(__dirname, '..', 'dist', version))) return
42-
42+
4343
downloadTSVersion(version)
4444
extractTSVersion(version)
4545
}

0 commit comments

Comments
 (0)