More different stuff

This commit is contained in:
Jacob Wallraff
2023-02-15 17:17:54 -08:00
parent 999a1deb60
commit 157c6f0672
3 changed files with 26 additions and 12 deletions
@@ -16,7 +16,7 @@ export function descriptionProvider(client: Octokit | undefined, cache: TTLCache
}
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 {isString} from "@github/actions-workflow-parser";
import {WorkflowTemplate} from "@github/actions-workflow-parser";
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 {TemplateToken} from "@github/actions-workflow-parser/templates/tokens/template-token";
import {Octokit} from "@octokit/rest";
import {TTLCache} from "../utils/cache";
export async function getReusableWorkflowInputDescription(
client: Octokit,
cache: TTLCache,
reusableWorkflowJob: ReusableWorkflowJob,
token: TemplateToken,
template: FileProvider
template: WorkflowTemplate
): Promise<string | undefined> {
if (!isReusableWorkflowJob(reusableWorkflowJob)) {
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!"
}
+2 -2
View File
@@ -112,7 +112,7 @@ async function getDescription(
) {
const defaultDescription = token.description || "";
// TODO fix this check - description provider is null for rusable workflows
if (!result?.value/* || !config?.descriptionProvider*/) {
if (!result?.value || !config?.descriptionProvider) {
return defaultDescription;
}
@@ -126,7 +126,7 @@ async function getDescription(
}
);
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;
}