Skip to content

Commit 847cb13

Browse files
committed
Add opening on GitHub of live results variant analyses
This implements the "Open on GitHub" context menu item for live results variant analyses.
1 parent dad6467 commit 847cb13

File tree

4 files changed

+46
-9
lines changed

4 files changed

+46
-9
lines changed

extensions/ql-vscode/src/query-history-info.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,3 +71,15 @@ export function buildRepoLabel(item: RemoteQueryHistoryItem | VariantAnalysisHis
7171
assertNever(item);
7272
}
7373
}
74+
75+
export function getActionsWorkflowRunUrl(item: RemoteQueryHistoryItem | VariantAnalysisHistoryItem): string {
76+
if (item.t === 'remote') {
77+
const { actionsWorkflowRunId: workflowRunId, controllerRepository: { owner, name } } = item.remoteQuery;
78+
return `https://github.com/${owner}/${name}/actions/runs/${workflowRunId}`;
79+
} else if (item.t === 'variant-analysis') {
80+
const { actionsWorkflowRunId, controllerRepo: { fullName } } = item.variantAnalysis;
81+
return `https://github.com/${fullName}/actions/runs/${actionsWorkflowRunId}`;
82+
} else {
83+
assertNever(item);
84+
}
85+
}

extensions/ql-vscode/src/query-history.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import { commandRunner } from './commandRunner';
3131
import { ONE_HOUR_IN_MS, TWO_HOURS_IN_MS } from './pure/time';
3232
import { assertNever, getErrorMessage, getErrorStack } from './pure/helpers-pure';
3333
import { CompletedLocalQueryInfo, LocalQueryInfo } from './query-results';
34-
import { getQueryId, getQueryText, QueryHistoryInfo } from './query-history-info';
34+
import { getActionsWorkflowRunUrl, getQueryId, getQueryText, QueryHistoryInfo } from './query-history-info';
3535
import { DatabaseManager } from './databases';
3636
import { registerQueryHistoryScrubber } from './query-history-scrubber';
3737
import { QueryStatus, variantAnalysisStatusToQueryStatus } from './query-status';
@@ -1214,16 +1214,17 @@ export class QueryHistoryManager extends DisposableObject {
12141214
const { finalSingleItem, finalMultiSelect } = this.determineSelection(singleItem, multiSelect);
12151215

12161216
// Remote queries only
1217-
if (!this.assertSingleQuery(finalMultiSelect) || !finalSingleItem || finalSingleItem.t !== 'remote') {
1217+
if (!this.assertSingleQuery(finalMultiSelect) || !finalSingleItem) {
12181218
return;
12191219
}
12201220

1221-
const { actionsWorkflowRunId: workflowRunId, controllerRepository: { owner, name } } = finalSingleItem.remoteQuery;
1221+
if (finalSingleItem.t === 'local') {
1222+
return;
1223+
}
12221224

1223-
await commands.executeCommand(
1224-
'vscode.open',
1225-
Uri.parse(`https://github.com/${owner}/${name}/actions/runs/${workflowRunId}`)
1226-
);
1225+
const actionsWorkflowRunUrl = getActionsWorkflowRunUrl(finalSingleItem);
1226+
1227+
await commands.executeCommand('vscode.open', Uri.parse(actionsWorkflowRunUrl));
12271228
}
12281229

12291230
async handleCopyRepoList(

extensions/ql-vscode/src/vscode-tests/cli-integration/remote-queries/variant-analysis-processor.test.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,11 @@ describe('Variant Analysis processor', function() {
2626

2727
expect(result).to.eql({
2828
'id': mockApiResponse.id,
29-
'controllerRepoId': mockApiResponse.controller_repo.id,
29+
'controllerRepo': {
30+
'id': mockApiResponse.controller_repo.id,
31+
'fullName': mockApiResponse.controller_repo.full_name,
32+
'private': mockApiResponse.controller_repo.private
33+
},
3034
'query': {
3135
'filePath': 'query-file-path',
3236
'language': VariantAnalysisQueryLanguage.Javascript,

extensions/ql-vscode/test/pure-tests/query-history-info.test.ts

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
import { expect } from 'chai';
22

33
import { QueryStatus } from '../../src/query-status';
4-
import { buildRepoLabel, getQueryId, getQueryText, getRawQueryName } from '../../src/query-history-info';
4+
import {
5+
buildRepoLabel,
6+
getActionsWorkflowRunUrl,
7+
getQueryId,
8+
getQueryText,
9+
getRawQueryName
10+
} from '../../src/query-history-info';
511
import { VariantAnalysisHistoryItem } from '../../src/remote-queries/variant-analysis-history-item';
612
import { createMockVariantAnalysis } from '../../src/vscode-tests/factories/remote-queries/shared/variant-analysis';
713
import { createMockScannedRepos } from '../../src/vscode-tests/factories/remote-queries/shared/scanned-repositories';
@@ -144,4 +150,18 @@ describe('Query history info', () => {
144150
});
145151
});
146152
});
153+
154+
describe('getActionsWorkflowRunUrl', () => {
155+
it('should get the run url for remote query history items', () => {
156+
const actionsWorkflowRunUrl = getActionsWorkflowRunUrl(remoteQueryHistoryItem);
157+
158+
expect(actionsWorkflowRunUrl).to.equal(`https://github.com/${remoteQueryHistoryItem.remoteQuery.controllerRepository.owner}/${remoteQueryHistoryItem.remoteQuery.controllerRepository.name}/actions/runs/${remoteQueryHistoryItem.remoteQuery.actionsWorkflowRunId}`);
159+
});
160+
161+
it('should get the run url for variant analysis history items', () => {
162+
const actionsWorkflowRunUrl = getActionsWorkflowRunUrl(variantAnalysisHistoryItem);
163+
164+
expect(actionsWorkflowRunUrl).to.equal(`https://github.com/${variantAnalysisHistoryItem.variantAnalysis.controllerRepo.fullName}/actions/runs/${variantAnalysisHistoryItem.variantAnalysis.actionsWorkflowRunId}`);
165+
});
166+
});
147167
});

0 commit comments

Comments
 (0)