Skip to content

Commit

Permalink
[release] prepare v0.41.2 release
Browse files Browse the repository at this point in the history
f5d6cad extension/src/goStatus: fix quick pick for gopls trace open
53bf019 src/language: adjust panic trace capture logic
b4b68a7 README.md: use the new telemetry official doc link
361c801 extension/src/goTelemetry: increase telemetry prompt rate to 1%
0b3fabc extension/src/goMain: skip vscgo installation on windows
9480a16 extension: start v0.42.0 dev cycle
beaf5fc extension/test/gopls: allow more time for testify tests
484a195 extension/src/goTools: add golangci-lint and gofumpt version mapping
1d634bf .github/workflows: use 1.22, drop 1.18
6dd3745 docs/tools.md: fix vscgo package doc link
baab7be extension/tools/release: add test for rc
7bfbcaf src/goTest: fix multifile suite test fails to debug

Change-Id: I966aaac48ecb67b22824bd7b3600bf90d983a039
  • Loading branch information
hyangah committed Mar 13, 2024
2 parents 2ba3f68 + f5d6cad commit 5bbfaf9
Show file tree
Hide file tree
Showing 29 changed files with 459 additions and 103 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test-long-all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
version: ['stable', 'insiders']
go: ['1.18', '1.19', '1.20', '1.21']
go: ['1.19', '1.20', '1.21', '1.22']

steps:
- name: Clone repository
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-long.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
matrix:
os: [ubuntu-latest, windows-latest] # TODO: reenable macos-latest
version: ['stable']
go: ['1.18', '1.19', '1.20', '1.21']
go: ['1.19', '1.20', '1.21', '1.22']

steps:
- name: Clone repository
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-smoke.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: '1.21'
go-version: '1.22'
check-latest: true
cache: true

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/wiki.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: '1.21'
go-version: '1.22'
check-latest: true
cache: true
cache-dependency-path: '**/go.sum'
Expand Down
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ nightly build of this extension. Learn how to install it in by reading the

## Telemetry

