From 8a5fe0138d8a4e527df0ae06ba8a20cffde9617b Mon Sep 17 00:00:00 2001 From: Andreas <38031952+AnHeuermann@users.noreply.github.com> Date: Fri, 2 Feb 2024 13:39:30 +0100 Subject: [PATCH] Handle empty tests (#17) --- badges/coverage.svg | 2 +- dist/index.js | 123 +++++++++++++++++++++++++++++++++++++------- package-lock.json | 114 ++++++++++++++++++++++++++-------------- package.json | 2 +- src/main.ts | 11 +++- 5 files changed, 190 insertions(+), 62 deletions(-) diff --git a/badges/coverage.svg b/badges/coverage.svg index 57c41ae..72bf43a 100644 --- a/badges/coverage.svg +++ b/badges/coverage.svg @@ -1 +1 @@ -Coverage: 89.75%Coverage89.75% \ No newline at end of file +Coverage: 88.94%Coverage88.94% \ No newline at end of file diff --git a/dist/index.js b/dist/index.js index f862b8a..77e9260 100644 --- a/dist/index.js +++ b/dist/index.js @@ -6173,6 +6173,18 @@ class AzureKeyCredential { } // Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +/** + * Tests an object to determine whether it implements KeyCredential. + * + * @param credential - The assumed KeyCredential to be tested. + */ +function isKeyCredential(credential) { + return coreUtil.isObjectWithProperties(credential, ["key"]) && typeof credential.key === "string"; +} + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. /** * A static name/key-based credential that supports updating * the underlying name and key values. @@ -6233,6 +6245,7 @@ function isNamedKeyCredential(credential) { } // Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. /** * A static-signature-based credential that supports updating * the underlying signature value. @@ -6302,6 +6315,7 @@ function isTokenCredential(credential) { exports.AzureKeyCredential = AzureKeyCredential; exports.AzureNamedKeyCredential = AzureNamedKeyCredential; exports.AzureSASCredential = AzureSASCredential; +exports.isKeyCredential = isKeyCredential; exports.isNamedKeyCredential = isNamedKeyCredential; exports.isSASCredential = isSASCredential; exports.isTokenCredential = isTokenCredential; @@ -11792,10 +11806,10 @@ exports.userAgentPolicy = userAgentPolicy; Object.defineProperty(exports, "__esModule", ({ value: true })); var logger$1 = __nccwpck_require__(3233); -var abortController = __nccwpck_require__(52557); var coreUtil = __nccwpck_require__(51333); // Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. /** * The `@azure/logger` configuration for this package. * @internal @@ -11814,6 +11828,7 @@ const POLL_INTERVAL_IN_MS = 2000; const terminalStates = ["succeeded", "canceled", "failed"]; // Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. /** * Deserializes the state */ @@ -11977,6 +11992,7 @@ async function pollOperation(inputs) { } // Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. function getOperationLocationPollingUrl(inputs) { const { azureAsyncOperation, operationLocation } = inputs; return operationLocation !== null && operationLocation !== void 0 ? operationLocation : azureAsyncOperation; @@ -12118,7 +12134,7 @@ function parseRetryAfter({ rawResponse }) { return undefined; } function getErrorFromResponse(response) { - const error = response.flatResponse.error; + const error = accessBodyProperty(response, "error"); if (!error) { logger.warning(`The long-running operation failed but there is no error property in the response's body`); return; @@ -12214,12 +12230,14 @@ function getOperationStatus({ rawResponse }, state) { throw new Error(`Internal error: Unexpected operation mode: ${mode}`); } } -function getResourceLocation({ flatResponse }, state) { - if (typeof flatResponse === "object") { - const resourceLocation = flatResponse.resourceLocation; - if (resourceLocation !== undefined) { - state.config.resourceLocation = resourceLocation; - } +function accessBodyProperty({ flatResponse, rawResponse }, prop) { + var _a, _b; + return (_a = flatResponse === null || flatResponse === void 0 ? void 0 : flatResponse[prop]) !== null && _a !== void 0 ? _a : (_b = rawResponse.body) === null || _b === void 0 ? void 0 : _b[prop]; +} +function getResourceLocation(res, state) { + const loc = accessBodyProperty(res, "resourceLocation"); + if (loc && typeof loc === "string") { + state.config.resourceLocation = loc; } return state.config.resourceLocation; } @@ -12254,6 +12272,7 @@ async function pollHttpOperation(inputs) { } // Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. const createStateProxy$1 = () => ({ /** * The state at this point is created to be of type OperationState. @@ -12305,7 +12324,7 @@ function buildCreatePoller(inputs) { setErrorAsResult: !resolveOnUnsuccessful, }); let resultPromise; - const abortController$1 = new abortController.AbortController(); + const abortController = new AbortController(); const handlers = new Map(); const handleProgressEvents = async () => handlers.forEach((h) => h(state)); const cancelErrMsg = "Operation was canceled"; @@ -12316,7 +12335,7 @@ function buildCreatePoller(inputs) { isDone: () => ["succeeded", "failed", "canceled"].includes(state.status), isStopped: () => resultPromise === undefined, stopPolling: () => { - abortController$1.abort(); + abortController.abort(); }, toString: () => JSON.stringify({ state, @@ -12328,16 +12347,29 @@ function buildCreatePoller(inputs) { }, pollUntilDone: (pollOptions) => (resultPromise !== null && resultPromise !== void 0 ? resultPromise : (resultPromise = (async () => { const { abortSignal: inputAbortSignal } = pollOptions || {}; - const { signal: abortSignal } = inputAbortSignal - ? new abortController.AbortController([inputAbortSignal, abortController$1.signal]) - : abortController$1; - if (!poller.isDone()) { - await poller.poll({ abortSignal }); - while (!poller.isDone()) { - await coreUtil.delay(currentPollIntervalInMs, { abortSignal }); + // In the future we can use AbortSignal.any() instead + function abortListener() { + abortController.abort(); + } + const abortSignal = abortController.signal; + if (inputAbortSignal === null || inputAbortSignal === void 0 ? void 0 : inputAbortSignal.aborted) { + abortController.abort(); + } + else if (!abortSignal.aborted) { + inputAbortSignal === null || inputAbortSignal === void 0 ? void 0 : inputAbortSignal.addEventListener("abort", abortListener, { once: true }); + } + try { + if (!poller.isDone()) { await poller.poll({ abortSignal }); + while (!poller.isDone()) { + await coreUtil.delay(currentPollIntervalInMs, { abortSignal }); + await poller.poll({ abortSignal }); + } } } + finally { + inputAbortSignal === null || inputAbortSignal === void 0 ? void 0 : inputAbortSignal.removeEventListener("abort", abortListener); + } if (resolveOnUnsuccessful) { return poller.getResult(); } @@ -12407,6 +12439,7 @@ function buildCreatePoller(inputs) { } // Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. /** * Creates a poller that can be used to poll a long-running operation. * @param lro - Description of the long-running operation @@ -12448,6 +12481,7 @@ async function createHttpPoller(lro, options) { } // Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. const createStateProxy = () => ({ initState: (config) => ({ config, isStarted: true }), setCanceled: (state) => (state.isCancelled = true), @@ -12926,6 +12960,7 @@ class Poller { } // Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. /** * The LRO Engine, a class that performs polling. */ @@ -13304,7 +13339,9 @@ exports.setSpanContext = setSpanContext; "use strict"; -var abortController = __nccwpck_require__(52557); +Object.defineProperty(exports, "__esModule", ({ value: true })); + +var abortController = __nccwpck_require__(34200); var crypto = __nccwpck_require__(6113); // Copyright (c) Microsoft Corporation. @@ -13376,7 +13413,7 @@ function delay(timeInMs, options) { */ async function cancelablePromiseRace(abortablePromiseBuilders, options) { var _a, _b; - const aborter = new abortController.AbortController(); + const aborter = new AbortController(); function abortHandler() { aborter.abort(); } @@ -13661,6 +13698,47 @@ exports.uint8ArrayToString = uint8ArrayToString; //# sourceMappingURL=index.js.map +/***/ }), + +/***/ 34200: +/***/ ((__unused_webpack_module, exports) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ value: true })); + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +/** + * This error is thrown when an asynchronous operation has been aborted. + * Check for this error by testing the `name` that the name property of the + * error matches `"AbortError"`. + * + * @example + * ```ts + * const controller = new AbortController(); + * controller.abort(); + * try { + * doAsyncWork(controller.signal) + * } catch (e) { + * if (e.name === 'AbortError') { + * // handle abort error here. + * } + * } + * ``` + */ +class AbortError extends Error { + constructor(message) { + super(message); + this.name = "AbortError"; + } +} + +exports.AbortError = AbortError; +//# sourceMappingURL=index.js.map + + /***/ }), /***/ 3233: @@ -159437,11 +159515,16 @@ async function run() { const cwd = process.cwd(); try { process.chdir('OpenModelicaLibraryTesting'); - await runPythonScript('test.py', [ + const { stdout } = await runPythonScript('test.py', [ `--branch=${inputs.omcVersion}`, '--noclean', path.join('configs', `conf-${inputs.library}.json`) ]); + // Verify that library has tests + if (stdout.includes('Not executing any tests.')) { + core.notice(`Ensure that ${inputs.library} has models with experiment annotations.`); + throw new Error('No tests to execute, aborting.'); + } await runPythonScript('report.py', [ `--branch=${inputs.omcVersion}`, path.join('configs', `conf-${inputs.library}.json`) diff --git a/package-lock.json b/package-lock.json index 67481ff..ee42dce 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "openmodelica-library-testing", - "version": "0.1.0", + "version": "0.1.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "openmodelica-library-testing", - "version": "0.1.0", + "version": "0.1.1", "license": "OSMC-PL-1-8", "dependencies": { "@actions/artifact": "^2.1.0", @@ -125,16 +125,27 @@ } }, "node_modules/@azure/core-auth": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/@azure/core-auth/-/core-auth-1.5.0.tgz", - "integrity": "sha512-udzoBuYG1VBoHVohDTrvKjyzel34zt77Bhp7dQntVGGD0ehVq48owENbBG8fIgkHRNUBQH5k1r0hpoMu5L8+kw==", + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/@azure/core-auth/-/core-auth-1.6.0.tgz", + "integrity": "sha512-3X9wzaaGgRaBCwhLQZDtFp5uLIXCPrGbwJNWPPugvL4xbIGgScv77YzzxToKGLAKvG9amDoofMoP+9hsH1vs1w==", "dependencies": { - "@azure/abort-controller": "^1.0.0", + "@azure/abort-controller": "^2.0.0", "@azure/core-util": "^1.1.0", "tslib": "^2.2.0" }, "engines": { - "node": ">=14.0.0" + "node": ">=18.0.0" + } + }, + "node_modules/@azure/core-auth/node_modules/@azure/abort-controller": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@azure/abort-controller/-/abort-controller-2.0.0.tgz", + "integrity": "sha512-RP/mR/WJchR+g+nQFJGOec+nzeN/VvjlwbinccoqfhTsTHbb8X5+mLDp48kHT0ueyum0BNSwGm0kX0UZuIqTGg==", + "dependencies": { + "tslib": "^2.2.0" + }, + "engines": { + "node": ">=18.0.0" } }, "node_modules/@azure/core-http": { @@ -162,17 +173,28 @@ } }, "node_modules/@azure/core-lro": { - "version": "2.5.4", - "resolved": "https://registry.npmjs.org/@azure/core-lro/-/core-lro-2.5.4.tgz", - "integrity": "sha512-3GJiMVH7/10bulzOKGrrLeG/uCBH/9VtxqaMcB9lIqAeamI/xYQSHJL/KcsLDuH+yTjYpro/u6D/MuRe4dN70Q==", + "version": "2.6.0", + "resolved": "https://registry.npmjs.org/@azure/core-lro/-/core-lro-2.6.0.tgz", + "integrity": "sha512-PyRNcaIOfMgoUC01/24NoG+k8O81VrKxYARnDlo+Q2xji0/0/j2nIt8BwQh294pb1c5QnXTDPbNR4KzoDKXEoQ==", "dependencies": { - "@azure/abort-controller": "^1.0.0", + "@azure/abort-controller": "^2.0.0", "@azure/core-util": "^1.2.0", "@azure/logger": "^1.0.0", "tslib": "^2.2.0" }, "engines": { - "node": ">=14.0.0" + "node": ">=18.0.0" + } + }, + "node_modules/@azure/core-lro/node_modules/@azure/abort-controller": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@azure/abort-controller/-/abort-controller-2.0.0.tgz", + "integrity": "sha512-RP/mR/WJchR+g+nQFJGOec+nzeN/VvjlwbinccoqfhTsTHbb8X5+mLDp48kHT0ueyum0BNSwGm0kX0UZuIqTGg==", + "dependencies": { + "tslib": "^2.2.0" + }, + "engines": { + "node": ">=18.0.0" } }, "node_modules/@azure/core-paging": { @@ -199,15 +221,26 @@ } }, "node_modules/@azure/core-util": { - "version": "1.6.1", - "resolved": "https://registry.npmjs.org/@azure/core-util/-/core-util-1.6.1.tgz", - "integrity": "sha512-h5taHeySlsV9qxuK64KZxy4iln1BtMYlNt5jbuEFN3UFSAd1EwKg/Gjl5a6tZ/W8t6li3xPnutOx7zbDyXnPmQ==", + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/@azure/core-util/-/core-util-1.7.0.tgz", + "integrity": "sha512-Zq2i3QO6k9DA8vnm29mYM4G8IE9u1mhF1GUabVEqPNX8Lj833gdxQ2NAFxt2BZsfAL+e9cT8SyVN7dFVJ/Hf0g==", + "dependencies": { + "@azure/abort-controller": "^2.0.0", + "tslib": "^2.2.0" + }, + "engines": { + "node": ">=18.0.0" + } + }, + "node_modules/@azure/core-util/node_modules/@azure/abort-controller": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@azure/abort-controller/-/abort-controller-2.0.0.tgz", + "integrity": "sha512-RP/mR/WJchR+g+nQFJGOec+nzeN/VvjlwbinccoqfhTsTHbb8X5+mLDp48kHT0ueyum0BNSwGm0kX0UZuIqTGg==", "dependencies": { - "@azure/abort-controller": "^1.0.0", "tslib": "^2.2.0" }, "engines": { - "node": ">=16.0.0" + "node": ">=18.0.0" } }, "node_modules/@azure/logger": { @@ -1994,9 +2027,9 @@ "dev": true }, "node_modules/@types/node": { - "version": "20.11.15", - "resolved": "https://registry.npmjs.org/@types/node/-/node-20.11.15.tgz", - "integrity": "sha512-gscmuADZfvNULx1eyirVbr3kVOVZtpQtzKMCZpeSZcN6MfbkRXAR4s9/gsQ4CzxLHw6EStDtKLNtSDL3vbq05A==", + "version": "20.11.16", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.11.16.tgz", + "integrity": "sha512-gKb0enTmRCzXSSUJDq6/sPcqrfCv2mkkG6Jt/clpn5eiCbKTY+SgZUxo+p8ZKMof5dCp9vHQUAB7wOUTod22wQ==", "dependencies": { "undici-types": "~5.26.4" } @@ -2950,9 +2983,9 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001582", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001582.tgz", - "integrity": "sha512-vsJG3V5vgfduaQGVxL53uSX/HUzxyr2eA8xCo36OLal7sRcSZbibJtLeh0qja4sFOr/QQGt4opB4tOy+eOgAxg==", + "version": "1.0.30001583", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001583.tgz", + "integrity": "sha512-acWTYaha8xfhA/Du/z4sNZjHUWjkiuoAi2LM+T/aL+kemKQgPT1xBb/YKjlQ0Qo8gvbHsGNplrEJ+9G3gL7i4Q==", "dev": true, "funding": [ { @@ -3487,9 +3520,9 @@ "dev": true }, "node_modules/electron-to-chromium": { - "version": "1.4.653", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.653.tgz", - "integrity": "sha512-wA2A2LQCqnEwQAvwADQq3KpMpNwgAUBnRmrFgRzHnPhbQUFArTR32Ab46f4p0MovDLcg4uqd4nCsN2hTltslpA==", + "version": "1.4.655", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.655.tgz", + "integrity": "sha512-2yszojF7vIZ68adIOvzV4bku8OZad9w5H9xF3ZAMZjPuOjBarlflUkjN6DggdV+L71WZuKUfKUhov/34+G5QHg==", "dev": true }, "node_modules/emittery": { @@ -4970,10 +5003,13 @@ } }, "node_modules/has-tostringtag": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/has-tostringtag/-/has-tostringtag-1.0.1.tgz", - "integrity": "sha512-6J4rC9ROz0UkOpjn0BRtSSqlewDTDYJNQvy8N8RSrPCduUWId1o9BQPEVII/KKBqRk/ZIQff1YbRkUDCH2N5Sg==", + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/has-tostringtag/-/has-tostringtag-1.0.2.tgz", + "integrity": "sha512-NqADB8VjPFLM2V0VvHUewwwsw0ZWBaIdgo+ieHtK3hasLz4qeCRjYcqfB6AQrBggRKppKF8L52/VqdVsO47Dlw==", "dev": true, + "dependencies": { + "has-symbols": "^1.0.3" + }, "engines": { "node": ">= 0.4" }, @@ -5435,12 +5471,12 @@ } }, "node_modules/is-typed-array": { - "version": "1.1.12", - "resolved": "https://registry.npmjs.org/is-typed-array/-/is-typed-array-1.1.12.tgz", - "integrity": "sha512-Z14TF2JNG8Lss5/HMqt0//T9JeHXttXy5pH/DBU4vi98ozO2btxzq9MwYDZYnKwU8nRsz/+GVFVRDq3DkVuSPg==", + "version": "1.1.13", + "resolved": "https://registry.npmjs.org/is-typed-array/-/is-typed-array-1.1.13.tgz", + "integrity": "sha512-uZ25/bUAlUY5fR4OKT4rZQEBrzQWYV9ZJYGGsUmEJ6thodVJ1HX64ePQ6Z0qPWP+m+Uq6e9UugrE38jeYsDSMw==", "dev": true, "dependencies": { - "which-typed-array": "^1.1.11" + "which-typed-array": "^1.1.14" }, "engines": { "node": ">= 0.4" @@ -8761,16 +8797,16 @@ } }, "node_modules/which-typed-array": { - "version": "1.1.13", - "resolved": "https://registry.npmjs.org/which-typed-array/-/which-typed-array-1.1.13.tgz", - "integrity": "sha512-P5Nra0qjSncduVPEAr7xhoF5guty49ArDTwzJ/yNuPIbZppyRxFQsRCWrocxIY+CnMVG+qfbU2FmDKyvSGClow==", + "version": "1.1.14", + "resolved": "https://registry.npmjs.org/which-typed-array/-/which-typed-array-1.1.14.tgz", + "integrity": "sha512-VnXFiIW8yNn9kIHN88xvZ4yOWchftKDsRJ8fEPacX/wl1lOvBrhsJ/OeJCXq7B0AaijRuqgzSKalJoPk+D8MPg==", "dev": true, "dependencies": { - "available-typed-arrays": "^1.0.5", - "call-bind": "^1.0.4", + "available-typed-arrays": "^1.0.6", + "call-bind": "^1.0.5", "for-each": "^0.3.3", "gopd": "^1.0.1", - "has-tostringtag": "^1.0.0" + "has-tostringtag": "^1.0.1" }, "engines": { "node": ">= 0.4" diff --git a/package.json b/package.json index 4a9e0df..cebbe4d 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "openmodelica-library-testing", "description": "Setup OpenModelicaLibraryTesting scripts and run them on Modelica package and publishes results.", - "version": "0.1.0", + "version": "0.1.1", "author": "AndreasHeuermann", "license": "OSMC-PL-1-8", "private": true, diff --git a/src/main.ts b/src/main.ts index 3900d9e..9d3e693 100644 --- a/src/main.ts +++ b/src/main.ts @@ -123,11 +123,20 @@ export async function run(): Promise { const cwd = process.cwd() try { process.chdir('OpenModelicaLibraryTesting') - await runPythonScript('test.py', [ + const { stdout } = await runPythonScript('test.py', [ `--branch=${inputs.omcVersion}`, '--noclean', path.join('configs', `conf-${inputs.library}.json`) ]) + + // Verify that library has tests + if (stdout.includes('Not executing any tests.')) { + core.notice( + `Ensure that ${inputs.library} has models with experiment annotations.` + ) + throw new Error('No tests to execute, aborting.') + } + await runPythonScript('report.py', [ `--branch=${inputs.omcVersion}`, path.join('configs', `conf-${inputs.library}.json`)