mirror of
https://github.com/github/codeql-action.git
synced 2025-12-19 13:59:30 +08:00
Test that workflow with two different languages doesn't produce an error
This commit is contained in:
25
lib/workflow.test.js
generated
25
lib/workflow.test.js
generated
@@ -163,29 +163,38 @@ function errorCodes(actual, expected) {
|
||||
}, await (0, codeql_1.getCodeQLForTesting)());
|
||||
t.deepEqual(...errorCodes(errors, [workflow_1.WorkflowErrors.CheckoutWrongHead]));
|
||||
});
|
||||
(0, ava_1.default)("getWorkflowErrors() for workflow with language name and its alias", async (t) => {
|
||||
await testLanguageAliases(t, ["java", "kotlin"], "java", ["java-kotlin", "kotlin"], [
|
||||
(0, ava_1.default)("getWorkflowErrors() produces an error for workflow with language name and its alias", async (t) => {
|
||||
await testLanguageAliases(t, ["java", "kotlin"], { java: ["java-kotlin", "kotlin"] }, [
|
||||
"CodeQL language 'java' is referenced by more than one entry in the 'language' matrix " +
|
||||
"parameter for job 'test'. This may result in duplicate alerts. Please edit the 'language' " +
|
||||
"matrix parameter to keep only one of the following: 'java', 'kotlin'.",
|
||||
]);
|
||||
});
|
||||
(0, ava_1.default)("getWorkflowErrors() for workflow with two aliases same language", async (t) => {
|
||||
await testLanguageAliases(t, ["java-kotlin", "kotlin"], "java", ["java-kotlin", "kotlin"], [
|
||||
(0, ava_1.default)("getWorkflowErrors() produces an error for workflow with two aliases same language", async (t) => {
|
||||
await testLanguageAliases(t, ["java-kotlin", "kotlin"], { java: ["java-kotlin", "kotlin"] }, [
|
||||
"CodeQL language 'java' is referenced by more than one entry in the 'language' matrix " +
|
||||
"parameter for job 'test'. This may result in duplicate alerts. Please edit the 'language' " +
|
||||
"matrix parameter to keep only one of the following: 'java-kotlin', 'kotlin'.",
|
||||
]);
|
||||
});
|
||||
(0, ava_1.default)("getWorkflowErrors() does not produce error if codeql doesn't support language aliases", async (t) => {
|
||||
await testLanguageAliases(t, ["java-kotlin", "kotlin"], "java", undefined, []);
|
||||
(0, ava_1.default)("getWorkflowErrors() does not produce an error for workflow with two distinct languages", async (t) => {
|
||||
await testLanguageAliases(t, ["java", "typescript"], {
|
||||
java: ["java-kotlin", "kotlin"],
|
||||
javascript: ["javascript-typescript", "typescript"],
|
||||
}, []);
|
||||
});
|
||||
async function testLanguageAliases(t, matrixLanguages, languageName, aliases, expectedErrorMessages) {
|
||||
(0, ava_1.default)("getWorkflowErrors() does not produce an error if codeql doesn't support language aliases", async (t) => {
|
||||
await testLanguageAliases(t, ["java-kotlin", "kotlin"], undefined, []);
|
||||
});
|
||||
async function testLanguageAliases(t, matrixLanguages, aliases, expectedErrorMessages) {
|
||||
process.env.GITHUB_JOB = "test";
|
||||
const codeql = await (0, codeql_1.getCodeQLForTesting)();
|
||||
sinon.stub(codeql, "betterResolveLanguages").resolves({
|
||||
aliases: aliases !== undefined
|
||||
? Object.assign({}, ...aliases.map((alias) => ({ [alias]: languageName })))
|
||||
? // Remap from languageName -> aliases to alias -> languageName
|
||||
Object.assign({}, ...Object.entries(aliases).flatMap(([language, languageAliases]) => languageAliases.map((alias) => ({
|
||||
[alias]: language,
|
||||
}))))
|
||||
: undefined,
|
||||
extractors: {
|
||||
java: [
|
||||
|
||||
Reference in New Issue
Block a user