From 77ba054d97ff674355aa4cd7ecabd206b89c569c Mon Sep 17 00:00:00 2001 From: Blazej Kustra Date: Fri, 29 Mar 2024 13:22:20 +0100 Subject: [PATCH 1/4] Test --- .../awaitStagingDeploys.js | 3 +- .../javascript/awaitStagingDeploys/index.js | 697 +++++++++++++++++- 2 files changed, 698 insertions(+), 2 deletions(-) diff --git a/.github/actions/javascript/awaitStagingDeploys/awaitStagingDeploys.js b/.github/actions/javascript/awaitStagingDeploys/awaitStagingDeploys.js index 950a8e7092cc..ee3415ce21e3 100644 --- a/.github/actions/javascript/awaitStagingDeploys/awaitStagingDeploys.js +++ b/.github/actions/javascript/awaitStagingDeploys/awaitStagingDeploys.js @@ -1,4 +1,5 @@ const _ = require('underscore'); +const lodashThrottle = require('lodash/throttle'); const CONST = require('../../../libs/CONST'); const ActionUtils = require('../../../libs/ActionUtils'); const GitHubUtils = require('../../../libs/GithubUtils'); @@ -56,7 +57,7 @@ function run() { return promiseDoWhile( () => !_.isEmpty(currentStagingDeploys), - _.throttle( + lodashThrottle( throttleFunc, // Poll every 60 seconds instead of every 10 seconds diff --git a/.github/actions/javascript/awaitStagingDeploys/index.js b/.github/actions/javascript/awaitStagingDeploys/index.js index 6dc6a4a213e3..ea76389c3a89 100644 --- a/.github/actions/javascript/awaitStagingDeploys/index.js +++ b/.github/actions/javascript/awaitStagingDeploys/index.js @@ -8,6 +8,7 @@ /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { const _ = __nccwpck_require__(5067); +const lodashThrottle = __nccwpck_require__(2891); const CONST = __nccwpck_require__(4097); const ActionUtils = __nccwpck_require__(970); const GitHubUtils = __nccwpck_require__(9296); @@ -65,7 +66,7 @@ function run() { return promiseDoWhile( () => !_.isEmpty(currentStagingDeploys), - _.throttle( + lodashThrottle( throttleFunc, // Poll every 60 seconds instead of every 10 seconds @@ -6716,6 +6717,700 @@ function isPlainObject(o) { exports.isPlainObject = isPlainObject; +/***/ }), + +/***/ 9213: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + +var root = __nccwpck_require__(9882); + +/** Built-in value references. */ +var Symbol = root.Symbol; + +module.exports = Symbol; + + +/***/ }), + +/***/ 7497: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + +var Symbol = __nccwpck_require__(9213), + getRawTag = __nccwpck_require__(923), + objectToString = __nccwpck_require__(4200); + +/** `Object#toString` result references. */ +var nullTag = '[object Null]', + undefinedTag = '[object Undefined]'; + +/** Built-in value references. */ +var symToStringTag = Symbol ? Symbol.toStringTag : undefined; + +/** + * The base implementation of `getTag` without fallbacks for buggy environments. + * + * @private + * @param {*} value The value to query. + * @returns {string} Returns the `toStringTag`. + */ +function baseGetTag(value) { + if (value == null) { + return value === undefined ? undefinedTag : nullTag; + } + return (symToStringTag && symToStringTag in Object(value)) + ? getRawTag(value) + : objectToString(value); +} + +module.exports = baseGetTag; + + +/***/ }), + +/***/ 9528: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + +var trimmedEndIndex = __nccwpck_require__(7010); + +/** Used to match leading whitespace. */ +var reTrimStart = /^\s+/; + +/** + * The base implementation of `_.trim`. + * + * @private + * @param {string} string The string to trim. + * @returns {string} Returns the trimmed string. + */ +function baseTrim(string) { + return string + ? string.slice(0, trimmedEndIndex(string) + 1).replace(reTrimStart, '') + : string; +} + +module.exports = baseTrim; + + +/***/ }), + +/***/ 2085: +/***/ ((module) => { + +/** Detect free variable `global` from Node.js. */ +var freeGlobal = typeof global == 'object' && global && global.Object === Object && global; + +module.exports = freeGlobal; + + +/***/ }), + +/***/ 923: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + +var Symbol = __nccwpck_require__(9213); + +/** Used for built-in method references. */ +var objectProto = Object.prototype; + +/** Used to check objects for own properties. */ +var hasOwnProperty = objectProto.hasOwnProperty; + +/** + * Used to resolve the + * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring) + * of values. + */ +var nativeObjectToString = objectProto.toString; + +/** Built-in value references. */ +var symToStringTag = Symbol ? Symbol.toStringTag : undefined; + +/** + * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values. + * + * @private + * @param {*} value The value to query. + * @returns {string} Returns the raw `toStringTag`. + */ +function getRawTag(value) { + var isOwn = hasOwnProperty.call(value, symToStringTag), + tag = value[symToStringTag]; + + try { + value[symToStringTag] = undefined; + var unmasked = true; + } catch (e) {} + + var result = nativeObjectToString.call(value); + if (unmasked) { + if (isOwn) { + value[symToStringTag] = tag; + } else { + delete value[symToStringTag]; + } + } + return result; +} + +module.exports = getRawTag; + + +/***/ }), + +/***/ 4200: +/***/ ((module) => { + +/** Used for built-in method references. */ +var objectProto = Object.prototype; + +/** + * Used to resolve the + * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring) + * of values. + */ +var nativeObjectToString = objectProto.toString; + +/** + * Converts `value` to a string using `Object.prototype.toString`. + * + * @private + * @param {*} value The value to convert. + * @returns {string} Returns the converted string. + */ +function objectToString(value) { + return nativeObjectToString.call(value); +} + +module.exports = objectToString; + + +/***/ }), + +/***/ 9882: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + +var freeGlobal = __nccwpck_require__(2085); + +/** Detect free variable `self`. */ +var freeSelf = typeof self == 'object' && self && self.Object === Object && self; + +/** Used as a reference to the global object. */ +var root = freeGlobal || freeSelf || Function('return this')(); + +module.exports = root; + + +/***/ }), + +/***/ 7010: +/***/ ((module) => { + +/** Used to match a single whitespace character. */ +var reWhitespace = /\s/; + +/** + * Used by `_.trim` and `_.trimEnd` to get the index of the last non-whitespace + * character of `string`. + * + * @private + * @param {string} string The string to inspect. + * @returns {number} Returns the index of the last non-whitespace character. + */ +function trimmedEndIndex(string) { + var index = string.length; + + while (index-- && reWhitespace.test(string.charAt(index))) {} + return index; +} + +module.exports = trimmedEndIndex; + + +/***/ }), + +/***/ 3626: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + +var isObject = __nccwpck_require__(3334), + now = __nccwpck_require__(8349), + toNumber = __nccwpck_require__(1235); + +/** Error message constants. */ +var FUNC_ERROR_TEXT = 'Expected a function'; + +/* Built-in method references for those with the same name as other `lodash` methods. */ +var nativeMax = Math.max, + nativeMin = Math.min; + +/** + * Creates a debounced function that delays invoking `func` until after `wait` + * milliseconds have elapsed since the last time the debounced function was + * invoked. The debounced function comes with a `cancel` method to cancel + * delayed `func` invocations and a `flush` method to immediately invoke them. + * Provide `options` to indicate whether `func` should be invoked on the + * leading and/or trailing edge of the `wait` timeout. The `func` is invoked + * with the last arguments provided to the debounced function. Subsequent + * calls to the debounced function return the result of the last `func` + * invocation. + * + * **Note:** If `leading` and `trailing` options are `true`, `func` is + * invoked on the trailing edge of the timeout only if the debounced function + * is invoked more than once during the `wait` timeout. + * + * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred + * until to the next tick, similar to `setTimeout` with a timeout of `0`. + * + * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/) + * for details over the differences between `_.debounce` and `_.throttle`. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Function + * @param {Function} func The function to debounce. + * @param {number} [wait=0] The number of milliseconds to delay. + * @param {Object} [options={}] The options object. + * @param {boolean} [options.leading=false] + * Specify invoking on the leading edge of the timeout. + * @param {number} [options.maxWait] + * The maximum time `func` is allowed to be delayed before it's invoked. + * @param {boolean} [options.trailing=true] + * Specify invoking on the trailing edge of the timeout. + * @returns {Function} Returns the new debounced function. + * @example + * + * // Avoid costly calculations while the window size is in flux. + * jQuery(window).on('resize', _.debounce(calculateLayout, 150)); + * + * // Invoke `sendMail` when clicked, debouncing subsequent calls. + * jQuery(element).on('click', _.debounce(sendMail, 300, { + * 'leading': true, + * 'trailing': false + * })); + * + * // Ensure `batchLog` is invoked once after 1 second of debounced calls. + * var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 }); + * var source = new EventSource('/stream'); + * jQuery(source).on('message', debounced); + * + * // Cancel the trailing debounced invocation. + * jQuery(window).on('popstate', debounced.cancel); + */ +function debounce(func, wait, options) { + var lastArgs, + lastThis, + maxWait, + result, + timerId, + lastCallTime, + lastInvokeTime = 0, + leading = false, + maxing = false, + trailing = true; + + if (typeof func != 'function') { + throw new TypeError(FUNC_ERROR_TEXT); + } + wait = toNumber(wait) || 0; + if (isObject(options)) { + leading = !!options.leading; + maxing = 'maxWait' in options; + maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait; + trailing = 'trailing' in options ? !!options.trailing : trailing; + } + + function invokeFunc(time) { + var args = lastArgs, + thisArg = lastThis; + + lastArgs = lastThis = undefined; + lastInvokeTime = time; + result = func.apply(thisArg, args); + return result; + } + + function leadingEdge(time) { + // Reset any `maxWait` timer. + lastInvokeTime = time; + // Start the timer for the trailing edge. + timerId = setTimeout(timerExpired, wait); + // Invoke the leading edge. + return leading ? invokeFunc(time) : result; + } + + function remainingWait(time) { + var timeSinceLastCall = time - lastCallTime, + timeSinceLastInvoke = time - lastInvokeTime, + timeWaiting = wait - timeSinceLastCall; + + return maxing + ? nativeMin(timeWaiting, maxWait - timeSinceLastInvoke) + : timeWaiting; + } + + function shouldInvoke(time) { + var timeSinceLastCall = time - lastCallTime, + timeSinceLastInvoke = time - lastInvokeTime; + + // Either this is the first call, activity has stopped and we're at the + // trailing edge, the system time has gone backwards and we're treating + // it as the trailing edge, or we've hit the `maxWait` limit. + return (lastCallTime === undefined || (timeSinceLastCall >= wait) || + (timeSinceLastCall < 0) || (maxing && timeSinceLastInvoke >= maxWait)); + } + + function timerExpired() { + var time = now(); + if (shouldInvoke(time)) { + return trailingEdge(time); + } + // Restart the timer. + timerId = setTimeout(timerExpired, remainingWait(time)); + } + + function trailingEdge(time) { + timerId = undefined; + + // Only invoke if we have `lastArgs` which means `func` has been + // debounced at least once. + if (trailing && lastArgs) { + return invokeFunc(time); + } + lastArgs = lastThis = undefined; + return result; + } + + function cancel() { + if (timerId !== undefined) { + clearTimeout(timerId); + } + lastInvokeTime = 0; + lastArgs = lastCallTime = lastThis = timerId = undefined; + } + + function flush() { + return timerId === undefined ? result : trailingEdge(now()); + } + + function debounced() { + var time = now(), + isInvoking = shouldInvoke(time); + + lastArgs = arguments; + lastThis = this; + lastCallTime = time; + + if (isInvoking) { + if (timerId === undefined) { + return leadingEdge(lastCallTime); + } + if (maxing) { + // Handle invocations in a tight loop. + clearTimeout(timerId); + timerId = setTimeout(timerExpired, wait); + return invokeFunc(lastCallTime); + } + } + if (timerId === undefined) { + timerId = setTimeout(timerExpired, wait); + } + return result; + } + debounced.cancel = cancel; + debounced.flush = flush; + return debounced; +} + +module.exports = debounce; + + +/***/ }), + +/***/ 3334: +/***/ ((module) => { + +/** + * Checks if `value` is the + * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types) + * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`) + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is an object, else `false`. + * @example + * + * _.isObject({}); + * // => true + * + * _.isObject([1, 2, 3]); + * // => true + * + * _.isObject(_.noop); + * // => true + * + * _.isObject(null); + * // => false + */ +function isObject(value) { + var type = typeof value; + return value != null && (type == 'object' || type == 'function'); +} + +module.exports = isObject; + + +/***/ }), + +/***/ 5926: +/***/ ((module) => { + +/** + * Checks if `value` is object-like. A value is object-like if it's not `null` + * and has a `typeof` result of "object". + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is object-like, else `false`. + * @example + * + * _.isObjectLike({}); + * // => true + * + * _.isObjectLike([1, 2, 3]); + * // => true + * + * _.isObjectLike(_.noop); + * // => false + * + * _.isObjectLike(null); + * // => false + */ +function isObjectLike(value) { + return value != null && typeof value == 'object'; +} + +module.exports = isObjectLike; + + +/***/ }), + +/***/ 6403: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + +var baseGetTag = __nccwpck_require__(7497), + isObjectLike = __nccwpck_require__(5926); + +/** `Object#toString` result references. */ +var symbolTag = '[object Symbol]'; + +/** + * Checks if `value` is classified as a `Symbol` primitive or object. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a symbol, else `false`. + * @example + * + * _.isSymbol(Symbol.iterator); + * // => true + * + * _.isSymbol('abc'); + * // => false + */ +function isSymbol(value) { + return typeof value == 'symbol' || + (isObjectLike(value) && baseGetTag(value) == symbolTag); +} + +module.exports = isSymbol; + + +/***/ }), + +/***/ 8349: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + +var root = __nccwpck_require__(9882); + +/** + * Gets the timestamp of the number of milliseconds that have elapsed since + * the Unix epoch (1 January 1970 00:00:00 UTC). + * + * @static + * @memberOf _ + * @since 2.4.0 + * @category Date + * @returns {number} Returns the timestamp. + * @example + * + * _.defer(function(stamp) { + * console.log(_.now() - stamp); + * }, _.now()); + * // => Logs the number of milliseconds it took for the deferred invocation. + */ +var now = function() { + return root.Date.now(); +}; + +module.exports = now; + + +/***/ }), + +/***/ 2891: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + +var debounce = __nccwpck_require__(3626), + isObject = __nccwpck_require__(3334); + +/** Error message constants. */ +var FUNC_ERROR_TEXT = 'Expected a function'; + +/** + * Creates a throttled function that only invokes `func` at most once per + * every `wait` milliseconds. The throttled function comes with a `cancel` + * method to cancel delayed `func` invocations and a `flush` method to + * immediately invoke them. Provide `options` to indicate whether `func` + * should be invoked on the leading and/or trailing edge of the `wait` + * timeout. The `func` is invoked with the last arguments provided to the + * throttled function. Subsequent calls to the throttled function return the + * result of the last `func` invocation. + * + * **Note:** If `leading` and `trailing` options are `true`, `func` is + * invoked on the trailing edge of the timeout only if the throttled function + * is invoked more than once during the `wait` timeout. + * + * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred + * until to the next tick, similar to `setTimeout` with a timeout of `0`. + * + * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/) + * for details over the differences between `_.throttle` and `_.debounce`. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Function + * @param {Function} func The function to throttle. + * @param {number} [wait=0] The number of milliseconds to throttle invocations to. + * @param {Object} [options={}] The options object. + * @param {boolean} [options.leading=true] + * Specify invoking on the leading edge of the timeout. + * @param {boolean} [options.trailing=true] + * Specify invoking on the trailing edge of the timeout. + * @returns {Function} Returns the new throttled function. + * @example + * + * // Avoid excessively updating the position while scrolling. + * jQuery(window).on('scroll', _.throttle(updatePosition, 100)); + * + * // Invoke `renewToken` when the click event is fired, but not more than once every 5 minutes. + * var throttled = _.throttle(renewToken, 300000, { 'trailing': false }); + * jQuery(element).on('click', throttled); + * + * // Cancel the trailing throttled invocation. + * jQuery(window).on('popstate', throttled.cancel); + */ +function throttle(func, wait, options) { + var leading = true, + trailing = true; + + if (typeof func != 'function') { + throw new TypeError(FUNC_ERROR_TEXT); + } + if (isObject(options)) { + leading = 'leading' in options ? !!options.leading : leading; + trailing = 'trailing' in options ? !!options.trailing : trailing; + } + return debounce(func, wait, { + 'leading': leading, + 'maxWait': wait, + 'trailing': trailing + }); +} + +module.exports = throttle; + + +/***/ }), + +/***/ 1235: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + +var baseTrim = __nccwpck_require__(9528), + isObject = __nccwpck_require__(3334), + isSymbol = __nccwpck_require__(6403); + +/** Used as references for various `Number` constants. */ +var NAN = 0 / 0; + +/** Used to detect bad signed hexadecimal string values. */ +var reIsBadHex = /^[-+]0x[0-9a-f]+$/i; + +/** Used to detect binary string values. */ +var reIsBinary = /^0b[01]+$/i; + +/** Used to detect octal string values. */ +var reIsOctal = /^0o[0-7]+$/i; + +/** Built-in method references without a dependency on `root`. */ +var freeParseInt = parseInt; + +/** + * Converts `value` to a number. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to process. + * @returns {number} Returns the number. + * @example + * + * _.toNumber(3.2); + * // => 3.2 + * + * _.toNumber(Number.MIN_VALUE); + * // => 5e-324 + * + * _.toNumber(Infinity); + * // => Infinity + * + * _.toNumber('3.2'); + * // => 3.2 + */ +function toNumber(value) { + if (typeof value == 'number') { + return value; + } + if (isSymbol(value)) { + return NAN; + } + if (isObject(value)) { + var other = typeof value.valueOf == 'function' ? value.valueOf() : value; + value = isObject(other) ? (other + '') : other; + } + if (typeof value != 'string') { + return value === 0 ? value : +value; + } + value = baseTrim(value); + var isBinary = reIsBinary.test(value); + return (isBinary || reIsOctal.test(value)) + ? freeParseInt(value.slice(2), isBinary ? 2 : 8) + : (reIsBadHex.test(value) ? NAN : +value); +} + +module.exports = toNumber; + + /***/ }), /***/ 467: From 4bf12ac162e4669dd4b9fe03043a0578c6b1baa8 Mon Sep 17 00:00:00 2001 From: Blazej Kustra Date: Fri, 29 Mar 2024 14:29:05 +0100 Subject: [PATCH 2/4] Change @kie/mock-github import --- workflow_tests/createNewVersion.test.ts | 4 ++-- workflow_tests/deploy.test.ts | 4 ++-- workflow_tests/deployBlocker.test.ts | 4 ++-- workflow_tests/failureNotifier.test.ts | 4 ++-- workflow_tests/finishReleaseCycle.test.ts | 4 ++-- workflow_tests/lint.test.ts | 4 ++-- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/workflow_tests/createNewVersion.test.ts b/workflow_tests/createNewVersion.test.ts index 05dcc2b10073..786d9096821b 100644 --- a/workflow_tests/createNewVersion.test.ts +++ b/workflow_tests/createNewVersion.test.ts @@ -1,4 +1,4 @@ -import {MockGithub} from '@kie/mock-github'; +import * as kieMockGithub from '@kie/mock-github'; import path from 'path'; import assertions from './assertions/createNewVersionAssertions'; import mocks from './mocks/createNewVersionMocks'; @@ -25,7 +25,7 @@ describe('test workflow createNewVersion', () => { beforeEach(async () => { // create a local repository and copy required files - mockGithub = new MockGithub({ + mockGithub = new kieMockGithub.MockGithub({ repo: { testCreateNewVersionWorkflowRepo: { files: FILES_TO_COPY_INTO_TEST_REPO, diff --git a/workflow_tests/deploy.test.ts b/workflow_tests/deploy.test.ts index 4edb3b252d38..201d025b8d44 100644 --- a/workflow_tests/deploy.test.ts +++ b/workflow_tests/deploy.test.ts @@ -1,4 +1,4 @@ -import {MockGithub} from '@kie/mock-github'; +import * as kieMockGithub from '@kie/mock-github'; import path from 'path'; import assertions from './assertions/deployAssertions'; import mocks from './mocks/deployMocks'; @@ -25,7 +25,7 @@ describe('test workflow deploy', () => { beforeEach(async () => { // create a local repository and copy required files - mockGithub = new MockGithub({ + mockGithub = new kieMockGithub.MockGithub({ repo: { testDeployWorkflowRepo: { files: FILES_TO_COPY_INTO_TEST_REPO, diff --git a/workflow_tests/deployBlocker.test.ts b/workflow_tests/deployBlocker.test.ts index eb4cdc2c9497..b9fa4a5a34bb 100644 --- a/workflow_tests/deployBlocker.test.ts +++ b/workflow_tests/deployBlocker.test.ts @@ -1,5 +1,5 @@ /* eslint-disable @typescript-eslint/naming-convention */ -import {MockGithub} from '@kie/mock-github'; +import * as kieMockGithub from '@kie/mock-github'; import path from 'path'; import assertions from './assertions/deployBlockerAssertions'; import mocks from './mocks/deployBlockerMocks'; @@ -33,7 +33,7 @@ describe('test workflow deployBlocker', () => { beforeEach(async () => { // create a local repository and copy required files - mockGithub = new MockGithub({ + mockGithub = new kieMockGithub.MockGithub({ repo: { testDeployBlockerWorkflowRepo: { files: FILES_TO_COPY_INTO_TEST_REPO, diff --git a/workflow_tests/failureNotifier.test.ts b/workflow_tests/failureNotifier.test.ts index 8dfc092c7e61..c2328220bf12 100644 --- a/workflow_tests/failureNotifier.test.ts +++ b/workflow_tests/failureNotifier.test.ts @@ -1,6 +1,6 @@ import type {MockStep} from '@kie/act-js/build/src/step-mocker/step-mocker.types'; import type {CreateRepositoryFile} from '@kie/mock-github'; -import {MockGithub} from '@kie/mock-github'; +import * as kieMockGithub from '@kie/mock-github'; import path from 'path'; import assertions from './assertions/failureNotifierAssertions'; import mocks from './mocks/failureNotifierMocks'; @@ -20,7 +20,7 @@ describe('test workflow failureNotifier', () => { const actor = 'Dummy Actor'; beforeEach(async () => { // create a local repository and copy required files - mockGithub = new MockGithub({ + mockGithub = new kieMockGithub.MockGithub({ repo: { testFailureNotifierWorkflowRepo: { files: FILES_TO_COPY_INTO_TEST_REPO, diff --git a/workflow_tests/finishReleaseCycle.test.ts b/workflow_tests/finishReleaseCycle.test.ts index 7f81137807f4..0b5692790ed2 100644 --- a/workflow_tests/finishReleaseCycle.test.ts +++ b/workflow_tests/finishReleaseCycle.test.ts @@ -1,4 +1,4 @@ -import {MockGithub} from '@kie/mock-github'; +import * as kieMockGithub from '@kie/mock-github'; import path from 'path'; import assertions from './assertions/finishReleaseCycleAssertions'; import mocks from './mocks/finishReleaseCycleMocks'; @@ -26,7 +26,7 @@ describe('test workflow finishReleaseCycle', () => { beforeEach(async () => { // create a local repository and copy required files - mockGithub = new MockGithub({ + mockGithub = new kieMockGithub.MockGithub({ repo: { testFinishReleaseCycleWorkflowRepo: { files: FILES_TO_COPY_INTO_TEST_REPO, diff --git a/workflow_tests/lint.test.ts b/workflow_tests/lint.test.ts index e0b0fb13859d..4fdfd5e330c5 100644 --- a/workflow_tests/lint.test.ts +++ b/workflow_tests/lint.test.ts @@ -1,4 +1,4 @@ -import {MockGithub} from '@kie/mock-github'; +import * as kieMockGithub from '@kie/mock-github'; import path from 'path'; import assertions from './assertions/lintAssertions'; import mocks from './mocks/lintMocks'; @@ -28,7 +28,7 @@ describe('test workflow lint', () => { beforeEach(async () => { // create a local repository and copy required files - mockGithub = new MockGithub({ + mockGithub = new kieMockGithub.MockGithub({ repo: { testLintWorkflowRepo: { files: FILES_TO_COPY_INTO_TEST_REPO, From 39f52536905778a1e2d113255f6408462bb67e38 Mon Sep 17 00:00:00 2001 From: Blazej Kustra Date: Fri, 29 Mar 2024 14:30:56 +0100 Subject: [PATCH 3/4] Fix workflow tests --- workflow_tests/cla.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/workflow_tests/cla.test.ts b/workflow_tests/cla.test.ts index 0203eba865be..1de0988d9107 100644 --- a/workflow_tests/cla.test.ts +++ b/workflow_tests/cla.test.ts @@ -1,7 +1,7 @@ /* eslint-disable @typescript-eslint/naming-convention */ import type {Step} from '@kie/act-js'; import type {CreateRepositoryFile, MockGithub} from '@kie/mock-github'; -import kieMockGithub from '@kie/mock-github'; +import * as kieMockGithub from '@kie/mock-github'; import path from 'path'; import {assertCLAJobExecuted} from './assertions/claAssertions'; import {CLA__CLA__CHECK_MATCH__STEP_MOCKS, CLA__CLA__NO_MATCHES__STEP_MOCKS, CLA__CLA__RECHECK_MATCH__STEP_MOCKS} from './mocks/claMocks'; From d22d160f7171e549afde742c9be350614e935717 Mon Sep 17 00:00:00 2001 From: Blazej Kustra Date: Fri, 29 Mar 2024 14:36:10 +0100 Subject: [PATCH 4/4] Fix typecheck --- workflow_tests/README.md | 4 ++-- workflow_tests/authorChecklist.test.ts | 6 +++--- workflow_tests/cherryPick.test.ts | 6 +++--- workflow_tests/cla.test.ts | 6 +++--- workflow_tests/createNewVersion.test.ts | 4 ++-- workflow_tests/deploy.test.ts | 4 ++-- workflow_tests/deployBlocker.test.ts | 4 ++-- workflow_tests/failureNotifier.test.ts | 4 ++-- workflow_tests/finishReleaseCycle.test.ts | 4 ++-- workflow_tests/lint.test.ts | 4 ++-- workflow_tests/lockDeploys.test.ts | 6 +++--- workflow_tests/platformDeploy.test.ts | 6 +++--- workflow_tests/preDeploy.test.ts | 6 +++--- workflow_tests/reviewerChecklist.test.ts | 6 +++--- workflow_tests/test.test.ts | 6 +++--- 15 files changed, 38 insertions(+), 38 deletions(-) diff --git a/workflow_tests/README.md b/workflow_tests/README.md index 0c491fe6d9e0..b55e2691d13e 100644 --- a/workflow_tests/README.md +++ b/workflow_tests/README.md @@ -246,7 +246,7 @@ const FILES_TO_COPY_INTO_TEST_REPO = [ ]; beforeEach(async () => { - mockGithub = new kieMockGithub.MockGithub({ + mockGithub = new MockGithub({ repo: { testWorkflowsRepo: { files: FILES_TO_COPY_INTO_TEST_REPO, @@ -339,7 +339,7 @@ const FILES_TO_COPY_INTO_TEST_REPO = [ `beforeEach` gets executed before each test. Here we create the local test repository with the files defined in the `FILES_TO_COPY_INTO_TEST_REPO` variable. `testWorkflowRepo` is the name of the test repo and can be changed to whichever name you choose, just remember to use it later when accessing this repo. _Note that we can't use `beforeAll()` method, because while mocking steps `Act-js` modifies the workflow file copied into the test repo and thus mocking could persist between tests_ ```javascript beforeEach(async () => { - mockGithub = new kieMockGithub.MockGithub({ + mockGithub = new MockGithub({ repo: { testWorkflowsRepo: { files: FILES_TO_COPY_INTO_TEST_REPO, diff --git a/workflow_tests/authorChecklist.test.ts b/workflow_tests/authorChecklist.test.ts index c0b1c7cf7533..84509818ff61 100644 --- a/workflow_tests/authorChecklist.test.ts +++ b/workflow_tests/authorChecklist.test.ts @@ -1,6 +1,6 @@ import type {MockStep} from '@kie/act-js/build/src/step-mocker/step-mocker.types'; -import * as kieMockGithub from '@kie/mock-github'; -import type {CreateRepositoryFile, MockGithub} from '@kie/mock-github'; +import {MockGithub} from '@kie/mock-github'; +import type {CreateRepositoryFile} from '@kie/mock-github'; import path from 'path'; import assertions from './assertions/authorChecklistAssertions'; import mocks from './mocks/authorChecklistMocks'; @@ -30,7 +30,7 @@ describe('test workflow authorChecklist', () => { beforeEach(async () => { // create a local repository and copy required files - mockGithub = new kieMockGithub.MockGithub({ + mockGithub = new MockGithub({ repo: { testAuthorChecklistWorkflowRepo: { files: FILES_TO_COPY_INTO_TEST_REPO, diff --git a/workflow_tests/cherryPick.test.ts b/workflow_tests/cherryPick.test.ts index 47a1c489df70..56ce851755b6 100644 --- a/workflow_tests/cherryPick.test.ts +++ b/workflow_tests/cherryPick.test.ts @@ -1,6 +1,6 @@ import type {MockStep} from '@kie/act-js/build/src/step-mocker/step-mocker.types'; -import * as kieMockGithub from '@kie/mock-github'; -import type {CreateRepositoryFile, MockGithub} from '@kie/mock-github'; +import {MockGithub} from '@kie/mock-github'; +import type {CreateRepositoryFile} from '@kie/mock-github'; import path from 'path'; import assertions from './assertions/cherryPickAssertions'; import mocks from './mocks/cherryPickMocks'; @@ -29,7 +29,7 @@ describe('test workflow cherryPick', () => { beforeEach(async () => { // create a local repository and copy required files - mockGithub = new kieMockGithub.MockGithub({ + mockGithub = new MockGithub({ repo: { testCherryPickWorkflowRepo: { files: FILES_TO_COPY_INTO_TEST_REPO, diff --git a/workflow_tests/cla.test.ts b/workflow_tests/cla.test.ts index 1de0988d9107..31a721305b20 100644 --- a/workflow_tests/cla.test.ts +++ b/workflow_tests/cla.test.ts @@ -1,7 +1,7 @@ /* eslint-disable @typescript-eslint/naming-convention */ import type {Step} from '@kie/act-js'; -import type {CreateRepositoryFile, MockGithub} from '@kie/mock-github'; -import * as kieMockGithub from '@kie/mock-github'; +import {MockGithub} from '@kie/mock-github'; +import type {CreateRepositoryFile} from '@kie/mock-github'; import path from 'path'; import {assertCLAJobExecuted} from './assertions/claAssertions'; import {CLA__CLA__CHECK_MATCH__STEP_MOCKS, CLA__CLA__NO_MATCHES__STEP_MOCKS, CLA__CLA__RECHECK_MATCH__STEP_MOCKS} from './mocks/claMocks'; @@ -36,7 +36,7 @@ describe('test workflow cla', () => { beforeEach(async () => { // create a local repository and copy required files - mockGithub = new kieMockGithub.MockGithub({ + mockGithub = new MockGithub({ repo: { testClaWorkflowRepo: { files: FILES_TO_COPY_INTO_TEST_REPO, diff --git a/workflow_tests/createNewVersion.test.ts b/workflow_tests/createNewVersion.test.ts index 786d9096821b..05dcc2b10073 100644 --- a/workflow_tests/createNewVersion.test.ts +++ b/workflow_tests/createNewVersion.test.ts @@ -1,4 +1,4 @@ -import * as kieMockGithub from '@kie/mock-github'; +import {MockGithub} from '@kie/mock-github'; import path from 'path'; import assertions from './assertions/createNewVersionAssertions'; import mocks from './mocks/createNewVersionMocks'; @@ -25,7 +25,7 @@ describe('test workflow createNewVersion', () => { beforeEach(async () => { // create a local repository and copy required files - mockGithub = new kieMockGithub.MockGithub({ + mockGithub = new MockGithub({ repo: { testCreateNewVersionWorkflowRepo: { files: FILES_TO_COPY_INTO_TEST_REPO, diff --git a/workflow_tests/deploy.test.ts b/workflow_tests/deploy.test.ts index 201d025b8d44..4edb3b252d38 100644 --- a/workflow_tests/deploy.test.ts +++ b/workflow_tests/deploy.test.ts @@ -1,4 +1,4 @@ -import * as kieMockGithub from '@kie/mock-github'; +import {MockGithub} from '@kie/mock-github'; import path from 'path'; import assertions from './assertions/deployAssertions'; import mocks from './mocks/deployMocks'; @@ -25,7 +25,7 @@ describe('test workflow deploy', () => { beforeEach(async () => { // create a local repository and copy required files - mockGithub = new kieMockGithub.MockGithub({ + mockGithub = new MockGithub({ repo: { testDeployWorkflowRepo: { files: FILES_TO_COPY_INTO_TEST_REPO, diff --git a/workflow_tests/deployBlocker.test.ts b/workflow_tests/deployBlocker.test.ts index b9fa4a5a34bb..eb4cdc2c9497 100644 --- a/workflow_tests/deployBlocker.test.ts +++ b/workflow_tests/deployBlocker.test.ts @@ -1,5 +1,5 @@ /* eslint-disable @typescript-eslint/naming-convention */ -import * as kieMockGithub from '@kie/mock-github'; +import {MockGithub} from '@kie/mock-github'; import path from 'path'; import assertions from './assertions/deployBlockerAssertions'; import mocks from './mocks/deployBlockerMocks'; @@ -33,7 +33,7 @@ describe('test workflow deployBlocker', () => { beforeEach(async () => { // create a local repository and copy required files - mockGithub = new kieMockGithub.MockGithub({ + mockGithub = new MockGithub({ repo: { testDeployBlockerWorkflowRepo: { files: FILES_TO_COPY_INTO_TEST_REPO, diff --git a/workflow_tests/failureNotifier.test.ts b/workflow_tests/failureNotifier.test.ts index c2328220bf12..07ebb45517b3 100644 --- a/workflow_tests/failureNotifier.test.ts +++ b/workflow_tests/failureNotifier.test.ts @@ -1,6 +1,6 @@ import type {MockStep} from '@kie/act-js/build/src/step-mocker/step-mocker.types'; +import {MockGithub} from '@kie/mock-github'; import type {CreateRepositoryFile} from '@kie/mock-github'; -import * as kieMockGithub from '@kie/mock-github'; import path from 'path'; import assertions from './assertions/failureNotifierAssertions'; import mocks from './mocks/failureNotifierMocks'; @@ -20,7 +20,7 @@ describe('test workflow failureNotifier', () => { const actor = 'Dummy Actor'; beforeEach(async () => { // create a local repository and copy required files - mockGithub = new kieMockGithub.MockGithub({ + mockGithub = new MockGithub({ repo: { testFailureNotifierWorkflowRepo: { files: FILES_TO_COPY_INTO_TEST_REPO, diff --git a/workflow_tests/finishReleaseCycle.test.ts b/workflow_tests/finishReleaseCycle.test.ts index 0b5692790ed2..7f81137807f4 100644 --- a/workflow_tests/finishReleaseCycle.test.ts +++ b/workflow_tests/finishReleaseCycle.test.ts @@ -1,4 +1,4 @@ -import * as kieMockGithub from '@kie/mock-github'; +import {MockGithub} from '@kie/mock-github'; import path from 'path'; import assertions from './assertions/finishReleaseCycleAssertions'; import mocks from './mocks/finishReleaseCycleMocks'; @@ -26,7 +26,7 @@ describe('test workflow finishReleaseCycle', () => { beforeEach(async () => { // create a local repository and copy required files - mockGithub = new kieMockGithub.MockGithub({ + mockGithub = new MockGithub({ repo: { testFinishReleaseCycleWorkflowRepo: { files: FILES_TO_COPY_INTO_TEST_REPO, diff --git a/workflow_tests/lint.test.ts b/workflow_tests/lint.test.ts index 4fdfd5e330c5..e0b0fb13859d 100644 --- a/workflow_tests/lint.test.ts +++ b/workflow_tests/lint.test.ts @@ -1,4 +1,4 @@ -import * as kieMockGithub from '@kie/mock-github'; +import {MockGithub} from '@kie/mock-github'; import path from 'path'; import assertions from './assertions/lintAssertions'; import mocks from './mocks/lintMocks'; @@ -28,7 +28,7 @@ describe('test workflow lint', () => { beforeEach(async () => { // create a local repository and copy required files - mockGithub = new kieMockGithub.MockGithub({ + mockGithub = new MockGithub({ repo: { testLintWorkflowRepo: { files: FILES_TO_COPY_INTO_TEST_REPO, diff --git a/workflow_tests/lockDeploys.test.ts b/workflow_tests/lockDeploys.test.ts index be739b963cbb..c9b083b4d804 100644 --- a/workflow_tests/lockDeploys.test.ts +++ b/workflow_tests/lockDeploys.test.ts @@ -1,6 +1,6 @@ import type {MockStep} from '@kie/act-js/build/src/step-mocker/step-mocker.types'; -import * as kieMockGithub from '@kie/mock-github'; -import type {CreateRepositoryFile, MockGithub} from '@kie/mock-github'; +import {MockGithub} from '@kie/mock-github'; +import type {CreateRepositoryFile} from '@kie/mock-github'; import path from 'path'; import assertions from './assertions/lockDeploysAssertions'; import mocks from './mocks/lockDeploysMocks'; @@ -28,7 +28,7 @@ describe('test workflow lockDeploys', () => { beforeEach(async () => { // create a local repository and copy required files - mockGithub = new kieMockGithub.MockGithub({ + mockGithub = new MockGithub({ repo: { testLockDeploysWorkflowRepo: { files: FILES_TO_COPY_INTO_TEST_REPO, diff --git a/workflow_tests/platformDeploy.test.ts b/workflow_tests/platformDeploy.test.ts index 82903b3bbe14..0ac68eb6d55b 100644 --- a/workflow_tests/platformDeploy.test.ts +++ b/workflow_tests/platformDeploy.test.ts @@ -1,6 +1,6 @@ import type {MockStep} from '@kie/act-js/build/src/step-mocker/step-mocker.types'; -import * as kieMockGithub from '@kie/mock-github'; -import type {CreateRepositoryFile, MockGithub} from '@kie/mock-github'; +import {MockGithub} from '@kie/mock-github'; +import type {CreateRepositoryFile} from '@kie/mock-github'; import path from 'path'; import assertions from './assertions/platformDeployAssertions'; import mocks from './mocks/platformDeployMocks'; @@ -29,7 +29,7 @@ describe('test workflow platformDeploy', () => { beforeEach(async () => { // create a local repository and copy required files - mockGithub = new kieMockGithub.MockGithub({ + mockGithub = new MockGithub({ repo: { testPlatformDeployWorkflowRepo: { files: FILES_TO_COPY_INTO_TEST_REPO, diff --git a/workflow_tests/preDeploy.test.ts b/workflow_tests/preDeploy.test.ts index b75603c5e846..1739fec13815 100644 --- a/workflow_tests/preDeploy.test.ts +++ b/workflow_tests/preDeploy.test.ts @@ -1,6 +1,6 @@ import type {MockStep} from '@kie/act-js/build/src/step-mocker/step-mocker.types'; -import * as kieMockGithub from '@kie/mock-github'; -import type {CreateRepositoryFile, MockGithub} from '@kie/mock-github'; +import {MockGithub} from '@kie/mock-github'; +import type {CreateRepositoryFile} from '@kie/mock-github'; import path from 'path'; import assertions from './assertions/preDeployAssertions'; import mocks from './mocks/preDeployMocks'; @@ -29,7 +29,7 @@ describe('test workflow preDeploy', () => { beforeEach(async () => { // create a local repository and copy required files - mockGithub = new kieMockGithub.MockGithub({ + mockGithub = new MockGithub({ repo: { testPreDeployWorkflowRepo: { files: FILES_TO_COPY_INTO_TEST_REPO, diff --git a/workflow_tests/reviewerChecklist.test.ts b/workflow_tests/reviewerChecklist.test.ts index 07b325f9d699..d70afd31f115 100644 --- a/workflow_tests/reviewerChecklist.test.ts +++ b/workflow_tests/reviewerChecklist.test.ts @@ -1,6 +1,6 @@ import type {MockStep} from '@kie/act-js/build/src/step-mocker/step-mocker.types'; -import * as kieMockGithub from '@kie/mock-github'; -import type {CreateRepositoryFile, MockGithub} from '@kie/mock-github'; +import {MockGithub} from '@kie/mock-github'; +import type {CreateRepositoryFile} from '@kie/mock-github'; import path from 'path'; import assertions from './assertions/reviewerChecklistAssertions'; import mocks from './mocks/reviewerChecklistMocks'; @@ -31,7 +31,7 @@ describe('test workflow reviewerChecklist', () => { beforeEach(async () => { // create a local repository and copy required files - mockGithub = new kieMockGithub.MockGithub({ + mockGithub = new MockGithub({ repo: { testReviewerChecklistWorkflowRepo: { files: FILES_TO_COPY_INTO_TEST_REPO, diff --git a/workflow_tests/test.test.ts b/workflow_tests/test.test.ts index 331a657a486c..085a2b3902d6 100644 --- a/workflow_tests/test.test.ts +++ b/workflow_tests/test.test.ts @@ -1,6 +1,6 @@ import type {MockStep} from '@kie/act-js/build/src/step-mocker/step-mocker.types'; -import * as kieMockGithub from '@kie/mock-github'; -import type {CreateRepositoryFile, MockGithub} from '@kie/mock-github'; +import {MockGithub} from '@kie/mock-github'; +import type {CreateRepositoryFile} from '@kie/mock-github'; import path from 'path'; import assertions from './assertions/testAssertions'; import mocks from './mocks/testMocks'; @@ -32,7 +32,7 @@ describe('test workflow test', () => { beforeEach(async () => { // create a local repository and copy required files - mockGithub = new kieMockGithub.MockGithub({ + mockGithub = new MockGithub({ repo: { testTestWorkflowRepo: { files: FILES_TO_COPY_INTO_TEST_REPO,