More different stuff
This commit is contained in:
@@ -16,7 +16,7 @@ export function descriptionProvider(client: Octokit | undefined, cache: TTLCache
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (context.reusableWorkflowJob && template && parent.definition?.key === "workflow-job-with") {
|
if (context.reusableWorkflowJob && template && parent.definition?.key === "workflow-job-with") {
|
||||||
return await getReusableWorkflowInputDescription(client, cache, context.reusableWorkflowJob, token, template);
|
return await getReusableWorkflowInputDescription(context.reusableWorkflowJob, token, template);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,22 +1,36 @@
|
|||||||
import {parseFileReference} from "@github/actions-workflow-parser/workflows/file-reference";
|
import {WorkflowTemplate} from "@github/actions-workflow-parser";
|
||||||
import {isString} from "@github/actions-workflow-parser";
|
|
||||||
import {isReusableWorkflowJob} from "@github/actions-workflow-parser/model/type-guards";
|
import {isReusableWorkflowJob} from "@github/actions-workflow-parser/model/type-guards";
|
||||||
import {FileProvider} from "@github/actions-workflow-parser/workflows/file-provider";
|
|
||||||
import {ReusableWorkflowJob} from "@github/actions-workflow-parser/model/workflow-template";
|
import {ReusableWorkflowJob} from "@github/actions-workflow-parser/model/workflow-template";
|
||||||
import {TemplateToken} from "@github/actions-workflow-parser/templates/tokens/template-token";
|
import {TemplateToken} from "@github/actions-workflow-parser/templates/tokens/template-token";
|
||||||
import {Octokit} from "@octokit/rest";
|
|
||||||
import {TTLCache} from "../utils/cache";
|
|
||||||
|
|
||||||
export async function getReusableWorkflowInputDescription(
|
export async function getReusableWorkflowInputDescription(
|
||||||
client: Octokit,
|
|
||||||
cache: TTLCache,
|
|
||||||
reusableWorkflowJob: ReusableWorkflowJob,
|
reusableWorkflowJob: ReusableWorkflowJob,
|
||||||
token: TemplateToken,
|
token: TemplateToken,
|
||||||
template: FileProvider
|
template: WorkflowTemplate
|
||||||
): Promise<string | undefined> {
|
): Promise<string | undefined> {
|
||||||
if (!isReusableWorkflowJob(reusableWorkflowJob)) {
|
if (!isReusableWorkflowJob(reusableWorkflowJob)) {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
return "here's a description"
|
// Filter out just reusable jobs
|
||||||
|
const templateReusableJobs = template.jobs.filter(isReusableWorkflowJob);
|
||||||
|
|
||||||
|
// Find the reusable job in the template that matches the current reusable job
|
||||||
|
const templateReusableJob = templateReusableJobs.find(job => job.id.value === reusableWorkflowJob.id.value);
|
||||||
|
|
||||||
|
// Set the description on the reusable job to the one from the template, if any
|
||||||
|
if (templateReusableJob && reusableWorkflowJob["input-definitions"] && templateReusableJob["input-definitions"]) {
|
||||||
|
// For each input in the reusable job, see if there's one that matches in the template
|
||||||
|
for (const input of reusableWorkflowJob["input-definitions"]) {
|
||||||
|
const templateInput = templateReusableJob["input-definitions"].find(templateInput => templateInput.key.value === input.key.value);
|
||||||
|
if (templateInput) {
|
||||||
|
return "fuck me"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return "Didn't find a matching job description!"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -112,7 +112,7 @@ async function getDescription(
|
|||||||
) {
|
) {
|
||||||
const defaultDescription = token.description || "";
|
const defaultDescription = token.description || "";
|
||||||
// TODO fix this check - description provider is null for rusable workflows
|
// TODO fix this check - description provider is null for rusable workflows
|
||||||
if (!result?.value/* || !config?.descriptionProvider*/) {
|
if (!result?.value || !config?.descriptionProvider) {
|
||||||
return defaultDescription;
|
return defaultDescription;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -126,7 +126,7 @@ async function getDescription(
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
const workflowContext = getWorkflowContext(document.uri, template, path);
|
const workflowContext = getWorkflowContext(document.uri, template, path);
|
||||||
const description = await config?.descriptionProvider?.getDescription(workflowContext, token, path, template);
|
const description = await config.descriptionProvider.getDescription(workflowContext, token, path, template);
|
||||||
return description || defaultDescription;
|
return description || defaultDescription;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user