VS Code Go extension relies on the [Go Telemetry](https://telemetry.go.dev) to
VS Code Go extension relies on the [Go Telemetry](https://go.dev/doc/telemetry) to
learn insights about the performance and stability of the extension and the
language server (`gopls`).
**Go Telemetry data uploading is disabled by default** and can be enabled
Expand Down Expand Up @@ -171,9 +171,8 @@ of reliability. For example:
These are just a few ways that telemetry can improve gopls. The [telemetry blog
post series](https://research.swtch.com/telemetry-uses) contains many more.

Go telemetry is designed to be transparent and privacy-preserving. If you have
concerns about enabling telemetry, you can learn more at
[https://telemetry.go.dev/privacy](https://telemetry.go.dev/privacy).
Go telemetry is designed to be transparent and privacy-preserving. Learn more at
[https://go.dev/doc/telemetry](https://go.dev/doc/telemetry).

## Contributing

Expand Down
7 changes: 7 additions & 0 deletions extension/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## v0.41.2 - 14 Mar, 2024

This release is a point release to increase the prompt rate of Go telemetry
opt-in. Learn more at https://go.dev/doc/telemetry.
For a detailed list of changes, refer to the complete
[commit history](https://github.com/golang/vscode-go/compare/v0.41.1...v0.41.2).

## v0.41.1 - 22 Feb, 2024

This release is a point release to skip `vscgo` installation on Windows
Expand Down
4 changes: 2 additions & 2 deletions extension/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion extension/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "go",
"displayName": "Go",
"version": "0.41.1",
"version": "0.41.2",
"publisher": "golang",
"description": "Rich Go language support for Visual Studio Code",
"author": {
Expand Down
2 changes: 1 addition & 1 deletion extension/src/goStatus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ export const expandGoStatusBar: CommandFactory = (ctx, goCtx) => async () => {
case 'Choose Go Environment':
vscode.commands.executeCommand('go.environment.choose');
break;
case `${languageServerIcon}Open 'gopls' trace`:
case `${languageServerIcon} Open 'gopls' trace`:
if (serverOutputChannel) {
serverOutputChannel.show();
}
Expand Down
2 changes: 1 addition & 1 deletion extension/src/goTelemetry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ export class TelemetryService {
async promptForTelemetry(
isPreviewExtension: boolean,
isVSCodeTelemetryEnabled: boolean = vscode.env.isTelemetryEnabled,
samplingInterval = 1 /* prompt N out of 1000. 1 = 0.1% */
samplingInterval = 10 /* prompt N out of 1000. 10 = 1% */
) {
if (!this.active) return;

Expand Down
31 changes: 19 additions & 12 deletions extension/src/goTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@ import {
getBenchmarkFunctions,
getTestFlags,
getTestFunctionDebugArgs,
getTestFunctions,
getTestFunctionsAndTestSuite,
getTestTags,
goTest,
TestConfig
TestConfig,
SuiteToTestMap,
getTestFunctions
} from './testUtils';

// lastTestConfig holds a reference to the last executed TestConfig which allows
Expand Down Expand Up @@ -52,8 +54,11 @@ async function _testAtCursor(
throw new NotFoundError('No tests found. Current file is not a test file.');
}

const getFunctions = cmd === 'benchmark' ? getBenchmarkFunctions : getTestFunctions;
const testFunctions = (await getFunctions(goCtx, editor.document)) ?? [];
const { testFunctions, suiteToTest } = await getTestFunctionsAndTestSuite(
cmd === 'benchmark',
goCtx,
editor.document
);
// We use functionName if it was provided as argument
// Otherwise find any test function containing the cursor.
const testFunctionName =
Expand All @@ -67,9 +72,9 @@ async function _testAtCursor(
await editor.document.save();

if (cmd === 'debug') {
return debugTestAtCursor(editor, testFunctionName, testFunctions, goConfig);
return debugTestAtCursor(editor, testFunctionName, testFunctions, suiteToTest, goConfig);
} else if (cmd === 'benchmark' || cmd === 'test') {
return runTestAtCursor(editor, testFunctionName, testFunctions, goConfig, cmd, args);
return runTestAtCursor(editor, testFunctionName, testFunctions, suiteToTest, goConfig, cmd, args);
} else {
throw new Error(`Unsupported command: ${cmd}`);
}
Expand All @@ -92,7 +97,7 @@ async function _subTestAtCursor(
}

await editor.document.save();
const testFunctions = (await getTestFunctions(goCtx, editor.document)) ?? [];
const { testFunctions, suiteToTest } = await getTestFunctionsAndTestSuite(false, goCtx, editor.document);
// We use functionName if it was provided as argument
// Otherwise find any test function containing the cursor.
const currentTestFunctions = testFunctions.filter((func) => func.range.contains(editor.selection.start));
Expand Down Expand Up @@ -142,9 +147,9 @@ async function _subTestAtCursor(
const escapedName = escapeSubTestName(testFunctionName, subTestName);

if (cmd === 'debug') {
return debugTestAtCursor(editor, escapedName, testFunctions, goConfig);
return debugTestAtCursor(editor, escapedName, testFunctions, suiteToTest, goConfig);
} else if (cmd === 'test') {
return runTestAtCursor(editor, escapedName, testFunctions, goConfig, cmd, args);
return runTestAtCursor(editor, escapedName, testFunctions, suiteToTest, goConfig, cmd, args);
} else {
throw new Error(`Unsupported command: ${cmd}`);
}
Expand All @@ -160,7 +165,7 @@ async function _subTestAtCursor(
export function testAtCursor(cmd: TestAtCursorCmd): CommandFactory {
return (ctx, goCtx) => (args: any) => {
const goConfig = getGoConfig();
_testAtCursor(goCtx, goConfig, cmd, args).catch((err) => {
return _testAtCursor(goCtx, goConfig, cmd, args).catch((err) => {
if (err instanceof NotFoundError) {
vscode.window.showInformationMessage(err.message);
} else {
Expand Down Expand Up @@ -202,13 +207,14 @@ async function runTestAtCursor(
editor: vscode.TextEditor,
testFunctionName: string,
testFunctions: vscode.DocumentSymbol[],
suiteToTest: SuiteToTestMap,
goConfig: vscode.WorkspaceConfiguration,
cmd: TestAtCursorCmd,
args: any
) {
const testConfigFns = [testFunctionName];
if (cmd !== 'benchmark' && extractInstanceTestName(testFunctionName)) {
testConfigFns.push(...findAllTestSuiteRuns(editor.document, testFunctions).map((t) => t.name));
testConfigFns.push(...findAllTestSuiteRuns(editor.document, testFunctions, suiteToTest).map((t) => t.name));
}

const isMod = await isModSupported(editor.document.uri);
Expand Down Expand Up @@ -259,11 +265,12 @@ export async function debugTestAtCursor(
editorOrDocument: vscode.TextEditor | vscode.TextDocument,
testFunctionName: string,
testFunctions: vscode.DocumentSymbol[],
suiteToFunc: SuiteToTestMap,
goConfig: vscode.WorkspaceConfiguration,
sessionID?: string
) {
const doc = 'document' in editorOrDocument ? editorOrDocument.document : editorOrDocument;
const args = getTestFunctionDebugArgs(doc, testFunctionName, testFunctions);
const args = getTestFunctionDebugArgs(doc, testFunctionName, testFunctions, suiteToFunc);
const tags = getTestTags(goConfig);
const buildFlags = tags ? ['-tags', tags] : [];
const flagsFromConfig = getTestFlags(goConfig);
Expand Down
12 changes: 8 additions & 4 deletions extension/src/goTest/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import vscode = require('vscode');
import { outputChannel } from '../goStatus';
import { isModSupported } from '../goModules';
import { getGoConfig } from '../config';
import { getBenchmarkFunctions, getTestFlags, getTestFunctions, goTest, GoTestOutput } from '../testUtils';
import { getTestFlags, getTestFunctionsAndTestSuite, goTest, GoTestOutput } from '../testUtils';
import { GoTestResolver } from './resolve';
import { dispose, forEachAsync, GoTest, Workspace } from './utils';
import { GoTestProfiler, ProfilingOptions } from './profile';
Expand Down Expand Up @@ -161,8 +161,11 @@ export class GoTestRunner {
await doc.save();

const goConfig = getGoConfig(test.uri);
const getFunctions = kind === 'benchmark' ? getBenchmarkFunctions : getTestFunctions;
const testFunctions = await getFunctions(this.goCtx, doc, token);
const { testFunctions, suiteToTest } = await getTestFunctionsAndTestSuite(
kind === 'benchmark',
this.goCtx,
doc
);

// TODO Can we get output from the debug session, in order to check for
// run/pass/fail events?
Expand Down Expand Up @@ -191,7 +194,8 @@ export class GoTestRunner {

const run = this.ctrl.createTestRun(request, `Debug ${name}`);
if (!testFunctions) return;
const started = await debugTestAtCursor(doc, escapeSubTestName(name), testFunctions, goConfig, id);
const started = await debugTestAtCursor(doc, escapeSubTestName(name), testFunctions, suiteToTest, goConfig, id);

if (!started) {
subs.forEach((s) => s.dispose());
run.end();
Expand Down
3 changes: 3 additions & 0 deletions extension/src/goTools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,13 @@ export function getImportPathWithVersion(
}
if (tool.name === 'gofumpt') {
if (goVersion.lt('1.18')) return importPath + '@v0.2.1';
if (goVersion.lt('1.19')) return importPath + '@v0.4.0';
if (goVersion.lt('1.20')) return importPath + '@v0.5.0';
}
if (tool.name === 'golangci-lint') {
if (goVersion.lt('1.18')) return importPath + '@v1.47.3';
if (goVersion.lt('1.20')) return importPath + '@v1.53.3';
if (goVersion.lt('1.21')) return importPath + '@v1.55.2';
}
if (tool.defaultVersion) {
return importPath + '@' + tool.defaultVersion;
Expand Down
2 changes: 1 addition & 1 deletion extension/src/goToolsInformation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export const allToolsInformation: { [key: string]: Tool } = {
replacedByGopls: true,
isImportant: false,
description: 'Formatter',
defaultVersion: 'v0.5.0'
defaultVersion: 'v0.6.0'
},
'goimports': {
name: 'goimports',
Expand Down
68 changes: 33 additions & 35 deletions extension/src/language/goLanguageServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1530,7 +1530,6 @@ async function collectGoplsLog(goCtx: GoExtensionContext): Promise<{ sanitizedLo
enum GoplsFailureModes {
NO_GOPLS_LOG = 'no gopls log',
EMPTY_PANIC_TRACE = 'empty panic trace',
INCOMPLETE_PANIC_TRACE = 'incomplete panic trace',
INCORRECT_COMMAND_USAGE = 'incorrect gopls command usage',
UNRECOGNIZED_CRASH_PATTERN = 'unrecognized crash pattern'
}
Expand All @@ -1544,34 +1543,40 @@ export function sanitizeGoplsTrace(logs?: string): { sanitizedLog?: string; fail
const panicMsgBegin = logs.lastIndexOf('panic: ');
if (panicMsgBegin > -1) {
// panic message was found.
const panicMsgEnd = logs.indexOf('Connection to server got closed.', panicMsgBegin);
let panicTrace = logs.substr(panicMsgBegin);
const panicMsgEnd = panicTrace.search(/\[(Info|Warning|Error)\s+-\s+/);
if (panicMsgEnd > -1) {
const panicTrace = logs.substr(panicMsgBegin, panicMsgEnd - panicMsgBegin);
const filePattern = /(\S+\.go):\d+/;
const sanitized = panicTrace
.split('\n')
.map((line: string) => {
// Even though this is a crash from gopls, the file path
// can contain user names and user's filesystem directory structure.
// We can still locate the corresponding file if the file base is
// available because the full package path is part of the function
// name. So, leave only the file base.
const m = line.match(filePattern);
if (!m) {
return line;
}
const filePath = m[1];
const fileBase = path.basename(filePath);
return line.replace(filePath, ' ' + fileBase);
})
.join('\n');

if (sanitized) {
return { sanitizedLog: sanitized };
}
return { failureReason: GoplsFailureModes.EMPTY_PANIC_TRACE };
panicTrace = panicTrace.substr(0, panicMsgEnd);
}
const filePattern = /(\S+\.go):\d+/;
const sanitized = panicTrace
.split('\n')
.map((line: string) => {
// Even though this is a crash from gopls, the file path
// can contain user names and user's filesystem directory structure.
// We can still locate the corresponding file if the file base is
// available because the full package path is part of the function
// name. So, leave only the file base.
const m = line.match(filePattern);
if (!m) {
return line;
}
const filePath = m[1];
const fileBase = path.basename(filePath);
return line.replace(filePath, ' ' + fileBase);
})
.join('\n');

if (sanitized) {
return { sanitizedLog: sanitized };
}
return { failureReason: GoplsFailureModes.INCOMPLETE_PANIC_TRACE };
return { failureReason: GoplsFailureModes.EMPTY_PANIC_TRACE };
}
// Capture Fatal
// foo.go:1: the last message (caveat - we capture only the first log line)
const m = logs.match(/(^\S+\.go:\d+:.*$)/gm);
if (m && m.length > 0) {
return { sanitizedLog: m[0].toString() };
}
const initFailMsgBegin = logs.lastIndexOf('gopls client:');
if (initFailMsgBegin > -1) {
Expand All @@ -1590,13 +1595,6 @@ export function sanitizeGoplsTrace(logs?: string): { sanitizedLog?: string; fail
if (logs.lastIndexOf('Usage:') > -1) {
return { failureReason: GoplsFailureModes.INCORRECT_COMMAND_USAGE };
}
// Capture Fatal
// foo.go:1: the last message (caveat - we capture only the first log line)
const m = logs.match(/(^\S+\.go:\d+:.*$)/gm);
if (m && m.length > 0) {
return { sanitizedLog: m[0].toString() };
}

return { failureReason: GoplsFailureModes.UNRECOGNIZED_CRASH_PATTERN };
}

Expand Down Expand Up @@ -1664,6 +1662,6 @@ async function getGoplsStats(binpath?: string) {
} catch (e) {
const duration = new Date().getTime() - start.getTime();
console.log(`gopls stats -anon failed: ${JSON.stringify(e)}`);
return `gopls stats -anon failed after running for ${duration}ms`; // e may contain user information. don't include in the report.
return `gopls stats -anon failed after ${duration} ms. Please check if gopls is killed by OS.`;
}
}
Loading

0 comments on commit 5bbfaf9

Please sign in to comment.