Merge branch 'main' into joshmgross/action-inputs-provider

This commit is contained in:
Josh Gross
2022-12-12 19:43:10 -05:00
8 changed files with 92 additions and 24 deletions
+2 -2
View File
@@ -1,6 +1,6 @@
{
"name": "@github/actions-languageserver",
"version": "0.1.49",
"version": "0.1.50",
"description": "Language server for GitHub Actions",
"license": "MIT",
"type": "module",
@@ -38,7 +38,7 @@
"prettier-fix": "prettier --write ."
},
"dependencies": {
"@github/actions-languageservice": "^0.1.49",
"@github/actions-languageservice": "^0.1.50",
"@github/actions-workflow-parser": "*",
"@octokit/rest": "^19.0.5",
"vscode-languageserver": "^8.0.2",
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@github/actions-languageservice",
"version": "0.1.49",
"version": "0.1.50",
"description": "Language service for GitHub Actions",
"license": "MIT",
"type": "module",
@@ -36,7 +36,7 @@ describe("expressions", () => {
describe("top-level auto-complete", () => {
it("single region", async () => {
const input = "run-name: ${{ | }}";
const result = await complete(...getPositionFromCursor(input), undefined, contextProviderConfig);
const result = await complete(...getPositionFromCursor(input), undefined, undefined);
expect(result.map(x => x.label)).toEqual([
"github",
@@ -320,6 +320,23 @@ jobs:
expect(result).toEqual([]);
});
it("github context includes expected keys", async () => {
const input = `
on: push
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: echo \${{ github.| }}
`;
const result = await complete(...getPositionFromCursor(input), undefined, undefined);
expect(result.map(x => x.label)).toContain("actor");
});
describe("steps context", () => {
it("includes defined step IDs", async () => {
const input = `
@@ -2,6 +2,7 @@ import {data} from "@github/actions-expressions";
import {Kind} from "@github/actions-expressions/data/expressiondata";
import {WorkflowContext} from "../context/workflow-context";
import {ContextProviderConfig} from "./config";
import {getGithubContext} from "./github";
import {getInputsContext} from "./inputs";
import {getMatrixContext} from "./matrix";
import {getNeedsContext} from "./needs";
@@ -44,6 +45,18 @@ export async function getContext(
function getDefaultContext(name: string, workflowContext: WorkflowContext, mode: Mode): ContextValue | undefined {
switch (name) {
case "github":
return getGithubContext();
case "inputs":
return getInputsContext(workflowContext);
case "matrix":
return getMatrixContext(workflowContext, mode);
case "needs":
return getNeedsContext(workflowContext);
case "runner":
return objectToDictionary({
os: "Linux",
@@ -53,12 +66,6 @@ function getDefaultContext(name: string, workflowContext: WorkflowContext, mode:
temp: "/home/runner/work/_temp"
});
case "needs":
return getNeedsContext(workflowContext);
case "inputs":
return getInputsContext(workflowContext);
case "secrets":
return objectToDictionary({GITHUB_TOKEN: "***"});
@@ -67,9 +74,6 @@ function getDefaultContext(name: string, workflowContext: WorkflowContext, mode:
case "strategy":
return getStrategyContext(workflowContext);
case "matrix":
return getMatrixContext(workflowContext, mode);
}
return undefined;
@@ -0,0 +1,47 @@
import {data} from "@github/actions-expressions";
export function getGithubContext(): data.Dictionary {
// https://docs.github.com/en/actions/learn-github-actions/contexts#github-context
const keys = [
"action",
"action_path",
"action_ref",
"action_repository",
"action_status",
"actor",
"api_url",
"base_ref",
"env",
"event",
"event_name",
"event_path",
"graphql_url",
"head_ref",
"job",
"ref",
"ref_name",
"ref_protected",
"ref_type",
"path",
"repository",
"repository_owner",
"repositoryUrl",
"retention_days",
"run_id",
"run_number",
"run_attempt",
"secret_source",
"server_url",
"sha",
"token",
"triggering_actor",
"workflow",
"workspace"
];
return new data.Dictionary(
...keys.map(key => {
return {key, value: new data.Null()};
})
);
}
+2 -2
View File
@@ -1,12 +1,12 @@
{
"name": "browser-playground",
"version": "0.1.49",
"version": "0.1.50",
"description": "",
"private": true,
"main": "index.js",
"type": "module",
"dependencies": {
"@github/actions-languageserver": "^0.1.49",
"@github/actions-languageserver": "^0.1.50",
"monaco-editor-webpack-plugin": "^7.0.1",
"monaco-editor-workers": "^0.34.2",
"monaco-languageclient": "^4.0.3",
+1 -1
View File
@@ -1,5 +1,5 @@
{
"$schema": "node_modules/lerna/schemas/lerna-schema.json",
"useWorkspaces": true,
"version": "0.1.49"
"version": "0.1.50"
}
+8 -8
View File
@@ -16,10 +16,10 @@
},
"actions-languageserver": {
"name": "@github/actions-languageserver",
"version": "0.1.49",
"version": "0.1.50",
"license": "MIT",
"dependencies": {
"@github/actions-languageservice": "^0.1.49",
"@github/actions-languageservice": "^0.1.50",
"@github/actions-workflow-parser": "*",
"@octokit/rest": "^19.0.5",
"vscode-languageserver": "^8.0.2",
@@ -40,7 +40,7 @@
},
"actions-languageservice": {
"name": "@github/actions-languageservice",
"version": "0.1.49",
"version": "0.1.50",
"license": "MIT",
"dependencies": {
"@github/actions-workflow-parser": "*",
@@ -61,10 +61,10 @@
}
},
"browser-playground": {
"version": "0.1.49",
"version": "0.1.50",
"license": "MIT",
"dependencies": {
"@github/actions-languageserver": "^0.1.49",
"@github/actions-languageserver": "^0.1.50",
"monaco-editor-webpack-plugin": "^7.0.1",
"monaco-editor-workers": "^0.34.2",
"monaco-languageclient": "^4.0.3",
@@ -13507,7 +13507,7 @@
"@github/actions-languageserver": {
"version": "file:actions-languageserver",
"requires": {
"@github/actions-languageservice": "^0.1.49",
"@github/actions-languageservice": "^0.1.50",
"@github/actions-workflow-parser": "*",
"@octokit/rest": "^19.0.5",
"@types/jest": "^29.0.3",
@@ -16292,7 +16292,7 @@
"browser-playground": {
"version": "file:browser-playground",
"requires": {
"@github/actions-languageserver": "^0.1.49",
"@github/actions-languageserver": "^0.1.50",
"css-loader": "^6.7.2",
"monaco-editor-webpack-plugin": "^7.0.1",
"monaco-editor-workers": "^0.34.2",
@@ -23082,4 +23082,4 @@
"dev": true
}
}
}
}