Compare commits
28
Commits
+1
-1
@@ -1 +1 @@
|
||||
* @github/c2c-actions-experience-parser-reviewers
|
||||
* @actions/actions-experience
|
||||
|
||||
@@ -5,7 +5,7 @@ on:
|
||||
branches:
|
||||
- main
|
||||
paths:
|
||||
- package.json
|
||||
- lerna.json
|
||||
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
@@ -30,7 +30,7 @@ jobs:
|
||||
uses: actions/github-script@v6
|
||||
with:
|
||||
script: |
|
||||
const version = '${{ inputs.version }}' || require('./package.json').version;
|
||||
const version = '${{ inputs.version }}' || require('./lerna.json').version;
|
||||
// Find a release for that version
|
||||
const release = await github.rest.repos.getReleaseByTag({
|
||||
owner: context.repo.owner,
|
||||
@@ -59,12 +59,10 @@ jobs:
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
packages: write
|
||||
|
||||
env:
|
||||
EXT_VERSION: "" # will be set in the workflow
|
||||
|
||||
outputs:
|
||||
version: ${{ env.EXT_VERSION }}
|
||||
PKG_VERSION: "" # will be set in the workflow
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
@@ -73,21 +71,15 @@ jobs:
|
||||
with:
|
||||
node-version: 16.x
|
||||
cache: "npm"
|
||||
registry-url: "https://npm.pkg.github.com"
|
||||
scope: '@actions'
|
||||
|
||||
- name: Parse version from package.json
|
||||
- name: Parse version from lerna.json
|
||||
run: |
|
||||
echo "EXT_VERSION=$(node -p -e "require('./package.json').version")" >> $GITHUB_ENV
|
||||
echo "PKG_VERSION=$(node -p -e "require('./lerna.json').version")" >> $GITHUB_ENV
|
||||
|
||||
- run: npm ci
|
||||
env:
|
||||
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Publish packages
|
||||
run: |
|
||||
lerna publish from-git
|
||||
|
||||
- name: Create release and upload release asset
|
||||
- name: Create release
|
||||
uses: actions/github-script@v6
|
||||
with:
|
||||
script: |
|
||||
@@ -96,11 +88,22 @@ jobs:
|
||||
const release = await github.rest.repos.createRelease({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
tag_name: "release-v${{ env.EXT_VERSION }}",
|
||||
name: "v${{ env.EXT_VERSION }}",
|
||||
tag_name: "release-v${{ env.PKG_VERSION }}",
|
||||
name: "v${{ env.PKG_VERSION }}",
|
||||
draft: false,
|
||||
prerelease: false
|
||||
});
|
||||
|
||||
core.summary.addLink(`Release v${{ env.EXT_VERSION }}`, release.data.html_url);
|
||||
await core.summary.write();
|
||||
core.summary.addLink(`Release v${{ env.PKG_VERSION }}`, release.data.html_url);
|
||||
await core.summary.write();
|
||||
|
||||
- name: setup authentication
|
||||
run: echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" >> .npmrc
|
||||
env:
|
||||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||
|
||||
- name: Publish packages
|
||||
run: |
|
||||
lerna publish ${{ env.PKG_VERSION }} --yes --no-git-reset --no-git-tag-version
|
||||
env:
|
||||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "browser-playground",
|
||||
"version": "0.1.2",
|
||||
"version": "0.2.0",
|
||||
"description": "",
|
||||
"private": true,
|
||||
"main": "index.js",
|
||||
"type": "module",
|
||||
"dependencies": {
|
||||
"@actions/languageserver": "^0.1.2",
|
||||
"@actions/languageserver": "^0.2.0",
|
||||
"monaco-editor-webpack-plugin": "^7.0.1",
|
||||
"monaco-editor-workers": "^0.34.2",
|
||||
"monaco-languageclient": "^4.0.3",
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
{
|
||||
"name": "@actions/expressions",
|
||||
"version": "0.1.2",
|
||||
"version": "0.3.1",
|
||||
"license": "MIT",
|
||||
"type": "module",
|
||||
"source": "./src/index.ts",
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"exports": {
|
||||
".": {
|
||||
"import": "./dist/index.js"
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
{
|
||||
"name": "@actions/languageserver",
|
||||
"version": "0.1.2",
|
||||
"version": "0.3.1",
|
||||
"description": "Language server for GitHub Actions",
|
||||
"license": "MIT",
|
||||
"type": "module",
|
||||
"source": "./src/index.ts",
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"exports": {
|
||||
".": {
|
||||
"import": "./dist/index.js"
|
||||
@@ -40,8 +43,8 @@
|
||||
"watch": "tsc --build tsconfig.build.json --watch"
|
||||
},
|
||||
"dependencies": {
|
||||
"@actions/languageservice": "^0.1.2",
|
||||
"@actions/workflow-parser": "^0.1.2",
|
||||
"@actions/languageservice": "^0.3.1",
|
||||
"@actions/workflow-parser": "^0.3.1",
|
||||
"@octokit/rest": "^19.0.7",
|
||||
"@octokit/types": "^9.0.0",
|
||||
"vscode-languageserver": "^8.0.2",
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {documentLinks, hover, validate, ValidationConfig} from "@actions/languageservice";
|
||||
import {documentLinks, documentSymbols, hover, validate, ValidationConfig} from "@actions/languageservice";
|
||||
import {registerLogger, setLogLevel} from "@actions/languageservice/log";
|
||||
import {clearCache, clearCacheEntry} from "@actions/languageservice/utils/workflow-cache";
|
||||
import {Octokit} from "@octokit/rest";
|
||||
@@ -7,6 +7,8 @@ import {
|
||||
Connection,
|
||||
DocumentLink,
|
||||
DocumentLinkParams,
|
||||
DocumentSymbol,
|
||||
DocumentSymbolParams,
|
||||
ExecuteCommandParams,
|
||||
Hover,
|
||||
HoverParams,
|
||||
@@ -26,7 +28,7 @@ import {getFileProvider} from "./file-provider";
|
||||
import {InitializationOptions, RepositoryContext} from "./initializationOptions";
|
||||
import {onCompletion} from "./on-completion";
|
||||
import {ReadFileRequest, Requests} from "./request";
|
||||
import {fetchActionMetadata} from "./utils/action-metadata";
|
||||
import {getActionsMetadataProvider} from "./utils/action-metadata";
|
||||
import {TTLCache} from "./utils/cache";
|
||||
import {timeOperation} from "./utils/timer";
|
||||
import {valueProviders} from "./value-providers";
|
||||
@@ -72,6 +74,10 @@ export function initConnection(connection: Connection) {
|
||||
hoverProvider: true,
|
||||
documentLinkProvider: {
|
||||
resolveProvider: false
|
||||
},
|
||||
documentSymbolProvider: {
|
||||
label: "GitHub Actions",
|
||||
workDoneProgress: false
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -108,13 +114,7 @@ export function initConnection(connection: Connection) {
|
||||
const config: ValidationConfig = {
|
||||
valueProviderConfig: valueProviders(client, repoContext, cache),
|
||||
contextProviderConfig: contextProviders(client, repoContext, cache),
|
||||
fetchActionMetadata: async action => {
|
||||
if (client) {
|
||||
return await fetchActionMetadata(client, cache, action);
|
||||
}
|
||||
|
||||
return undefined;
|
||||
},
|
||||
actionsMetadataProvider: getActionsMetadataProvider(client, cache),
|
||||
fileProvider: getFileProvider(client, cache, repoContext?.workspaceUri, async path => {
|
||||
return await connection.sendRequest(Requests.ReadFile, {path} satisfies ReadFileRequest);
|
||||
})
|
||||
@@ -164,6 +164,11 @@ export function initConnection(connection: Connection) {
|
||||
return documentLinks(getDocument(documents, textDocument), repoContext?.workspaceUri);
|
||||
});
|
||||
|
||||
connection.onDocumentSymbol(async ({textDocument}: DocumentSymbolParams): Promise<DocumentSymbol[] | null> => {
|
||||
const repoContext = repos.find(repo => textDocument.uri.startsWith(repo.workspaceUri));
|
||||
return documentSymbols(getDocument(documents, textDocument), repoContext?.workspaceUri);
|
||||
});
|
||||
|
||||
// Make the text document manager listen on the connection
|
||||
// for open, change and close text document events
|
||||
documents.listen(connection);
|
||||
|
||||
@@ -1,10 +1,24 @@
|
||||
import {actionIdentifier, ActionMetadata, ActionReference} from "@actions/languageservice/action";
|
||||
import {ActionsMetadataProvider} from "@actions/languageservice";
|
||||
import {error} from "@actions/languageservice/log";
|
||||
import {Octokit, RestEndpointMethodTypes} from "@octokit/rest";
|
||||
import {parse} from "yaml";
|
||||
import {TTLCache} from "./cache";
|
||||
import {errorMessage, errorStatus} from "./error";
|
||||
|
||||
export function getActionsMetadataProvider(
|
||||
client: Octokit | undefined,
|
||||
cache: TTLCache
|
||||
): ActionsMetadataProvider | undefined {
|
||||
if (!client) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return {
|
||||
fetchActionMetadata: async action => fetchActionMetadata(client, cache, action)
|
||||
};
|
||||
}
|
||||
|
||||
export async function fetchActionMetadata(
|
||||
client: Octokit,
|
||||
cache: TTLCache,
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
{
|
||||
"name": "@actions/languageservice",
|
||||
"version": "0.1.2",
|
||||
"version": "0.3.1",
|
||||
"description": "Language service for GitHub Actions",
|
||||
"license": "MIT",
|
||||
"type": "module",
|
||||
"source": "./src/index.ts",
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"exports": {
|
||||
".": {
|
||||
"import": "./dist/index.js"
|
||||
@@ -41,8 +44,8 @@
|
||||
"watch": "tsc --build tsconfig.build.json --watch"
|
||||
},
|
||||
"dependencies": {
|
||||
"@actions/expressions": "^0.1.2",
|
||||
"@actions/workflow-parser": "^0.1.2",
|
||||
"@actions/expressions": "^0.3.1",
|
||||
"@actions/workflow-parser": "^0.3.1",
|
||||
"vscode-languageserver-textdocument": "^1.0.7",
|
||||
"vscode-languageserver-types": "^3.17.2",
|
||||
"vscode-uri": "^3.0.7",
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
import {ErrorPolicy} from "@actions/workflow-parser/model/convert";
|
||||
import {File} from "@actions/workflow-parser/workflows/file";
|
||||
import {TextDocument} from "vscode-languageserver-textdocument";
|
||||
import {DocumentSymbol, SymbolKind} from "vscode-languageserver-types";
|
||||
import {mapRange} from "./utils/range";
|
||||
import {fetchOrConvertWorkflowTemplate, fetchOrParseWorkflow} from "./utils/workflow-cache";
|
||||
|
||||
export async function documentSymbols(
|
||||
document: TextDocument,
|
||||
workspace: string | undefined
|
||||
): Promise<DocumentSymbol[]> {
|
||||
const file: File = {
|
||||
name: document.uri,
|
||||
content: document.getText()
|
||||
};
|
||||
|
||||
const parsedWorkflow = fetchOrParseWorkflow(file, document.uri);
|
||||
if (!parsedWorkflow?.value) {
|
||||
return [];
|
||||
}
|
||||
|
||||
const template = await fetchOrConvertWorkflowTemplate(
|
||||
parsedWorkflow.context,
|
||||
parsedWorkflow.value,
|
||||
document.uri,
|
||||
undefined,
|
||||
{
|
||||
errorPolicy: ErrorPolicy.TryConversion
|
||||
}
|
||||
);
|
||||
|
||||
if (!template) {
|
||||
return [];
|
||||
}
|
||||
|
||||
const symbols: DocumentSymbol[] = [];
|
||||
|
||||
const onSymbol = DocumentSymbol.create(
|
||||
"`on` Triggers",
|
||||
undefined,
|
||||
SymbolKind.Key,
|
||||
mapRange(template.events.range),
|
||||
mapRange(template.events.range)
|
||||
);
|
||||
symbols.push(onSymbol);
|
||||
|
||||
const jobsSymbol = DocumentSymbol.create(
|
||||
"Jobs",
|
||||
undefined,
|
||||
SymbolKind.Namespace,
|
||||
mapRange(template.jobs?.[0].id.range),
|
||||
mapRange(template.jobs?.[0].id.range),
|
||||
[]
|
||||
);
|
||||
symbols.push(jobsSymbol);
|
||||
|
||||
for (const job of template.jobs || []) {
|
||||
const jobSymbol = DocumentSymbol.create(
|
||||
`Job ${job.name?.toDisplayString() || job.id?.toString()}`,
|
||||
"detail",
|
||||
SymbolKind.Class,
|
||||
mapRange(job.id.range),
|
||||
mapRange(job.id.range)
|
||||
);
|
||||
|
||||
jobsSymbol.children!.push(jobSymbol);
|
||||
}
|
||||
|
||||
return symbols;
|
||||
}
|
||||
@@ -1,7 +1,8 @@
|
||||
export {complete} from "./complete";
|
||||
export {ContextProviderConfig} from "./context-providers/config";
|
||||
export {documentLinks} from "./document-links";
|
||||
export {documentSymbols} from "./document-symbols";
|
||||
export {hover} from "./hover";
|
||||
export {Logger, LogLevel, registerLogger, setLogLevel} from "./log";
|
||||
export {validate, ValidationConfig} from "./validate";
|
||||
export {LogLevel, Logger, registerLogger, setLogLevel} from "./log";
|
||||
export {ActionsMetadataProvider, ValidationConfig, validate} from "./validate";
|
||||
export {ValueProviderConfig, ValueProviderKind} from "./value-providers/config";
|
||||
|
||||
@@ -14,7 +14,7 @@ export async function validateAction(
|
||||
step: Step | undefined,
|
||||
config: ValidationConfig | undefined
|
||||
): Promise<void> {
|
||||
if (!isMapping(stepToken) || !step || !isActionStep(step) || !config?.fetchActionMetadata) {
|
||||
if (!isMapping(stepToken) || !step || !isActionStep(step) || !config?.actionsMetadataProvider) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ export async function validateAction(
|
||||
return;
|
||||
}
|
||||
|
||||
const actionMetadata = await config.fetchActionMetadata(action);
|
||||
const actionMetadata = await config.actionsMetadataProvider.fetchActionMetadata(action);
|
||||
if (actionMetadata === undefined) {
|
||||
diagnostics.push({
|
||||
severity: DiagnosticSeverity.Error,
|
||||
|
||||
@@ -14,75 +14,77 @@ beforeEach(() => {
|
||||
});
|
||||
|
||||
const validationConfig: ValidationConfig = {
|
||||
fetchActionMetadata: (ref: ActionReference) => {
|
||||
let metadata: ActionMetadata | undefined = undefined;
|
||||
switch (ref.owner + "/" + ref.name + "@" + ref.ref) {
|
||||
case "actions/checkout@v3":
|
||||
metadata = {
|
||||
name: "Checkout",
|
||||
description: "Checkout a Git repository at a particular version",
|
||||
inputs: {
|
||||
repository: {
|
||||
description: "Repository name with owner",
|
||||
default: "${{ github.repository }}"
|
||||
actionsMetadataProvider: {
|
||||
fetchActionMetadata: (ref: ActionReference) => {
|
||||
let metadata: ActionMetadata | undefined = undefined;
|
||||
switch (ref.owner + "/" + ref.name + "@" + ref.ref) {
|
||||
case "actions/checkout@v3":
|
||||
metadata = {
|
||||
name: "Checkout",
|
||||
description: "Checkout a Git repository at a particular version",
|
||||
inputs: {
|
||||
repository: {
|
||||
description: "Repository name with owner",
|
||||
default: "${{ github.repository }}"
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
break;
|
||||
case "actions/setup-node@v1":
|
||||
metadata = {
|
||||
name: "Setup Node.js environment",
|
||||
description:
|
||||
"Setup a Node.js environment by adding problem matchers and optionally downloading and adding it to the PATH.",
|
||||
inputs: {
|
||||
version: {
|
||||
description: "Deprecated. Use node-version instead. Will not be supported after October 1, 2019",
|
||||
deprecationMessage:
|
||||
"The version property will not be supported after October 1, 2019. Use node-version instead"
|
||||
};
|
||||
break;
|
||||
case "actions/setup-node@v1":
|
||||
metadata = {
|
||||
name: "Setup Node.js environment",
|
||||
description:
|
||||
"Setup a Node.js environment by adding problem matchers and optionally downloading and adding it to the PATH.",
|
||||
inputs: {
|
||||
version: {
|
||||
description: "Deprecated. Use node-version instead. Will not be supported after October 1, 2019",
|
||||
deprecationMessage:
|
||||
"The version property will not be supported after October 1, 2019. Use node-version instead"
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
break;
|
||||
case "actions/deploy-pages@main":
|
||||
metadata = {
|
||||
name: "Deploy GitHub Pages site",
|
||||
description: "A GitHub Action to deploy an artifact as a GitHub Pages site",
|
||||
inputs: {
|
||||
token: {
|
||||
required: true,
|
||||
description: "token to use",
|
||||
default: "${{ github.token }}"
|
||||
};
|
||||
break;
|
||||
case "actions/deploy-pages@main":
|
||||
metadata = {
|
||||
name: "Deploy GitHub Pages site",
|
||||
description: "A GitHub Action to deploy an artifact as a GitHub Pages site",
|
||||
inputs: {
|
||||
token: {
|
||||
required: true,
|
||||
description: "token to use",
|
||||
default: "${{ github.token }}"
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
break;
|
||||
case "actions/cache@v1":
|
||||
metadata = {
|
||||
name: "Cache",
|
||||
description: "Cache artifacts like dependencies and build outputs to improve workflow execution time",
|
||||
inputs: {
|
||||
path: {
|
||||
description: "A directory to store and save the cache",
|
||||
required: true
|
||||
},
|
||||
key: {
|
||||
description: "An explicit key for restoring and saving the cache",
|
||||
required: true
|
||||
},
|
||||
"restore-keys": {
|
||||
description: "An ordered list of keys to use for restoring the cache if no cache hit occurred for key",
|
||||
required: false
|
||||
};
|
||||
break;
|
||||
case "actions/cache@v1":
|
||||
metadata = {
|
||||
name: "Cache",
|
||||
description: "Cache artifacts like dependencies and build outputs to improve workflow execution time",
|
||||
inputs: {
|
||||
path: {
|
||||
description: "A directory to store and save the cache",
|
||||
required: true
|
||||
},
|
||||
key: {
|
||||
description: "An explicit key for restoring and saving the cache",
|
||||
required: true
|
||||
},
|
||||
"restore-keys": {
|
||||
description: "An ordered list of keys to use for restoring the cache if no cache hit occurred for key",
|
||||
required: false
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
break;
|
||||
case "actions/action-no-input@v1":
|
||||
metadata = {
|
||||
name: "Action with no inputs",
|
||||
description: "An action with no inputs"
|
||||
};
|
||||
};
|
||||
break;
|
||||
case "actions/action-no-input@v1":
|
||||
metadata = {
|
||||
name: "Action with no inputs",
|
||||
description: "An action with no inputs"
|
||||
};
|
||||
}
|
||||
return Promise.resolve(metadata);
|
||||
}
|
||||
return Promise.resolve(metadata);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -101,6 +103,21 @@ jobs:
|
||||
expect(result).toEqual([]);
|
||||
});
|
||||
|
||||
it("no actionsMetadataProvider", async () => {
|
||||
const input = `
|
||||
on: push
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/does-not-exist@v3
|
||||
`;
|
||||
const config: ValidationConfig = {};
|
||||
const result = await validate(createDocument("wf.yaml", input), config);
|
||||
|
||||
expect(result).toEqual([]);
|
||||
});
|
||||
|
||||
it("action does not exist", async () => {
|
||||
const input = `
|
||||
on: push
|
||||
|
||||
@@ -28,10 +28,14 @@ import {defaultValueProviders} from "./value-providers/default";
|
||||
export type ValidationConfig = {
|
||||
valueProviderConfig?: ValueProviderConfig;
|
||||
contextProviderConfig?: ContextProviderConfig;
|
||||
fetchActionMetadata?(action: ActionReference): Promise<ActionMetadata | undefined>;
|
||||
actionsMetadataProvider?: ActionsMetadataProvider;
|
||||
fileProvider?: FileProvider;
|
||||
};
|
||||
|
||||
export type ActionsMetadataProvider = {
|
||||
fetchActionMetadata(action: ActionReference): Promise<ActionMetadata | undefined>;
|
||||
};
|
||||
|
||||
/**
|
||||
* Validates a workflow file
|
||||
*
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"$schema": "node_modules/lerna/schemas/lerna-schema.json",
|
||||
"useWorkspaces": true,
|
||||
"version": "0.1.2"
|
||||
"version": "0.3.1"
|
||||
}
|
||||
|
||||
Generated
+54
-2292
File diff suppressed because it is too large
Load Diff
+1
-2
@@ -5,8 +5,7 @@
|
||||
"./expressions",
|
||||
"./workflow-parser",
|
||||
"./languageservice",
|
||||
"./languageserver",
|
||||
"./browser-playground"
|
||||
"./languageserver"
|
||||
],
|
||||
"devDependencies": {
|
||||
"lerna": "^6.0.3"
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
{
|
||||
"name": "@actions/workflow-parser",
|
||||
"version": "0.1.2",
|
||||
"version": "0.3.1",
|
||||
"license": "MIT",
|
||||
"type": "module",
|
||||
"source": "./src/index.ts",
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"exports": {
|
||||
".": {
|
||||
"import": "./dist/index.js"
|
||||
@@ -40,7 +43,7 @@
|
||||
"watch": "tsc --build tsconfig.build.json --watch"
|
||||
},
|
||||
"dependencies": {
|
||||
"@actions/expressions": "^0.1.2",
|
||||
"@actions/expressions": "^0.3.1",
|
||||
"cronstrue": "^2.21.0",
|
||||
"yaml": "^2.0.0-8"
|
||||
},
|
||||
|
||||
@@ -9,7 +9,7 @@ import {handleTemplateTokenErrors} from "./converter/handle-errors";
|
||||
import {convertJobs} from "./converter/jobs";
|
||||
import {convertReferencedWorkflow} from "./converter/referencedWorkflow";
|
||||
import {isReusableWorkflowJob} from "./type-guards";
|
||||
import {WorkflowTemplate} from "./workflow-template";
|
||||
import {EventsConfig, WorkflowTemplate} from "./workflow-template";
|
||||
|
||||
export enum ErrorPolicy {
|
||||
ReturnErrorsOnly,
|
||||
@@ -73,7 +73,9 @@ export async function convertWorkflowTemplate(
|
||||
|
||||
switch (key.value) {
|
||||
case "on":
|
||||
result.events = handleTemplateTokenErrors(root, context, {}, () => convertOn(context, item.value));
|
||||
result.events = handleTemplateTokenErrors(root, context, {range: item.key.range} as EventsConfig, () =>
|
||||
convertOn(context, item.value)
|
||||
);
|
||||
break;
|
||||
|
||||
case "jobs":
|
||||
|
||||
@@ -23,12 +23,15 @@ export function convertOn(context: TemplateContext, token: TemplateToken): Event
|
||||
const event = token.assertString("on");
|
||||
|
||||
return {
|
||||
range: token.range,
|
||||
[event.value]: {}
|
||||
} as EventsConfig;
|
||||
}
|
||||
|
||||
if (isSequence(token)) {
|
||||
const result = {} as EventsConfig;
|
||||
const result = {
|
||||
range: token.range
|
||||
} as EventsConfig;
|
||||
|
||||
for (const item of token) {
|
||||
const event = item.assertString("on");
|
||||
@@ -39,7 +42,9 @@ export function convertOn(context: TemplateContext, token: TemplateToken): Event
|
||||
}
|
||||
|
||||
if (isMapping(token)) {
|
||||
const result = {} as EventsConfig;
|
||||
const result = {
|
||||
range: token.range
|
||||
} as EventsConfig;
|
||||
|
||||
for (const item of token) {
|
||||
const eventKey = item.key.assertString("event name");
|
||||
@@ -77,7 +82,9 @@ export function convertOn(context: TemplateContext, token: TemplateToken): Event
|
||||
}
|
||||
|
||||
context.error(token, "Invalid format for 'on'");
|
||||
return {};
|
||||
return {
|
||||
range: token.range
|
||||
} as EventsConfig;
|
||||
}
|
||||
|
||||
function convertPatternFilter<T extends BranchFilterConfig & TagFilterConfig & PathFilterConfig>(
|
||||
|
||||
@@ -6,6 +6,7 @@ import {
|
||||
StringToken,
|
||||
TemplateToken
|
||||
} from "../templates/tokens";
|
||||
import {TokenRange} from "../templates/tokens/token-range";
|
||||
|
||||
export type WorkflowTemplate = {
|
||||
events: EventsConfig;
|
||||
@@ -99,6 +100,8 @@ export type ActionStep = BaseStep & {
|
||||
};
|
||||
|
||||
export type EventsConfig = {
|
||||
range: TokenRange;
|
||||
|
||||
schedule?: ScheduleConfig[];
|
||||
workflow_dispatch?: WorkflowDispatchConfig;
|
||||
workflow_call?: WorkflowCallConfig;
|
||||
|
||||
Reference in New Issue
Block a user