Fix license test failures
This commit is contained in:
@@ -49,6 +49,15 @@ let rubyChange: Change = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
jest.mock('@actions/core')
|
jest.mock('@actions/core')
|
||||||
|
jest.mock('spdx-satisfies', () => {
|
||||||
|
return {
|
||||||
|
__esModule: true,
|
||||||
|
// hack to coerce / mock spdx-satisfies to return value
|
||||||
|
// true for BSD, false for all others
|
||||||
|
// affects only deny_licenses and allow_licenses checks
|
||||||
|
default: (license: string, _: string): boolean => license === 'BSD'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
const mockOctokit = {
|
const mockOctokit = {
|
||||||
rest: {
|
rest: {
|
||||||
|
|||||||
+6
@@ -175,6 +175,7 @@ function getDeniedLicenseChanges(changes, licenses) {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (validityCache.get(license) === undefined) {
|
if (validityCache.get(license) === undefined) {
|
||||||
|
try {
|
||||||
if (allow !== undefined) {
|
if (allow !== undefined) {
|
||||||
const found = allow.find(spdxExpression => (0, spdx_satisfies_1.default)(license, spdxExpression));
|
const found = allow.find(spdxExpression => (0, spdx_satisfies_1.default)(license, spdxExpression));
|
||||||
validityCache.set(license, found !== undefined);
|
validityCache.set(license, found !== undefined);
|
||||||
@@ -184,6 +185,11 @@ function getDeniedLicenseChanges(changes, licenses) {
|
|||||||
validityCache.set(license, found === undefined);
|
validityCache.set(license, found === undefined);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (_) {
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
|
console.log(`Invalid spdx license ${license} for ${change.name}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
// TODO: Verify spdxSatisfies is working as expected as currently:
|
// TODO: Verify spdxSatisfies is working as expected as currently:
|
||||||
// spdxSatisfies("MIT", "MIT AND (GPL-2.0 OR ISC)") => true
|
// spdxSatisfies("MIT", "MIT AND (GPL-2.0 OR ISC)") => true
|
||||||
// spdxSatisfies("MIT AND (GPL-2.0 OR ISC)", "MIT") => false
|
// spdxSatisfies("MIT AND (GPL-2.0 OR ISC)", "MIT") => false
|
||||||
|
|||||||
+1
-1
File diff suppressed because one or more lines are too long
@@ -41,6 +41,7 @@ export async function getDeniedLicenseChanges(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (validityCache.get(license) === undefined) {
|
if (validityCache.get(license) === undefined) {
|
||||||
|
try {
|
||||||
if (allow !== undefined) {
|
if (allow !== undefined) {
|
||||||
const found = allow.find(spdxExpression =>
|
const found = allow.find(spdxExpression =>
|
||||||
spdxSatisfies(license, spdxExpression)
|
spdxSatisfies(license, spdxExpression)
|
||||||
@@ -52,6 +53,10 @@ export async function getDeniedLicenseChanges(
|
|||||||
)
|
)
|
||||||
validityCache.set(license, found === undefined)
|
validityCache.set(license, found === undefined)
|
||||||
}
|
}
|
||||||
|
} catch (_) {
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
|
console.log(`Invalid spdx license ${license} for ${change.name}`)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Verify spdxSatisfies is working as expected as currently:
|
// TODO: Verify spdxSatisfies is working as expected as currently:
|
||||||
|
|||||||
Reference in New Issue
Block a user