Merge pull request #1686 from github/koesie10/live-results-view-logs
Open Actions workflow run when clicking on "View logs"
This commit is contained in:
@@ -477,6 +477,10 @@ export interface OpenQueryTextMessage {
|
||||
t: 'openQueryText';
|
||||
}
|
||||
|
||||
export interface OpenLogsMessage {
|
||||
t: 'openLogs';
|
||||
}
|
||||
|
||||
export type ToVariantAnalysisMessage =
|
||||
| SetVariantAnalysisMessage
|
||||
| SetRepoResultsMessage
|
||||
@@ -487,4 +491,5 @@ export type FromVariantAnalysisMessage =
|
||||
| StopVariantAnalysisMessage
|
||||
| RequestRepositoryResultsMessage
|
||||
| OpenQueryFileMessage
|
||||
| OpenQueryTextMessage;
|
||||
| OpenQueryTextMessage
|
||||
| OpenLogsMessage;
|
||||
|
||||
@@ -3,7 +3,10 @@ import { VariantAnalysisHistoryItem } from './remote-queries/variant-analysis-hi
|
||||
import { LocalQueryInfo } from './query-results';
|
||||
import { assertNever } from './pure/helpers-pure';
|
||||
import { pluralize } from './pure/word';
|
||||
import { hasRepoScanCompleted } from './remote-queries/shared/variant-analysis';
|
||||
import {
|
||||
hasRepoScanCompleted,
|
||||
getActionsWorkflowRunUrl as getVariantAnalysisActionsWorkflowRunUrl
|
||||
} from './remote-queries/shared/variant-analysis';
|
||||
|
||||
export type QueryHistoryInfo = LocalQueryInfo | RemoteQueryHistoryItem | VariantAnalysisHistoryItem;
|
||||
|
||||
@@ -77,8 +80,7 @@ export function getActionsWorkflowRunUrl(item: RemoteQueryHistoryItem | VariantA
|
||||
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}`;
|
||||
return getVariantAnalysisActionsWorkflowRunUrl(item.variantAnalysis);
|
||||
} else {
|
||||
assertNever(item);
|
||||
}
|
||||
|
||||
@@ -175,3 +175,8 @@ export function getSkippedRepoCount(skippedRepos: VariantAnalysisSkippedReposito
|
||||
|
||||
return Object.values(skippedRepos).reduce((acc, group) => acc + group.repositoryCount, 0);
|
||||
}
|
||||
|
||||
export function getActionsWorkflowRunUrl(variantAnalysis: VariantAnalysis): string {
|
||||
const { actionsWorkflowRunId, controllerRepo: { fullName } } = variantAnalysis;
|
||||
return `https://github.com/${fullName}/actions/runs/${actionsWorkflowRunId}`;
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import { logger } from '../logging';
|
||||
import { FromVariantAnalysisMessage, ToVariantAnalysisMessage } from '../pure/interface-types';
|
||||
import { assertNever } from '../pure/helpers-pure';
|
||||
import {
|
||||
getActionsWorkflowRunUrl,
|
||||
VariantAnalysis,
|
||||
VariantAnalysisScannedRepositoryResult,
|
||||
VariantAnalysisScannedRepositoryState,
|
||||
@@ -102,6 +103,9 @@ export class VariantAnalysisView extends AbstractWebview<ToVariantAnalysisMessag
|
||||
case 'openQueryText':
|
||||
await this.openQueryText();
|
||||
break;
|
||||
case 'openLogs':
|
||||
await this.openLogs();
|
||||
break;
|
||||
default:
|
||||
assertNever(msg);
|
||||
}
|
||||
@@ -165,4 +169,16 @@ export class VariantAnalysisView extends AbstractWebview<ToVariantAnalysisMessag
|
||||
void showAndLogWarningMessage('Could not open variant analysis query text. Failed to open text document.');
|
||||
}
|
||||
}
|
||||
|
||||
private async openLogs(): Promise<void> {
|
||||
const variantAnalysis = await this.manager.getVariantAnalysis(this.variantAnalysisId);
|
||||
if (!variantAnalysis) {
|
||||
void showAndLogWarningMessage('Could not open variant analysis logs. Variant analysis not found.');
|
||||
return;
|
||||
}
|
||||
|
||||
const actionsWorkflowRunUrl = getActionsWorkflowRunUrl(variantAnalysis);
|
||||
|
||||
await commands.executeCommand('vscode.open', Uri.parse(actionsWorkflowRunUrl));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,6 +30,12 @@ const openQueryText = () => {
|
||||
});
|
||||
};
|
||||
|
||||
const openLogs = () => {
|
||||
vscode.postMessage({
|
||||
t: 'openLogs',
|
||||
});
|
||||
};
|
||||
|
||||
export function VariantAnalysis({
|
||||
variantAnalysis: initialVariantAnalysis,
|
||||
repoStates: initialRepoStates = [],
|
||||
@@ -85,7 +91,7 @@ export function VariantAnalysis({
|
||||
onStopQueryClick={() => console.log('Stop query')}
|
||||
onCopyRepositoryListClick={() => console.log('Copy repository list')}
|
||||
onExportResultsClick={() => console.log('Export results')}
|
||||
onViewLogsClick={() => console.log('View logs')}
|
||||
onViewLogsClick={openLogs}
|
||||
/>
|
||||
<VariantAnalysisOutcomePanels
|
||||
variantAnalysis={variantAnalysis}
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
import { expect } from 'chai';
|
||||
import { parseVariantAnalysisQueryLanguage, VariantAnalysisQueryLanguage } from '../../src/remote-queries/shared/variant-analysis';
|
||||
import {
|
||||
getActionsWorkflowRunUrl,
|
||||
parseVariantAnalysisQueryLanguage,
|
||||
VariantAnalysisQueryLanguage
|
||||
} from '../../src/remote-queries/shared/variant-analysis';
|
||||
import { createMockVariantAnalysis } from '../../src/vscode-tests/factories/remote-queries/shared/variant-analysis';
|
||||
|
||||
describe('parseVariantAnalysisQueryLanguage', () => {
|
||||
it('parses a valid language', () => {
|
||||
@@ -10,3 +15,13 @@ describe('parseVariantAnalysisQueryLanguage', () => {
|
||||
expect(parseVariantAnalysisQueryLanguage('rubbish')).to.not.exist;
|
||||
});
|
||||
});
|
||||
|
||||
describe('getActionsWorkflowRunUrl', () => {
|
||||
it('should get the run url', () => {
|
||||
const variantAnalysis = createMockVariantAnalysis();
|
||||
|
||||
const actionsWorkflowRunUrl = getActionsWorkflowRunUrl(variantAnalysis);
|
||||
|
||||
expect(actionsWorkflowRunUrl).to.equal(`https://github.com/${variantAnalysis.controllerRepo.fullName}/actions/runs/${variantAnalysis.actionsWorkflowRunId}`);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user