Rename folders

This commit is contained in:
Christopher Schleiden
2023-02-22 15:52:40 -08:00
parent 16cc4d9bda
commit 2a3d63551f
469 changed files with 0 additions and 0 deletions
@@ -0,0 +1,39 @@
import {WorkflowContext} from "@github/actions-languageservice/context/workflow-context";
import {convertWorkflowTemplate, parseWorkflow, TraceWriter} from "@github/actions-workflow-parser";
import {isJob} from "@github/actions-workflow-parser/model/type-guards";
const nullTrace: TraceWriter = {
info: x => {},
verbose: x => {},
error: x => {}
};
export async function createWorkflowContext(
workflow: string,
job?: string,
stepIndex?: number
): Promise<WorkflowContext> {
const parsed = parseWorkflow({name: "test.yaml", content: workflow}, nullTrace);
if (!parsed.value) {
throw new Error("Failed to parse workflow");
}
const template = await convertWorkflowTemplate(parsed.context, parsed.value);
const context: WorkflowContext = {uri: "test.yaml", template};
if (job) {
const workflowJob = template.jobs.find(j => j.id.value === job);
if (workflowJob) {
if (isJob(workflowJob)) {
context.job = workflowJob;
} else {
context.reusableWorkflowJob = workflowJob;
}
}
}
if (stepIndex !== undefined) {
context.step = context.job?.steps[stepIndex];
}
return context;
}