From 873db60522fc221034a032a94a700b64874d42e5 Mon Sep 17 00:00:00 2001 From: Christopher Schleiden Date: Fri, 6 Jan 2023 15:27:25 -0800 Subject: [PATCH 1/3] Use markdown details for (expression) auto-completions --- actions-languageservice/src/complete.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/actions-languageservice/src/complete.ts b/actions-languageservice/src/complete.ts index 1dfe643..44c3c3f 100644 --- a/actions-languageservice/src/complete.ts +++ b/actions-languageservice/src/complete.ts @@ -109,7 +109,10 @@ export async function complete( const item: CompletionItem = { label: value.label, - detail: value.description, + documentation: value.description && { + kind: "markdown", + value: value.description + }, tags: value.deprecated ? [CompletionItemTag.Deprecated] : undefined, textEdit: replaceRange ? TextEdit.replace(replaceRange, newText) : TextEdit.insert(position, newText) }; @@ -212,6 +215,10 @@ function mapExpressionCompletionItem(item: ExpressionCompletionItem, charAfterPo } return { label: item.label, + documentation: item.description && { + kind: "markdown", + value: item.description + }, insertText: insertText, kind: item.function ? CompletionItemKind.Function : CompletionItemKind.Variable }; From ee41580255246cef095c00146c41edb0b957954a Mon Sep 17 00:00:00 2001 From: Christopher Schleiden Date: Fri, 6 Jan 2023 15:29:49 -0800 Subject: [PATCH 2/3] Consume expressions --- package-lock.json | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/package-lock.json b/package-lock.json index 87a5ebc..70f9e7b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -685,9 +685,9 @@ "dev": true }, "node_modules/@github/actions-expressions": { - "version": "0.0.8", - "resolved": "https://npm.pkg.github.com/download/@github/actions-expressions/0.0.8/055f455fcb0ed907f52c349b9385728aeed38f9a", - "integrity": "sha512-SPuGfnjgKAbMzJNCk4sZPAK2bxHlRXDJCk6vrwIi9VJL16Eh1YyiyM4fU9kV5EXEE5AV9aPFlZAPXu6t0mmBNw==", + "version": "0.0.9", + "resolved": "https://npm.pkg.github.com/download/@github/actions-expressions/0.0.9/9124cb4602858cf4e97ca01ec4371bac7bd278df", + "integrity": "sha512-6cgVHf2t2wYeFkF0rSZ6t65ttP+RNf2g5pL9QlA9AAkHqX1bym0yO6AzMt1XUjQn+fJN+Di+xvVJkJT4fpgSDA==", "license": "MIT", "engines": { "node": ">= 16" @@ -13526,9 +13526,9 @@ "dev": true }, "@github/actions-expressions": { - "version": "0.0.8", - "resolved": "https://npm.pkg.github.com/download/@github/actions-expressions/0.0.8/055f455fcb0ed907f52c349b9385728aeed38f9a", - "integrity": "sha512-SPuGfnjgKAbMzJNCk4sZPAK2bxHlRXDJCk6vrwIi9VJL16Eh1YyiyM4fU9kV5EXEE5AV9aPFlZAPXu6t0mmBNw==" + "version": "0.0.9", + "resolved": "https://npm.pkg.github.com/download/@github/actions-expressions/0.0.9/9124cb4602858cf4e97ca01ec4371bac7bd278df", + "integrity": "sha512-6cgVHf2t2wYeFkF0rSZ6t65ttP+RNf2g5pL9QlA9AAkHqX1bym0yO6AzMt1XUjQn+fJN+Di+xvVJkJT4fpgSDA==" }, "@github/actions-languageserver": { "version": "file:actions-languageserver", From 1b7bae144fab5763bbe5ae4566dfe0b9ab23a7c4 Mon Sep 17 00:00:00 2001 From: Christopher Schleiden Date: Fri, 6 Jan 2023 15:38:08 -0800 Subject: [PATCH 3/3] Update tests --- actions-languageservice/src/complete.test.ts | 8 ++++---- actions-languageservice/src/hover.test.ts | 6 ++---- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/actions-languageservice/src/complete.test.ts b/actions-languageservice/src/complete.test.ts index b18949e..2ba5a6f 100644 --- a/actions-languageservice/src/complete.test.ts +++ b/actions-languageservice/src/complete.test.ts @@ -1,4 +1,4 @@ -import {TextEdit} from "vscode-languageserver-types"; +import {MarkupContent, TextEdit} from "vscode-languageserver-types"; import {complete} from "./complete"; import {WorkflowContext} from "./context/workflow-context"; import {registerLogger} from "./log"; @@ -311,7 +311,7 @@ jobs: ]); // Includes detail when available. Using continue-on-error as a sample here. - expect(result.map(x => x.detail)).toContain( + expect(result.map(x => (x.documentation as MarkupContent)?.value)).toContain( "Prevents a job from failing when a step fails. Set to true to allow a job to pass when this step fails." ); }); @@ -337,7 +337,7 @@ o| const result = await complete(...getPositionFromCursor(input)); const onResult = result.find(x => x.label === "on"); expect(onResult).not.toBeUndefined(); - expect(onResult?.detail).toEqual( + expect((onResult!.documentation as MarkupContent).value).toEqual( "The name of the GitHub event that triggers the workflow. You can provide a single event string, array of events, array of event types, or an event configuration map that schedules a workflow or restricts the execution of a workflow to specific files, tags, or branch changes. For a list of available events, see https://help.github.com/en/github/automating-your-workflow-with-github-actions/events-that-trigger-workflows." ); }); @@ -348,7 +348,7 @@ o| const result = await complete(...getPositionFromCursor(input)); const dispatchResult = result.find(x => x.label === "workflow_dispatch"); expect(dispatchResult).not.toBeUndefined(); - expect(dispatchResult?.detail).toEqual( + expect((dispatchResult!.documentation as MarkupContent).value).toEqual( "You can now create workflows that are manually triggered with the new workflow_dispatch event. You will then see a 'Run workflow' button on the Actions tab, enabling you to easily trigger a run." ); }); diff --git a/actions-languageservice/src/hover.test.ts b/actions-languageservice/src/hover.test.ts index 598ed0b..c47efb8 100644 --- a/actions-languageservice/src/hover.test.ts +++ b/actions-languageservice/src/hover.test.ts @@ -1,4 +1,3 @@ -import {TextDocument} from "vscode-languageserver-textdocument"; import {hover} from "./hover"; import {getPositionFromCursor} from "./test-utils/cursor-position"; @@ -25,7 +24,6 @@ jobs: expect(result?.contents).toEqual("Runs your workflow when you push a commit or tag."); }); - it("on a parameter with a description", async () => { const input = `on: push jobs: @@ -35,7 +33,7 @@ jobs: expect(result).not.toBeUndefined(); expect(result?.contents).toEqual( "Prevents a workflow run from failing when a job fails. Set to true to allow a workflow run to pass when this job fails.\n\n" + - "**Context:** github, inputs, vars, needs, strategy, matrix" + "**Context:** github, inputs, vars, needs, strategy, matrix" ); }); @@ -52,7 +50,7 @@ jobs: }); it("on a value in a sequence", async () => { - const input = `on: [pull_request, + const input = `on: [pull_request, pu|sh] jobs: build: