Skip to content

Commit

Permalink
Publsh vscode logs to better analyze dotnet rt problems (microsoft#760)
Browse files Browse the repository at this point in the history
* Publsh vscode logs to better analyze dotnet rt problems

* Mnor changes

* Publsh logs for all extensons
  • Loading branch information
StephenWeatherford authored Jun 4, 2020
1 parent 240591d commit 2c1f27e
Show file tree
Hide file tree
Showing 10 changed files with 71 additions and 43 deletions.
28 changes: 0 additions & 28 deletions .azure-pipelines/common/publish-cache.yml

This file was deleted.

14 changes: 14 additions & 0 deletions .azure-pipelines/common/publish-logs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
steps:
- task: CopyFiles@2
displayName: "Copy logs folder to staging directory"
inputs:
Contents: "logs/**"
TargetFolder: "$(build.artifactstagingdirectory)"
condition: succeededOrFailed()

- task: PublishBuildArtifacts@1
displayName: "Publish artifacts: logs"
inputs:
PathtoPublish: "$(build.artifactstagingdirectory)"
ArtifactName: logs-$(Agent.OS)
condition: succeededOrFailed()
6 changes: 3 additions & 3 deletions .azure-pipelines/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jobs:
- template: common/build.yml
- template: common/lint.yml
- template: common/test.yml
- template: common/publish-cache.yml
- template: common/publish-logs.yml

- job: Linux
pool:
Expand All @@ -16,7 +16,7 @@ jobs:
- template: common/publish-vsix.yml # Only publish vsix from linux build since we use this to release and want to stay consistent
- template: common/lint.yml
- template: common/test.yml
- template: common/publish-cache.yml
- template: common/publish-logs.yml

- job: macOS
pool:
Expand All @@ -25,4 +25,4 @@ jobs:
- template: common/build.yml
- template: common/lint.yml
- template: common/test.yml
- template: common/publish-cache.yml
- template: common/publish-logs.yml
5 changes: 2 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,5 @@ pkgs/**
# Staged language server bits
languageServer/**

# Schema caches
pre-cache
post-cache
# Logs to publish
logs
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
],
"preLaunchTask": "npm: compile",
"env": {
"MOCHA_grep": "", // RegExp of tests to run (empty for all)
"MOCHA_grep": "deploymentt", // RegExp of tests to run (empty for all)
"MOCHA_invert": "0", // Invert the RegExp
"AZCODE_ARM_IGNORE_BUNDLE": "1",
"MOCHA_enableTimeouts": "0", // Disable time-outs
Expand Down
3 changes: 1 addition & 2 deletions .vscodeignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,4 @@ webpack.config*
*.zip
pkgs
tools
pre-cache
post-cache
logs
19 changes: 16 additions & 3 deletions test/global.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,16 @@
* Licensed under the MIT License. See LICENSE.md in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import * as fse from 'fs-extra';
import * as mocha from 'mocha';
import * as path from 'path';
import * as rimraf from 'rimraf';
import * as vscode from 'vscode';
import { armTemplateLanguageId, configKeys, configPrefix, ext } from "../extension.bundle";
import { displayCacheStatus, packageCache } from './support/clearCache';
import { displayCacheStatus, publishCache } from './support/cache';
import { delay } from "./support/delay";
import { publishVsCodeLogs } from './support/publishVsCodeLogs';
import { logsFolder } from './testConstants';
import { useTestFunctionMetadata } from "./TestData";

// tslint:disable:no-console no-function-expression
Expand All @@ -19,9 +24,14 @@ let previousSettings = {

// Runs before all tests
suiteSetup(async function (this: mocha.IHookCallbackContext): Promise<void> {
// Create logs folder
if (await fse.pathExists(logsFolder)) {
rimraf.sync(logsFolder);
}
await fse.mkdir(logsFolder);

await displayCacheStatus();
await packageCache('pre-cache');
await publishCache(path.join(logsFolder, 'pre-cache'));

// For tests, set up dotnet install path to something unusual to simulate installing with unusual usernames
process.env.ARM_DOTNET_INSTALL_FOLDER = ".dotnet O'Hare O'Donald";
Expand Down Expand Up @@ -54,7 +64,10 @@ suiteTeardown(async function (this: mocha.IHookCallbackContext): Promise<void> {
console.log('Done: global.test.ts: suiteTeardown');

await displayCacheStatus();
await packageCache('post-cache');
await publishCache(path.join(logsFolder, 'post-cache'));
// await publishVsCodeLogs('ms-dotnettools.vscode-dotnet-runtime');
// await publishVsCodeLogs(path.basename(ext.context.logPath));
await publishVsCodeLogs(undefined);

console.log('Restoring settings');
vscode.workspace.getConfiguration(configPrefix).update(configKeys.autoDetectJsonTemplates, previousSettings.autoDetectJsonTemplates, vscode.ConfigurationTarget.Global);
Expand Down
5 changes: 2 additions & 3 deletions test/support/clearCache.ts → test/support/cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import * as path from 'path';
import * as process from 'process';
import * as rimraf from 'rimraf';
import { parseError } from 'vscode-azureextensionui';
import { basePath, isWin32 } from '../../extension.bundle';
import { isWin32 } from '../../extension.bundle';

const homedir = os.homedir();
const cacheFolder = isWin32
Expand Down Expand Up @@ -62,9 +62,8 @@ export async function displayCacheStatus(): Promise<void> {
}
}

export async function packageCache(destFolderName: string): Promise<void> {
export async function publishCache(destFolderPath: string): Promise<void> {
console.log(`Copying the cache...`);
const destFolderPath = path.join(basePath, destFolderName);
const destFolderExpirationPath = path.join(destFolderPath, 'Expiration');

if (await fse.pathExists(destFolderExpirationPath)) {
Expand Down
26 changes: 26 additions & 0 deletions test/support/publishVsCodeLogs.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.md in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import * as fse from 'fs-extra';
import * as path from 'path';
import { ext } from '../../extension.bundle';
import { logsFolder } from '../testConstants';

export async function publishVsCodeLogs(extensionid: string | undefined): Promise<void> {
console.log(`Copying the vscode logs for ${extensionid ?? 'all'}...`);
const parentPath = path.dirname(ext.context.logPath);
const sourcePath = path.join(parentPath, extensionid ?? '..');
const destFolderPath = path.join(logsFolder, extensionid ?? 'all');
await fse.mkdir(destFolderPath);

if (fse.pathExistsSync(sourcePath)) {
await fse.copy(sourcePath, destFolderPath, {
recursive: true,
preserveTimestamps: true
});
} else {
console.log(` Log folder does not exist: ${sourcePath}`);
}
}
6 changes: 6 additions & 0 deletions test/testConstants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,16 @@
* Licensed under the MIT License. See LICENSE.md in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import * as path from 'path';
import { basePath } from "../extension.bundle";

// tslint:disable-next-line: strict-boolean-expressions
export const DISABLE_SLOW_TESTS = !!/^(true|1)$/i.test(process.env.DISABLE_SLOW_TESTS || '');
console.log(`DISABLE_SLOW_TESTS = ${DISABLE_SLOW_TESTS}`);

// tslint:disable-next-line: strict-boolean-expressions
export const DISABLE_LANGUAGE_SERVER: boolean = !!/^(true|1)$/i.test(process.env.DISABLE_LANGUAGE_SERVER || '') || DISABLE_SLOW_TESTS;
console.log(`DISABLE_LANGUAGE_SERVER = ${DISABLE_LANGUAGE_SERVER}`);

// This folder gets published as an artifact after the pipeline runs
export const logsFolder = path.join(basePath, 'logs');

0 comments on commit 2c1f27e

Please sign in to comment.