Remove sequence definition support, fix test
This commit is contained in:
@@ -2,14 +2,13 @@ import {TextDocument} from "vscode-languageserver-textdocument";
|
||||
import {hover} from "./hover";
|
||||
import {getPositionFromCursor} from "./test-utils/cursor-position";
|
||||
|
||||
describe("validation", () => {
|
||||
describe("hover", () => {
|
||||
it("valid workflow", async () => {
|
||||
const input = `o|n: push
|
||||
jobs:
|
||||
build:
|
||||
runs-on: [self-hosted]`;
|
||||
const doc = TextDocument.create("test://test/test.yaml", "yaml", 0, input);
|
||||
const result = await hover(doc, getPositionFromCursor(input)[1]);
|
||||
const result = await hover(...getPositionFromCursor(input));
|
||||
expect(result).not.toBeUndefined();
|
||||
expect(result?.contents).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."
|
||||
@@ -21,8 +20,7 @@ jobs:
|
||||
jobs:
|
||||
build:
|
||||
runs-on: [self-hosted]`;
|
||||
const doc = TextDocument.create("test://test/test.yaml", "yaml", 0, input);
|
||||
const result = await hover(doc, getPositionFromCursor(input)[1]);
|
||||
const result = await hover(...getPositionFromCursor(input));
|
||||
expect(result).not.toBeUndefined();
|
||||
expect(result?.contents).toEqual("Runs your workflow when you push a commit or tag.");
|
||||
});
|
||||
@@ -33,8 +31,7 @@ jobs:
|
||||
jobs:
|
||||
build:
|
||||
runs-on: [self-hosted]`;
|
||||
const doc = TextDocument.create("test://test/test.yaml", "yaml", 0, input);
|
||||
const result = await hover(doc, getPositionFromCursor(input)[1]);
|
||||
const result = await hover(...getPositionFromCursor(input));
|
||||
expect(result).not.toBeUndefined();
|
||||
expect(result?.contents).toEqual("Runs your workflow when you push a commit or tag.");
|
||||
});
|
||||
|
||||
@@ -93,9 +93,9 @@ describe("find-token", () => {
|
||||
path: [
|
||||
["workflow-root-strict", TokenType.Mapping],
|
||||
["on-strict", TokenType.String, "on"],
|
||||
["on-sequence-strict", TokenType.Sequence]
|
||||
["on-strict", TokenType.Sequence]
|
||||
],
|
||||
parent: ["on-sequence-strict", TokenType.Sequence],
|
||||
parent: ["on-strict", TokenType.Sequence],
|
||||
key: null,
|
||||
token: ["push-string", TokenType.String, "push"]
|
||||
});
|
||||
@@ -109,9 +109,9 @@ describe("find-token", () => {
|
||||
path: [
|
||||
["workflow-root-strict", TokenType.Mapping],
|
||||
["on-strict", TokenType.String, "on"],
|
||||
["on-sequence-strict", TokenType.Sequence]
|
||||
["on-strict", TokenType.Sequence]
|
||||
],
|
||||
parent: ["on-sequence-strict", TokenType.Sequence],
|
||||
parent: ["on-strict", TokenType.Sequence],
|
||||
key: null,
|
||||
token: null
|
||||
});
|
||||
@@ -126,9 +126,9 @@ describe("find-token", () => {
|
||||
path: [
|
||||
["workflow-root-strict", TokenType.Mapping],
|
||||
["on-strict", TokenType.String, "on"],
|
||||
["on-sequence-strict", TokenType.Sequence]
|
||||
["on-strict", TokenType.Sequence]
|
||||
],
|
||||
parent: ["on-sequence-strict", TokenType.Sequence],
|
||||
parent: ["on-strict", TokenType.Sequence],
|
||||
key: null,
|
||||
token: ["pull-request-string", TokenType.String, "pull_request"]
|
||||
});
|
||||
@@ -148,9 +148,9 @@ jobs:
|
||||
["job-id", TokenType.String, "build"],
|
||||
["job-factory", TokenType.Mapping],
|
||||
["runs-on", TokenType.String, "runs-on"],
|
||||
["sequence-of-non-empty-string", TokenType.Sequence]
|
||||
["runs-on", TokenType.Sequence]
|
||||
],
|
||||
parent: ["sequence-of-non-empty-string", TokenType.Sequence],
|
||||
parent: ["runs-on", TokenType.Sequence],
|
||||
key: null,
|
||||
token: ["non-empty-string", TokenType.String, "self"]
|
||||
});
|
||||
|
||||
@@ -2,7 +2,6 @@ import {BooleanDefinition} from "@github/actions-workflow-parser/templates/schem
|
||||
import {Definition} from "@github/actions-workflow-parser/templates/schema/definition";
|
||||
import {MappingDefinition} from "@github/actions-workflow-parser/templates/schema/mapping-definition";
|
||||
import {OneOfDefinition} from "@github/actions-workflow-parser/templates/schema/one-of-definition";
|
||||
import {SequenceDefinition} from "@github/actions-workflow-parser/templates/schema/sequence-definition";
|
||||
import {StringDefinition} from "@github/actions-workflow-parser/templates/schema/string-definition";
|
||||
import {getWorkflowSchema} from "@github/actions-workflow-parser/workflows/workflow-schema";
|
||||
import {Value} from "./config";
|
||||
@@ -27,10 +26,6 @@ export function definitionValues(def: Definition): Value[] {
|
||||
return stringsToValues([def.constant]);
|
||||
}
|
||||
|
||||
if (def instanceof SequenceDefinition && def.itemType && schema.definitions[def.itemType]) {
|
||||
return definitionValues(schema.definitions[def.itemType]);
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user