Merge branch 'main' into cschleiden/events-without-default-types
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "browser-playground",
|
||||
"version": "0.1.173",
|
||||
"version": "0.1.174",
|
||||
"description": "",
|
||||
"private": true,
|
||||
"main": "index.js",
|
||||
"type": "module",
|
||||
"dependencies": {
|
||||
"@github/actions-languageserver": "^0.1.173",
|
||||
"@github/actions-languageserver": "^0.1.174",
|
||||
"monaco-editor-webpack-plugin": "^7.0.1",
|
||||
"monaco-editor-workers": "^0.34.2",
|
||||
"monaco-languageclient": "^4.0.3",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@github/actions-expressions",
|
||||
"version": "0.1.173",
|
||||
"version": "0.1.174",
|
||||
"license": "MIT",
|
||||
"type": "module",
|
||||
"source": "./src/index.ts",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@github/actions-languageserver",
|
||||
"version": "0.1.173",
|
||||
"version": "0.1.174",
|
||||
"description": "Language server for GitHub Actions",
|
||||
"license": "MIT",
|
||||
"type": "module",
|
||||
@@ -40,8 +40,8 @@
|
||||
"watch": "tsc --build tsconfig.build.json --watch"
|
||||
},
|
||||
"dependencies": {
|
||||
"@github/actions-languageservice": "^0.1.173",
|
||||
"@github/actions-workflow-parser": "^0.1.173",
|
||||
"@github/actions-languageservice": "^0.1.174",
|
||||
"@github/actions-workflow-parser": "^0.1.174",
|
||||
"@octokit/rest": "^19.0.7",
|
||||
"@octokit/types": "^9.0.0",
|
||||
"vscode-languageserver": "^8.0.2",
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import {documentLinks, hover, validate, ValidationConfig} from "@github/actions-languageservice";
|
||||
import {registerLogger, setLogLevel} from "@github/actions-languageservice/log";
|
||||
import {clearCache, clearCacheEntry} from "@github/actions-languageservice/utils/workflow-cache";
|
||||
import {Octokit} from "@octokit/rest";
|
||||
import {
|
||||
CompletionItem,
|
||||
@@ -28,7 +29,6 @@ import {fetchActionMetadata} from "./utils/action-metadata";
|
||||
import {TTLCache} from "./utils/cache";
|
||||
import {timeOperation} from "./utils/timer";
|
||||
import {valueProviders} from "./value-providers";
|
||||
import {clearCacheEntry, clearCache} from "@github/actions-languageservice/utils/workflow-cache";
|
||||
|
||||
export function initConnection(connection: Connection) {
|
||||
const documents: TextDocuments<TextDocument> = new TextDocuments(TextDocument);
|
||||
@@ -165,7 +165,8 @@ export function initConnection(connection: Connection) {
|
||||
});
|
||||
|
||||
connection.onDocumentLinks(async ({textDocument}: DocumentLinkParams): Promise<DocumentLink[] | null> => {
|
||||
return documentLinks(documents.get(textDocument.uri)!);
|
||||
const repoContext = repos.find(repo => textDocument.uri.startsWith(repo.workspaceUri));
|
||||
return documentLinks(documents.get(textDocument.uri)!, repoContext?.workspaceUri);
|
||||
});
|
||||
|
||||
// Make the text document manager listen on the connection
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@github/actions-languageservice",
|
||||
"version": "0.1.173",
|
||||
"version": "0.1.174",
|
||||
"description": "Language service for GitHub Actions",
|
||||
"license": "MIT",
|
||||
"type": "module",
|
||||
@@ -41,10 +41,11 @@
|
||||
"watch": "tsc --build tsconfig.build.json --watch"
|
||||
},
|
||||
"dependencies": {
|
||||
"@github/actions-expressions": "^0.1.173",
|
||||
"@github/actions-workflow-parser": "^0.1.173",
|
||||
"@github/actions-expressions": "^0.1.174",
|
||||
"@github/actions-workflow-parser": "^0.1.174",
|
||||
"vscode-languageserver-textdocument": "^1.0.7",
|
||||
"vscode-languageserver-types": "^3.17.2",
|
||||
"vscode-uri": "^3.0.7",
|
||||
"yaml": "^2.1.1"
|
||||
},
|
||||
"engines": {
|
||||
|
||||
@@ -14,7 +14,7 @@ jobs:
|
||||
runs-on: [self-hosted]
|
||||
steps:
|
||||
- run: echo "Hello World"`;
|
||||
const result = await documentLinks(createDocument("test.yaml", input));
|
||||
const result = await documentLinks(createDocument("test.yaml", input), undefined);
|
||||
expect(result).toHaveLength(0);
|
||||
});
|
||||
|
||||
@@ -23,7 +23,7 @@ jobs:
|
||||
jobs:
|
||||
build:
|
||||
runs-on: [self-hosted]`;
|
||||
const result = await documentLinks(createDocument("test.yaml", input));
|
||||
const result = await documentLinks(createDocument("test.yaml", input), undefined);
|
||||
expect(result).toHaveLength(0);
|
||||
});
|
||||
|
||||
@@ -36,7 +36,7 @@ jobs:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v3
|
||||
- uses: github/codeql-action/init@v2`;
|
||||
const result = await documentLinks(createDocument("test.yaml", input));
|
||||
const result = await documentLinks(createDocument("test.yaml", input), undefined);
|
||||
expect(result).toEqual([
|
||||
{
|
||||
range: {
|
||||
@@ -82,4 +82,51 @@ jobs:
|
||||
}
|
||||
]);
|
||||
});
|
||||
|
||||
it("links for reusable local workflow", async () => {
|
||||
const input = `on: push
|
||||
jobs:
|
||||
build:
|
||||
uses: ./.github/workflows/reusable-workflow.yml`;
|
||||
const result = await documentLinks(createDocument("test.yaml", input), "file:///workspace/");
|
||||
expect(result).toEqual([
|
||||
{
|
||||
range: {
|
||||
end: {
|
||||
character: 51,
|
||||
line: 3
|
||||
},
|
||||
start: {
|
||||
character: 10,
|
||||
line: 3
|
||||
}
|
||||
},
|
||||
target: "file:///workspace/.github/workflows/reusable-workflow.yml"
|
||||
}
|
||||
]);
|
||||
});
|
||||
|
||||
it("links for reusable remote workflow", async () => {
|
||||
const input = `on: push
|
||||
jobs:
|
||||
build:
|
||||
uses: seismis-rainier/workflows/reusable-workflow.yml@main`;
|
||||
const result = await documentLinks(createDocument("test.yaml", input), "file:///workspace/");
|
||||
expect(result).toEqual([
|
||||
{
|
||||
range: {
|
||||
end: {
|
||||
character: 62,
|
||||
line: 3
|
||||
},
|
||||
start: {
|
||||
character: 10,
|
||||
line: 3
|
||||
}
|
||||
},
|
||||
target: "https://www.github.com/seismis-rainier/workflows/tree/main/reusable-workflow.yml",
|
||||
tooltip: "Open reusable workflow on GitHub"
|
||||
}
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,13 +1,15 @@
|
||||
import {ErrorPolicy} from "@github/actions-workflow-parser/model/convert";
|
||||
import {isJob} from "@github/actions-workflow-parser/model/type-guards";
|
||||
import {isJob, isReusableWorkflowJob} from "@github/actions-workflow-parser/model/type-guards";
|
||||
import {File} from "@github/actions-workflow-parser/workflows/file";
|
||||
import {parseFileReference} from "@github/actions-workflow-parser/workflows/file-reference";
|
||||
import {TextDocument} from "vscode-languageserver-textdocument";
|
||||
import {DocumentLink} from "vscode-languageserver-types";
|
||||
import vscodeURI from "vscode-uri/lib/umd"; // work around issues with the vscode-uri package
|
||||
import {actionUrl, parseActionReference} from "./action";
|
||||
import {mapRange} from "./utils/range";
|
||||
import {fetchOrParseWorkflow, fetchOrConvertWorkflowTemplate} from "./utils/workflow-cache";
|
||||
import {fetchOrConvertWorkflowTemplate, fetchOrParseWorkflow} from "./utils/workflow-cache";
|
||||
|
||||
export async function documentLinks(document: TextDocument): Promise<DocumentLink[]> {
|
||||
export async function documentLinks(document: TextDocument, workspace: string | undefined): Promise<DocumentLink[]> {
|
||||
const file: File = {
|
||||
name: document.uri,
|
||||
content: document.getText()
|
||||
@@ -22,30 +24,61 @@ export async function documentLinks(document: TextDocument): Promise<DocumentLin
|
||||
errorPolicy: ErrorPolicy.TryConversion
|
||||
});
|
||||
|
||||
// Add links to referenced actions
|
||||
const actionLinks: DocumentLink[] = [];
|
||||
const links: DocumentLink[] = [];
|
||||
|
||||
for (const job of template?.jobs || []) {
|
||||
if (!job || !isJob(job)) {
|
||||
if (!job) {
|
||||
continue;
|
||||
}
|
||||
for (const step of job.steps || []) {
|
||||
if ("uses" in step) {
|
||||
const actionRef = parseActionReference(step.uses.value);
|
||||
if (!actionRef) {
|
||||
continue;
|
||||
|
||||
if (isJob(job)) {
|
||||
// Add links to referenced actions
|
||||
for (const step of job.steps || []) {
|
||||
if ("uses" in step) {
|
||||
const actionRef = parseActionReference(step.uses.value);
|
||||
if (!actionRef) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const url = actionUrl(actionRef);
|
||||
|
||||
links.push({
|
||||
range: mapRange(step.uses.range),
|
||||
target: url,
|
||||
tooltip: `Open action on GitHub`
|
||||
});
|
||||
}
|
||||
}
|
||||
} else if (isReusableWorkflowJob(job)) {
|
||||
// Add links to referenced reusable workflows
|
||||
const ref = parseFileReference(job.ref.value);
|
||||
if ("repository" in ref) {
|
||||
// Remote workflow
|
||||
const url = actionUrl({
|
||||
owner: ref.owner,
|
||||
name: ref.repository,
|
||||
path: ref.path,
|
||||
ref: ref.version
|
||||
});
|
||||
|
||||
const url = actionUrl(actionRef);
|
||||
|
||||
actionLinks.push({
|
||||
range: mapRange(step.uses.range),
|
||||
links.push({
|
||||
range: mapRange(job.ref.range),
|
||||
target: url,
|
||||
tooltip: `Open action on GitHub`
|
||||
tooltip: `Open reusable workflow on GitHub`
|
||||
});
|
||||
} else if (workspace) {
|
||||
// We need workspace information to generate this link
|
||||
// Local workflow, generate workspace link
|
||||
const workspaceURI = vscodeURI.URI.parse(workspace);
|
||||
const refURI = vscodeURI.Utils.joinPath(workspaceURI, job.ref.value);
|
||||
|
||||
links.push({
|
||||
range: mapRange(job.ref.range),
|
||||
target: refURI.toString()
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return [...actionLinks];
|
||||
return [...links];
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"$schema": "node_modules/lerna/schemas/lerna-schema.json",
|
||||
"useWorkspaces": true,
|
||||
"version": "0.1.173"
|
||||
"version": "0.1.174"
|
||||
}
|
||||
|
||||
Generated
+29
-17
@@ -111,10 +111,10 @@
|
||||
}
|
||||
},
|
||||
"browser-playground": {
|
||||
"version": "0.1.173",
|
||||
"version": "0.1.174",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@github/actions-languageserver": "^0.1.173",
|
||||
"@github/actions-languageserver": "^0.1.174",
|
||||
"monaco-editor-webpack-plugin": "^7.0.1",
|
||||
"monaco-editor-workers": "^0.34.2",
|
||||
"monaco-languageclient": "^4.0.3",
|
||||
@@ -135,7 +135,7 @@
|
||||
},
|
||||
"expressions": {
|
||||
"name": "@github/actions-expressions",
|
||||
"version": "0.1.173",
|
||||
"version": "0.1.174",
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"@types/jest": "^29.0.3",
|
||||
@@ -151,11 +151,11 @@
|
||||
},
|
||||
"languageserver": {
|
||||
"name": "@github/actions-languageserver",
|
||||
"version": "0.1.173",
|
||||
"version": "0.1.174",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@github/actions-languageservice": "^0.1.173",
|
||||
"@github/actions-workflow-parser": "^0.1.173",
|
||||
"@github/actions-languageservice": "^0.1.174",
|
||||
"@github/actions-workflow-parser": "^0.1.174",
|
||||
"@octokit/rest": "^19.0.7",
|
||||
"@octokit/types": "^9.0.0",
|
||||
"vscode-languageserver": "^8.0.2",
|
||||
@@ -190,13 +190,14 @@
|
||||
},
|
||||
"languageservice": {
|
||||
"name": "@github/actions-languageservice",
|
||||
"version": "0.1.173",
|
||||
"version": "0.1.174",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@github/actions-expressions": "^0.1.173",
|
||||
"@github/actions-workflow-parser": "^0.1.173",
|
||||
"@github/actions-expressions": "^0.1.174",
|
||||
"@github/actions-workflow-parser": "^0.1.174",
|
||||
"vscode-languageserver-textdocument": "^1.0.7",
|
||||
"vscode-languageserver-types": "^3.17.2",
|
||||
"vscode-uri": "^3.0.7",
|
||||
"yaml": "^2.1.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
@@ -13566,6 +13567,11 @@
|
||||
"integrity": "sha512-9hJp0xL7HW1Q5OgGe03NACo7yiCTMEk3WU/rtKXUbncLtdg6rVVNJnHwD88UhbIYU2KoxY0Dih0x+kIsmUKn2A==",
|
||||
"peer": true
|
||||
},
|
||||
"node_modules/vscode-uri": {
|
||||
"version": "3.0.7",
|
||||
"resolved": "https://registry.npmjs.org/vscode-uri/-/vscode-uri-3.0.7.tgz",
|
||||
"integrity": "sha512-eOpPHogvorZRobNqJGhapa0JdwaxpjVvyBp0QIUMRMSf8ZAlqOdEquKuRmw9Qwu0qXtJIWqFtMkmvJjUZmMjVA=="
|
||||
},
|
||||
"node_modules/walk-up-path": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/walk-up-path/-/walk-up-path-1.0.0.tgz",
|
||||
@@ -14279,10 +14285,10 @@
|
||||
},
|
||||
"workflow-parser": {
|
||||
"name": "@github/actions-workflow-parser",
|
||||
"version": "0.1.173",
|
||||
"version": "0.1.174",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@github/actions-expressions": "^0.1.173",
|
||||
"@github/actions-expressions": "^0.1.174",
|
||||
"cronstrue": "^2.21.0",
|
||||
"yaml": "^2.0.0-8"
|
||||
},
|
||||
@@ -14841,8 +14847,8 @@
|
||||
"@github/actions-languageserver": {
|
||||
"version": "file:languageserver",
|
||||
"requires": {
|
||||
"@github/actions-languageservice": "^0.1.173",
|
||||
"@github/actions-workflow-parser": "^0.1.173",
|
||||
"@github/actions-languageservice": "^0.1.174",
|
||||
"@github/actions-workflow-parser": "^0.1.174",
|
||||
"@octokit/rest": "^19.0.7",
|
||||
"@octokit/types": "^9.0.0",
|
||||
"@types/jest": "^29.0.3",
|
||||
@@ -14875,8 +14881,8 @@
|
||||
"@github/actions-languageservice": {
|
||||
"version": "file:languageservice",
|
||||
"requires": {
|
||||
"@github/actions-expressions": "^0.1.173",
|
||||
"@github/actions-workflow-parser": "^0.1.173",
|
||||
"@github/actions-expressions": "^0.1.174",
|
||||
"@github/actions-workflow-parser": "^0.1.174",
|
||||
"@types/jest": "^29.0.3",
|
||||
"jest": "^29.0.3",
|
||||
"prettier": "^2.8.3",
|
||||
@@ -14887,13 +14893,14 @@
|
||||
"typescript": "^4.8.4",
|
||||
"vscode-languageserver-textdocument": "^1.0.7",
|
||||
"vscode-languageserver-types": "^3.17.2",
|
||||
"vscode-uri": "^3.0.7",
|
||||
"yaml": "^2.1.1"
|
||||
}
|
||||
},
|
||||
"@github/actions-workflow-parser": {
|
||||
"version": "file:workflow-parser",
|
||||
"requires": {
|
||||
"@github/actions-expressions": "^0.1.173",
|
||||
"@github/actions-expressions": "^0.1.174",
|
||||
"@types/jest": "^29.0.3",
|
||||
"@typescript-eslint/eslint-plugin": "^5.40.0",
|
||||
"@typescript-eslint/parser": "^5.40.0",
|
||||
@@ -17887,7 +17894,7 @@
|
||||
"browser-playground": {
|
||||
"version": "file:browser-playground",
|
||||
"requires": {
|
||||
"@github/actions-languageserver": "^0.1.173",
|
||||
"@github/actions-languageserver": "^0.1.174",
|
||||
"css-loader": "^6.7.2",
|
||||
"monaco-editor-webpack-plugin": "^7.0.1",
|
||||
"monaco-editor-workers": "^0.34.2",
|
||||
@@ -24672,6 +24679,11 @@
|
||||
"integrity": "sha512-9hJp0xL7HW1Q5OgGe03NACo7yiCTMEk3WU/rtKXUbncLtdg6rVVNJnHwD88UhbIYU2KoxY0Dih0x+kIsmUKn2A==",
|
||||
"peer": true
|
||||
},
|
||||
"vscode-uri": {
|
||||
"version": "3.0.7",
|
||||
"resolved": "https://registry.npmjs.org/vscode-uri/-/vscode-uri-3.0.7.tgz",
|
||||
"integrity": "sha512-eOpPHogvorZRobNqJGhapa0JdwaxpjVvyBp0QIUMRMSf8ZAlqOdEquKuRmw9Qwu0qXtJIWqFtMkmvJjUZmMjVA=="
|
||||
},
|
||||
"walk-up-path": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/walk-up-path/-/walk-up-path-1.0.0.tgz",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@github/actions-workflow-parser",
|
||||
"version": "0.1.173",
|
||||
"version": "0.1.174",
|
||||
"license": "MIT",
|
||||
"type": "module",
|
||||
"source": "./src/index.ts",
|
||||
@@ -40,7 +40,7 @@
|
||||
"watch": "tsc --build tsconfig.build.json --watch"
|
||||
},
|
||||
"dependencies": {
|
||||
"@github/actions-expressions": "^0.1.173",
|
||||
"@github/actions-expressions": "^0.1.174",
|
||||
"cronstrue": "^2.21.0",
|
||||
"yaml": "^2.0.0-8"
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user