Add opening on GitHub of live results variant analyses

This implements the "Open on GitHub" context menu item for live results
variant analyses.
This commit is contained in:
Koen Vlaswinkel
2022-10-31 14:20:44 +01:00
parent dad6467599
commit 847cb13694
4 changed files with 46 additions and 9 deletions

View File

@@ -71,3 +71,15 @@ export function buildRepoLabel(item: RemoteQueryHistoryItem | VariantAnalysisHis
assertNever(item);
}
}
export function getActionsWorkflowRunUrl(item: RemoteQueryHistoryItem | VariantAnalysisHistoryItem): string {
if (item.t === 'remote') {
const { actionsWorkflowRunId: workflowRunId, controllerRepository: { owner, name } } = item.remoteQuery;
return `https://github.com/${owner}/${name}/actions/runs/${workflowRunId}`;
} else if (item.t === 'variant-analysis') {
const { actionsWorkflowRunId, controllerRepo: { fullName } } = item.variantAnalysis;
return `https://github.com/${fullName}/actions/runs/${actionsWorkflowRunId}`;
} else {
assertNever(item);
}
}

View File

@@ -31,7 +31,7 @@ import { commandRunner } from './commandRunner';
import { ONE_HOUR_IN_MS, TWO_HOURS_IN_MS } from './pure/time';
import { assertNever, getErrorMessage, getErrorStack } from './pure/helpers-pure';
import { CompletedLocalQueryInfo, LocalQueryInfo } from './query-results';
import { getQueryId, getQueryText, QueryHistoryInfo } from './query-history-info';
import { getActionsWorkflowRunUrl, getQueryId, getQueryText, QueryHistoryInfo } from './query-history-info';
import { DatabaseManager } from './databases';
import { registerQueryHistoryScrubber } from './query-history-scrubber';
import { QueryStatus, variantAnalysisStatusToQueryStatus } from './query-status';
@@ -1214,16 +1214,17 @@ export class QueryHistoryManager extends DisposableObject {
const { finalSingleItem, finalMultiSelect } = this.determineSelection(singleItem, multiSelect);
// Remote queries only
if (!this.assertSingleQuery(finalMultiSelect) || !finalSingleItem || finalSingleItem.t !== 'remote') {
if (!this.assertSingleQuery(finalMultiSelect) || !finalSingleItem) {
return;
}
const { actionsWorkflowRunId: workflowRunId, controllerRepository: { owner, name } } = finalSingleItem.remoteQuery;
if (finalSingleItem.t === 'local') {
return;
}
await commands.executeCommand(
'vscode.open',
Uri.parse(`https://github.com/${owner}/${name}/actions/runs/${workflowRunId}`)
);
const actionsWorkflowRunUrl = getActionsWorkflowRunUrl(finalSingleItem);
await commands.executeCommand('vscode.open', Uri.parse(actionsWorkflowRunUrl));
}
async handleCopyRepoList(

View File

@@ -26,7 +26,11 @@ describe('Variant Analysis processor', function() {
expect(result).to.eql({
'id': mockApiResponse.id,
'controllerRepoId': mockApiResponse.controller_repo.id,
'controllerRepo': {
'id': mockApiResponse.controller_repo.id,
'fullName': mockApiResponse.controller_repo.full_name,
'private': mockApiResponse.controller_repo.private
},
'query': {
'filePath': 'query-file-path',
'language': VariantAnalysisQueryLanguage.Javascript,

View File

@@ -1,7 +1,13 @@
import { expect } from 'chai';
import { QueryStatus } from '../../src/query-status';
import { buildRepoLabel, getQueryId, getQueryText, getRawQueryName } from '../../src/query-history-info';
import {
buildRepoLabel,
getActionsWorkflowRunUrl,
getQueryId,
getQueryText,
getRawQueryName
} from '../../src/query-history-info';
import { VariantAnalysisHistoryItem } from '../../src/remote-queries/variant-analysis-history-item';
import { createMockVariantAnalysis } from '../../src/vscode-tests/factories/remote-queries/shared/variant-analysis';
import { createMockScannedRepos } from '../../src/vscode-tests/factories/remote-queries/shared/scanned-repositories';
@@ -144,4 +150,18 @@ describe('Query history info', () => {
});
});
});
describe('getActionsWorkflowRunUrl', () => {
it('should get the run url for remote query history items', () => {
const actionsWorkflowRunUrl = getActionsWorkflowRunUrl(remoteQueryHistoryItem);
expect(actionsWorkflowRunUrl).to.equal(`https://github.com/${remoteQueryHistoryItem.remoteQuery.controllerRepository.owner}/${remoteQueryHistoryItem.remoteQuery.controllerRepository.name}/actions/runs/${remoteQueryHistoryItem.remoteQuery.actionsWorkflowRunId}`);
});
it('should get the run url for variant analysis history items', () => {
const actionsWorkflowRunUrl = getActionsWorkflowRunUrl(variantAnalysisHistoryItem);
expect(actionsWorkflowRunUrl).to.equal(`https://github.com/${variantAnalysisHistoryItem.variantAnalysis.controllerRepo.fullName}/actions/runs/${variantAnalysisHistoryItem.variantAnalysis.actionsWorkflowRunId}`);
});
});
});