Allow testing workflow parsing functionality from PR checks
This commit is contained in:
parent
697ed97fa5
commit
384a214d60
9 changed files with 53 additions and 9 deletions
19
lib/workflow.js
generated
19
lib/workflow.js
generated
|
|
@ -293,6 +293,19 @@ function getInputOrThrow(workflow, jobName, actionName, inputName, matrixVars) {
|
|||
}
|
||||
return input;
|
||||
}
|
||||
/**
|
||||
* Get the expected name of the analyze Action.
|
||||
*
|
||||
* This allows us to test workflow parsing functionality as a CodeQL Action PR check.
|
||||
*/
|
||||
function getAnalyzeActionName() {
|
||||
if ((0, util_1.getRequiredEnvParam)("GITHUB_REPOSITORY") === "github/codeql-action") {
|
||||
return "./analyze";
|
||||
}
|
||||
else {
|
||||
return "github/codeql-action/analyze";
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Makes a best effort attempt to retrieve the category input for the particular job,
|
||||
* given a set of matrix variables.
|
||||
|
|
@ -303,7 +316,7 @@ function getInputOrThrow(workflow, jobName, actionName, inputName, matrixVars) {
|
|||
* @throws an error if the category input could not be determined
|
||||
*/
|
||||
function getCategoryInputOrThrow(workflow, jobName, matrixVars) {
|
||||
return getInputOrThrow(workflow, jobName, "github/codeql-action/analyze", "category", matrixVars);
|
||||
return getInputOrThrow(workflow, jobName, getAnalyzeActionName(), "category", matrixVars);
|
||||
}
|
||||
exports.getCategoryInputOrThrow = getCategoryInputOrThrow;
|
||||
/**
|
||||
|
|
@ -316,7 +329,7 @@ exports.getCategoryInputOrThrow = getCategoryInputOrThrow;
|
|||
* @throws an error if the upload input could not be determined
|
||||
*/
|
||||
function getUploadInputOrThrow(workflow, jobName, matrixVars) {
|
||||
return (getInputOrThrow(workflow, jobName, "github/codeql-action/analyze", "upload", matrixVars) || "true" // if unspecified, upload defaults to true
|
||||
return (getInputOrThrow(workflow, jobName, getAnalyzeActionName(), "upload", matrixVars) || "true" // if unspecified, upload defaults to true
|
||||
);
|
||||
}
|
||||
exports.getUploadInputOrThrow = getUploadInputOrThrow;
|
||||
|
|
@ -330,7 +343,7 @@ exports.getUploadInputOrThrow = getUploadInputOrThrow;
|
|||
* @throws an error if the checkout_path input could not be determined
|
||||
*/
|
||||
function getCheckoutPathInputOrThrow(workflow, jobName, matrixVars) {
|
||||
return (getInputOrThrow(workflow, jobName, "github/codeql-action/analyze", "checkout_path", matrixVars) || (0, util_1.getRequiredEnvParam)("GITHUB_WORKSPACE") // if unspecified, checkout_path defaults to ${{ github.workspace }}
|
||||
return (getInputOrThrow(workflow, jobName, getAnalyzeActionName(), "checkout_path", matrixVars) || (0, util_1.getRequiredEnvParam)("GITHUB_WORKSPACE") // if unspecified, checkout_path defaults to ${{ github.workspace }}
|
||||
);
|
||||
}
|
||||
exports.getCheckoutPathInputOrThrow = getCheckoutPathInputOrThrow;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue