Skip to content

Commit 4b498d8

Browse files
authored
Merge pull request #559 from keymanapp/fix/resilience-for-tc-data
chore: more tweaks to builddata
2 parents 35e7041 + a525b75 commit 4b498d8

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

server/keymanapp-test-bot/artifact-links-comment.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ import { statusData } from '../data/status-data.js';
55
import { artifactLinks } from '../../shared/artifact-links.js';
66
import { getTeamcityUrlParams } from "../../shared/getTeamcityUrlParams.js";
77

8+
type BuildDataCacheItem = {context:string, target_url:string, state:string};
9+
type BuildDataCache = {[index:string]: BuildDataCacheItem};
10+
811
export async function getArtifactLinksComment(
912
octokit: InstanceType<typeof ProbotOctokit>,
1013
data,
@@ -23,7 +26,7 @@ export async function getArtifactLinksComment(
2326
return '';
2427
}
2528
//const statuses = await octokit.rest.repos.getCombinedStatusForRef({owner:'keymanapp',repo:'keyman',ref:'fix/web/5950-clear-timeout-on-longpress-flick'/*pull.data.head.ref*/});
26-
let s: {[index:string]: {context:string, target_url:string, state:string}} = {};
29+
let s: BuildDataCache = {};
2730
statuses.data.statuses.forEach(status => {
2831
if(s[status.context]) return;
2932
let o = {
@@ -112,7 +115,7 @@ export async function getArtifactLinksComment(
112115
if(buildData) version = findBuildVersion(buildData);
113116
if(version) version = /^(\d+\.\d+\.\d+)/.exec(version)?.[1];
114117
if(!version) {
115-
console.error(`[@keymanapp-test-bot] Failed to find version information for artifact links for ${buildTypeId}:${buildId}; buildData: ${JSON.stringify(buildData)}; teamCityData.length:${JSON.stringify(teamCityData).length}`);
118+
console.error(`[@keymanapp-test-bot] Failed to find version information for artifact links for ${buildTypeId}:${buildId}; buildData: ${JSON.stringify(buildData)}`);
116119
if(!teamCityDataFromCache) {
117120
continue;
118121
}
@@ -190,13 +193,13 @@ export async function getArtifactLinksComment(
190193
return r;
191194
}
192195

193-
function findBuildData(s, buildTypeId, teamCity) {
196+
function findBuildData(s: BuildDataCache, buildTypeId, teamCity) {
194197
for(let context of Object.keys(s)) {
195198
if(s[context].state == 'success') {
196199
// artifactLinks
197200
let u;
198201
try {
199-
u = new URL(s[context].url);
202+
u = new URL(s[context].target_url);
200203
} catch(e) {
201204
continue;
202205
}

0 commit comments

Comments
 (0)