mirror of
https://github.com/github/codeql-action.git
synced 2025-12-24 08:10:06 +08:00
Upgrade TypeScript to 9.2.0
This commit is contained in:
26
lib/workflow.js
generated
26
lib/workflow.js
generated
@@ -1,7 +1,11 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
@@ -85,12 +89,11 @@ exports.WorkflowErrors = toCodedErrors({
|
||||
CheckoutWrongHead: `git checkout HEAD^2 is no longer necessary. Please remove this step as Code Scanning recommends analyzing the merge commit for best results.`,
|
||||
});
|
||||
function getWorkflowErrors(doc) {
|
||||
var _a, _b, _c, _d, _e;
|
||||
const errors = [];
|
||||
const jobName = process.env.GITHUB_JOB;
|
||||
if (jobName) {
|
||||
const job = (_a = doc === null || doc === void 0 ? void 0 : doc.jobs) === null || _a === void 0 ? void 0 : _a[jobName];
|
||||
const steps = job === null || job === void 0 ? void 0 : job.steps;
|
||||
const job = doc?.jobs?.[jobName];
|
||||
const steps = job?.steps;
|
||||
if (Array.isArray(steps)) {
|
||||
for (const step of steps) {
|
||||
// this was advice that we used to give in the README
|
||||
@@ -98,7 +101,7 @@ function getWorkflowErrors(doc) {
|
||||
// to produce results that are more inline with expectations
|
||||
// (i.e: this is what will happen if you merge this PR)
|
||||
// and avoid some race conditions
|
||||
if ((step === null || step === void 0 ? void 0 : step.run) === "git checkout HEAD^2") {
|
||||
if (step?.run === "git checkout HEAD^2") {
|
||||
errors.push(exports.WorkflowErrors.CheckoutWrongHead);
|
||||
break;
|
||||
}
|
||||
@@ -128,14 +131,14 @@ function getWorkflowErrors(doc) {
|
||||
missingPush = true;
|
||||
}
|
||||
if (hasPush && hasPullRequest) {
|
||||
const paths = (_b = doc.on.push) === null || _b === void 0 ? void 0 : _b.paths;
|
||||
const paths = doc.on.push?.paths;
|
||||
// if you specify paths or paths-ignore you can end up with commits that have no baseline
|
||||
// if they didn't change any files
|
||||
// currently we cannot go back through the history and find the most recent baseline
|
||||
if (Array.isArray(paths) && paths.length > 0) {
|
||||
errors.push(exports.WorkflowErrors.PathsSpecified);
|
||||
}
|
||||
const pathsIgnore = (_c = doc.on.push) === null || _c === void 0 ? void 0 : _c["paths-ignore"];
|
||||
const pathsIgnore = doc.on.push?.["paths-ignore"];
|
||||
if (Array.isArray(pathsIgnore) && pathsIgnore.length > 0) {
|
||||
errors.push(exports.WorkflowErrors.PathsIgnoreSpecified);
|
||||
}
|
||||
@@ -144,9 +147,9 @@ function getWorkflowErrors(doc) {
|
||||
// if doc.on.pull_request is undefined that means 'off'
|
||||
// we only want to check for mismatched branches if pull_request is on.
|
||||
if (doc.on.pull_request !== undefined) {
|
||||
const push = branchesToArray((_d = doc.on.push) === null || _d === void 0 ? void 0 : _d.branches);
|
||||
const push = branchesToArray(doc.on.push?.branches);
|
||||
if (push !== "**") {
|
||||
const pull_request = branchesToArray((_e = doc.on.pull_request) === null || _e === void 0 ? void 0 : _e.branches);
|
||||
const pull_request = branchesToArray(doc.on.pull_request?.branches);
|
||||
if (pull_request !== "**") {
|
||||
const difference = pull_request.filter((value) => !push.some((o) => patternIsSuperset(o, value)));
|
||||
if (difference.length > 0) {
|
||||
@@ -263,7 +266,7 @@ function getStepsCallingAction(job, actionName) {
|
||||
if (!Array.isArray(steps)) {
|
||||
throw new Error(`Could not get steps calling ${actionName} since job.steps was not an array.`);
|
||||
}
|
||||
return steps.filter((step) => { var _a; return (_a = step.uses) === null || _a === void 0 ? void 0 : _a.includes(actionName); });
|
||||
return steps.filter((step) => step.uses?.includes(actionName));
|
||||
}
|
||||
/**
|
||||
* Makes a best effort attempt to retrieve the value of a particular input with which
|
||||
@@ -276,7 +279,6 @@ function getStepsCallingAction(job, actionName) {
|
||||
* determine that no such input is passed to the Action.
|
||||
*/
|
||||
function getInputOrThrow(workflow, jobName, actionName, inputName, matrixVars) {
|
||||
var _a, _b;
|
||||
const preamble = `Could not get ${inputName} input to ${actionName} since`;
|
||||
if (!workflow.jobs) {
|
||||
throw new Error(`${preamble} the workflow has no jobs.`);
|
||||
@@ -291,7 +293,7 @@ function getInputOrThrow(workflow, jobName, actionName, inputName, matrixVars) {
|
||||
else if (stepsCallingAction.length > 1) {
|
||||
throw new Error(`${preamble} the ${jobName} job calls ${actionName} multiple times.`);
|
||||
}
|
||||
let input = (_b = (_a = stepsCallingAction[0].with) === null || _a === void 0 ? void 0 : _a[inputName]) === null || _b === void 0 ? void 0 : _b.toString();
|
||||
let input = stepsCallingAction[0].with?.[inputName]?.toString();
|
||||
if (input !== undefined && matrixVars !== undefined) {
|
||||
// Normalize by removing whitespace
|
||||
input = input.replace(/\${{\s+/, "${{").replace(/\s+}}/, "}}");
|
||||
|
||||
Reference in New Issue
Block a user