From d797bc5826aa92b098c80cddc27d3747cee151ba Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Wed, 1 Nov 2023 13:25:41 +0200 Subject: [PATCH 01/66] Add main dev deps for e2e tests --- package.json | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index e3a0968f..b05ef364 100644 --- a/package.json +++ b/package.json @@ -35,11 +35,16 @@ }, "devDependencies": { "@mapbox/node-pre-gyp": "1.0.6", + "@wdio/cli": "8.20.5", + "@wdio/local-runner": "8.20.5", + "@wdio/mocha-framework": "8.20.3", + "@wdio/spec-reporter": "8.20.0", "app-builder-bin": "4.1.0", "electron": "27.0.2", "electron-builder": "23.6.0", "mocha": "10.2.0", - "standard": "16.0.4" + "standard": "16.0.4", + "wdio-electron-service": "5.3.0" }, "standard": { "globals": [ From 8e47c61871a23ecbe4717e33522f89c92620c23d Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Wed, 1 Nov 2023 13:26:50 +0200 Subject: [PATCH 02/66] Add base webdriverio config --- wdio.conf.js | 291 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 291 insertions(+) create mode 100644 wdio.conf.js diff --git a/wdio.conf.js b/wdio.conf.js new file mode 100644 index 00000000..a3a9e9e3 --- /dev/null +++ b/wdio.conf.js @@ -0,0 +1,291 @@ +process.env.TEST = 'true' + +exports.config = { + // + // ==================== + // Runner Configuration + // ==================== + // WebdriverIO supports running e2e tests as well as unit and component tests. + runner: 'local', + // + // ================== + // Specify Test Files + // ================== + // Define which test specs should run. The pattern is relative to the directory + // of the configuration file being run. + // + // The specs are defined as an array of spec files (optionally using wildcards + // that will be expanded). The test for each spec file will be run in a separate + // worker process. In order to have a group of spec files run in the same worker + // process simply enclose them in an array within the specs array. + // + // If you are calling `wdio` from an NPM script (see https://docs.npmjs.com/cli/run-script), + // then the current working directory is where your `package.json` resides, so `wdio` + // will be called from there. + // + specs: [ + './test/specs/**/*.js' + ], + // Patterns to exclude. + exclude: [ + // 'path/to/excluded/files' + ], + // + // ============ + // Capabilities + // ============ + // Define your capabilities here. WebdriverIO can run multiple capabilities at the same + // time. Depending on the number of capabilities, WebdriverIO launches several test + // sessions. Within your capabilities you can overwrite the spec and exclude options in + // order to group specific specs to a specific capability. + // + // First, you can define how many instances should be started at the same time. Let's + // say you have 3 different capabilities (Chrome, Firefox, and Safari) and you have + // set maxInstances to 1; wdio will spawn 3 processes. Therefore, if you have 10 spec + // files and you set maxInstances to 10, all spec files will get tested at the same time + // and 30 processes will get spawned. The property handles how many capabilities + // from the same test should run tests. + // + maxInstances: 10, + // + // If you have trouble getting all important capabilities together, check out the + // Sauce Labs platform configurator - a great tool to configure your capabilities: + // https://saucelabs.com/platform/platform-configurator + // + capabilities: [{ + browserName: 'electron', + // Electron service options + // see https://webdriver.io/docs/wdio-electron-service/#configuration + 'wdio:electronServiceOptions': { + // custom application args + appArgs: [] + } + }], + + // + // =================== + // Test Configurations + // =================== + // Define all options that are relevant for the WebdriverIO instance here + // + // Level of logging verbosity: trace | debug | info | warn | error | silent + logLevel: 'info', + // + // Set specific log levels per logger + // loggers: + // - webdriver, webdriverio + // - @wdio/browserstack-service, @wdio/devtools-service, @wdio/sauce-service + // - @wdio/mocha-framework, @wdio/jasmine-framework + // - @wdio/local-runner + // - @wdio/sumologic-reporter + // - @wdio/cli, @wdio/config, @wdio/utils + // Level of logging verbosity: trace | debug | info | warn | error | silent + // logLevels: { + // webdriver: 'info', + // '@wdio/appium-service': 'info' + // }, + // + // If you only want to run your tests until a specific amount of tests have failed use + // bail (default is 0 - don't bail, run all tests). + bail: 0, + // + // Set a base URL in order to shorten url command calls. If your `url` parameter starts + // with `/`, the base url gets prepended, not including the path portion of your baseUrl. + // If your `url` parameter starts without a scheme or `/` (like `some/path`), the base url + // gets prepended directly. + baseUrl: '', + // + // Default timeout for all waitFor* commands. + waitforTimeout: 10000, + // + // Default timeout in milliseconds for request + // if browser driver or grid doesn't send response + connectionRetryTimeout: 120000, + // + // Default request retries count + connectionRetryCount: 3, + // + // Test runner services + // Services take over a specific job you don't want to take care of. They enhance + // your test setup with almost no effort. Unlike plugins, they don't add new + // commands. Instead, they hook themselves up into the test process. + services: ['electron'], + + // Framework you want to run your specs with. + // The following are supported: Mocha, Jasmine, and Cucumber + // see also: https://webdriver.io/docs/frameworks + // + // Make sure you have the wdio adapter package for the specific framework installed + // before running any tests. + framework: 'mocha', + + // + // The number of times to retry the entire specfile when it fails as a whole + // specFileRetries: 1, + // + // Delay in seconds between the spec file retry attempts + // specFileRetriesDelay: 0, + // + // Whether or not retried spec files should be retried immediately or deferred to the end of the queue + // specFileRetriesDeferred: false, + // + // Test reporter for stdout. + // The only one supported by default is 'dot' + // see also: https://webdriver.io/docs/dot-reporter + reporters: ['spec'], + + // Options to be passed to Mocha. + // See the full list at http://mochajs.org/ + mochaOpts: { + ui: 'bdd', + timeout: 60000 + }, + + // + // ===== + // Hooks + // ===== + // WebdriverIO provides several hooks you can use to interfere with the test process in order to enhance + // it and to build services around it. You can either apply a single function or an array of + // methods to it. If one of them returns with a promise, WebdriverIO will wait until that promise got + // resolved to continue. + /** + * Gets executed once before all workers get launched. + * @param {object} config wdio configuration object + * @param {Array.} capabilities list of capabilities details + */ + // onPrepare: function (config, capabilities) { + // }, + /** + * Gets executed before a worker process is spawned and can be used to initialise specific service + * for that worker as well as modify runtime environments in an async fashion. + * @param {string} cid capability id (e.g 0-0) + * @param {object} caps object containing capabilities for session that will be spawn in the worker + * @param {object} specs specs to be run in the worker process + * @param {object} args object that will be merged with the main configuration once worker is initialized + * @param {object} execArgv list of string arguments passed to the worker process + */ + // onWorkerStart: function (cid, caps, specs, args, execArgv) { + // }, + /** + * Gets executed just after a worker process has exited. + * @param {string} cid capability id (e.g 0-0) + * @param {number} exitCode 0 - success, 1 - fail + * @param {object} specs specs to be run in the worker process + * @param {number} retries number of retries used + */ + // onWorkerEnd: function (cid, exitCode, specs, retries) { + // }, + /** + * Gets executed just before initialising the webdriver session and test framework. It allows you + * to manipulate configurations depending on the capability or spec. + * @param {object} config wdio configuration object + * @param {Array.} capabilities list of capabilities details + * @param {Array.} specs List of spec file paths that are to be run + * @param {string} cid worker id (e.g. 0-0) + */ + // beforeSession: function (config, capabilities, specs, cid) { + // }, + /** + * Gets executed before test execution begins. At this point you can access to all global + * variables like `browser`. It is the perfect place to define custom commands. + * @param {Array.} capabilities list of capabilities details + * @param {Array.} specs List of spec file paths that are to be run + * @param {object} browser instance of created browser/device session + */ + // before: function (capabilities, specs) { + // }, + /** + * Runs before a WebdriverIO command gets executed. + * @param {string} commandName hook command name + * @param {Array} args arguments that command would receive + */ + // beforeCommand: function (commandName, args) { + // }, + /** + * Hook that gets executed before the suite starts + * @param {object} suite suite details + */ + // beforeSuite: function (suite) { + // }, + /** + * Function to be executed before a test (in Mocha/Jasmine) starts. + */ + // beforeTest: function (test, context) { + // }, + /** + * Hook that gets executed _before_ a hook within the suite starts (e.g. runs before calling + * beforeEach in Mocha) + */ + // beforeHook: function (test, context, hookName) { + // }, + /** + * Hook that gets executed _after_ a hook within the suite starts (e.g. runs after calling + * afterEach in Mocha) + */ + // afterHook: function (test, context, { error, result, duration, passed, retries }, hookName) { + // }, + /** + * Function to be executed after a test (in Mocha/Jasmine only) + * @param {object} test test object + * @param {object} context scope object the test was executed with + * @param {Error} result.error error object in case the test fails, otherwise `undefined` + * @param {*} result.result return object of test function + * @param {number} result.duration duration of test + * @param {boolean} result.passed true if test has passed, otherwise false + * @param {object} result.retries information about spec related retries, e.g. `{ attempts: 0, limit: 0 }` + */ + // afterTest: function(test, context, { error, result, duration, passed, retries }) { + // }, + + + /** + * Hook that gets executed after the suite has ended + * @param {object} suite suite details + */ + // afterSuite: function (suite) { + // }, + /** + * Runs after a WebdriverIO command gets executed + * @param {string} commandName hook command name + * @param {Array} args arguments that command would receive + * @param {number} result 0 - command success, 1 - command error + * @param {object} error error object if any + */ + // afterCommand: function (commandName, args, result, error) { + // }, + /** + * Gets executed after all tests are done. You still have access to all global variables from + * the test. + * @param {number} result 0 - test pass, 1 - test fail + * @param {Array.} capabilities list of capabilities details + * @param {Array.} specs List of spec file paths that ran + */ + // after: function (result, capabilities, specs) { + // }, + /** + * Gets executed right after terminating the webdriver session. + * @param {object} config wdio configuration object + * @param {Array.} capabilities list of capabilities details + * @param {Array.} specs List of spec file paths that ran + */ + // afterSession: function (config, capabilities, specs) { + // }, + /** + * Gets executed after all workers got shut down and the process is about to exit. An error + * thrown in the onComplete hook will result in the test run failing. + * @param {object} exitCode 0 - success, 1 - fail + * @param {object} config wdio configuration object + * @param {Array.} capabilities list of capabilities details + * @param {} results object containing test results + */ + // onComplete: function(exitCode, config, capabilities, results) { + // }, + /** + * Gets executed when a refresh happens. + * @param {string} oldSessionId session ID of the old session + * @param {string} newSessionId session ID of the new session + */ + // onReload: function(oldSessionId, newSessionId) { + // } +} From 03a1de1f5fa2ee46a9513b63ff5bb85fe3b74993 Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Wed, 1 Nov 2023 13:39:11 +0200 Subject: [PATCH 03/66] Add test case for app title --- test/specs/test.e2e.js | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 test/specs/test.e2e.js diff --git a/test/specs/test.e2e.js b/test/specs/test.e2e.js new file mode 100644 index 00000000..4ccd45e0 --- /dev/null +++ b/test/specs/test.e2e.js @@ -0,0 +1,7 @@ +const { browser } = require('@wdio/globals') + +describe('Electron Testing', () => { + it('should print application title', async () => { + expect(await await browser.getTitle()).toBe('Bitfinex Reporting & Performance Tools') + }) +}) From d05239b08b7e8c0ed546e2a51994831552bf3ec3 Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Wed, 1 Nov 2023 13:42:25 +0200 Subject: [PATCH 04/66] Expose electron api in test env for main process --- index.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/index.js b/index.js index 98810008..4de1e892 100644 --- a/index.js +++ b/index.js @@ -14,6 +14,8 @@ try { const { app } = require('electron') +const isTestEnv = process.env.NODE_ENV === 'test' + const productName = require('./src/helpers/product-name') app.setName(productName) @@ -33,6 +35,10 @@ if (shouldQuit) { } else { ;(async () => { try { + if (isTestEnv) { + require('wdio-electron-service/main') + } + await initializeApp() } catch (err) { console.error(err) From a8037e87caf995e2426abda885ccb9439fdfc5b6 Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Wed, 1 Nov 2023 13:43:49 +0200 Subject: [PATCH 05/66] Add preload script for browser windows --- src/preload.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 src/preload.js diff --git a/src/preload.js b/src/preload.js new file mode 100644 index 00000000..804b55ab --- /dev/null +++ b/src/preload.js @@ -0,0 +1,16 @@ +'use strict' + +const { ipcRenderer, contextBridge } = require('electron') + +// See the Electron documentation for details on how to use preload scripts: +// https://www.electronjs.org/docs/latest/tutorial/process-model#preload-scripts +const isTest = process.env.NODE_ENV === 'test' + +if (isTest) { + require('wdio-electron-service/preload') +} + +contextBridge.exposeInMainWorld('electron', { + openDialog: (method, config) => ipcRenderer + .send('dialog', method, config) +}) From 46c2f101f95b477e6661b6ceca63e7ced41b1361 Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Wed, 1 Nov 2023 13:44:51 +0200 Subject: [PATCH 06/66] Expose electron api in test env for browser wins --- src/window-creators.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/window-creators.js b/src/window-creators.js index 461eb16f..79f9a016 100644 --- a/src/window-creators.js +++ b/src/window-creators.js @@ -6,6 +6,7 @@ const { URL } = require('url') const { BrowserWindow } = electron const isDevEnv = process.env.NODE_ENV === 'development' +const isTestEnv = process.env.NODE_ENV === 'test' const isMac = process.platform === 'darwin' const wins = require('./windows') @@ -93,7 +94,13 @@ const _createWindow = async ( icon: path.join(__dirname, '../build/icons/512x512.png'), backgroundColor: '#172d3e', show: false, - ...props + ...props, + + webPreferences: { + sandbox: !isTestEnv, + preload: path.join(__dirname, 'preload.js'), + ...props?.webPreferences + } } wins[winName] = new BrowserWindow(_props) From 1b95cd3abc9f50f3e21f66a03604bb05d1e27c91 Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Wed, 1 Nov 2023 13:45:47 +0200 Subject: [PATCH 07/66] Add npm script to launch e2e tests --- package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index b05ef364..12300366 100644 --- a/package.json +++ b/package.json @@ -60,6 +60,7 @@ "unit": "export NODE_ENV=test && mocha './src/**/__test__/*.spec.js' --config .mocharc.json", "setup": "./scripts/setup.sh", "launch": "./scripts/launch.sh", - "sync-repo": "./scripts/sync-repo.sh" + "sync-repo": "./scripts/sync-repo.sh", + "e2e": "export NODE_ENV=test && wdio run ./wdio.conf.js" } } From e1e74eac59a354c8760c8a2e4c56ac42e8e02178 Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Fri, 3 Nov 2023 11:55:06 +0200 Subject: [PATCH 08/66] Prevent removal app unpacked folder for e2e test runner --- scripts/build-release.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/build-release.sh b/scripts/build-release.sh index a2718592..601317d5 100755 --- a/scripts/build-release.sh +++ b/scripts/build-release.sh @@ -236,7 +236,9 @@ node "$ROOT/node_modules/.bin/electron-builder" \ unpackedFolder=$(ls -d "$DIST_FOLDER/"*/ | grep $targetPlatform | head -1) -rm -rf "$unpackedFolder" +# Don't remove the unpacked folder of the app for e2e test runner +# but keep it for further debugging purposes +# rm -rf "$unpackedFolder" rm -rf "$DIST_FOLDER/.icon-ico" rm -f "$DIST_FOLDER/builder-effective-config.yaml" rm -f "$DIST_FOLDER/builder-debug.yml" From 53aadf7a04e9347b960e53a826be09e1d7dea8da Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Fri, 3 Nov 2023 11:57:14 +0200 Subject: [PATCH 09/66] Improve wdio config --- wdio.conf.js | 561 +++++++++++++++++++++++++-------------------------- 1 file changed, 280 insertions(+), 281 deletions(-) diff --git a/wdio.conf.js b/wdio.conf.js index a3a9e9e3..08e2a7b4 100644 --- a/wdio.conf.js +++ b/wdio.conf.js @@ -1,291 +1,290 @@ process.env.TEST = 'true' exports.config = { - // - // ==================== - // Runner Configuration - // ==================== - // WebdriverIO supports running e2e tests as well as unit and component tests. - runner: 'local', - // - // ================== - // Specify Test Files - // ================== - // Define which test specs should run. The pattern is relative to the directory - // of the configuration file being run. - // - // The specs are defined as an array of spec files (optionally using wildcards - // that will be expanded). The test for each spec file will be run in a separate - // worker process. In order to have a group of spec files run in the same worker - // process simply enclose them in an array within the specs array. - // - // If you are calling `wdio` from an NPM script (see https://docs.npmjs.com/cli/run-script), - // then the current working directory is where your `package.json` resides, so `wdio` - // will be called from there. - // - specs: [ - './test/specs/**/*.js' - ], - // Patterns to exclude. - exclude: [ - // 'path/to/excluded/files' - ], - // - // ============ - // Capabilities - // ============ - // Define your capabilities here. WebdriverIO can run multiple capabilities at the same - // time. Depending on the number of capabilities, WebdriverIO launches several test - // sessions. Within your capabilities you can overwrite the spec and exclude options in - // order to group specific specs to a specific capability. - // - // First, you can define how many instances should be started at the same time. Let's - // say you have 3 different capabilities (Chrome, Firefox, and Safari) and you have - // set maxInstances to 1; wdio will spawn 3 processes. Therefore, if you have 10 spec - // files and you set maxInstances to 10, all spec files will get tested at the same time - // and 30 processes will get spawned. The property handles how many capabilities - // from the same test should run tests. - // - maxInstances: 10, - // - // If you have trouble getting all important capabilities together, check out the - // Sauce Labs platform configurator - a great tool to configure your capabilities: - // https://saucelabs.com/platform/platform-configurator - // - capabilities: [{ - browserName: 'electron', - // Electron service options - // see https://webdriver.io/docs/wdio-electron-service/#configuration - 'wdio:electronServiceOptions': { - // custom application args - appArgs: [] - } - }], + // + // ==================== + // Runner Configuration + // ==================== + // WebdriverIO supports running e2e tests as well as unit and component tests. + runner: 'local', + // + // ================== + // Specify Test Files + // ================== + // Define which test specs should run. The pattern is relative to the directory + // of the configuration file being run. + // + // The specs are defined as an array of spec files (optionally using wildcards + // that will be expanded). The test for each spec file will be run in a separate + // worker process. In order to have a group of spec files run in the same worker + // process simply enclose them in an array within the specs array. + // + // If you are calling `wdio` from an NPM script (see https://docs.npmjs.com/cli/run-script), + // then the current working directory is where your `package.json` resides, so `wdio` + // will be called from there. + // + specs: [ + './test/e2e/*.spec.js' + ], + // Patterns to exclude. + exclude: [ + // 'path/to/excluded/files' + ], + // + // ============ + // Capabilities + // ============ + // Define your capabilities here. WebdriverIO can run multiple capabilities at the same + // time. Depending on the number of capabilities, WebdriverIO launches several test + // sessions. Within your capabilities you can overwrite the spec and exclude options in + // order to group specific specs to a specific capability. + // + // First, you can define how many instances should be started at the same time. Let's + // say you have 3 different capabilities (Chrome, Firefox, and Safari) and you have + // set maxInstances to 1; wdio will spawn 3 processes. Therefore, if you have 10 spec + // files and you set maxInstances to 10, all spec files will get tested at the same time + // and 30 processes will get spawned. The property handles how many capabilities + // from the same test should run tests. + // + maxInstances: 10, + // + // If you have trouble getting all important capabilities together, check out the + // Sauce Labs platform configurator - a great tool to configure your capabilities: + // https://saucelabs.com/platform/platform-configurator + // + capabilities: [{ + browserName: 'electron', + // Electron service options + // see https://webdriver.io/docs/wdio-electron-service/#configuration + 'wdio:electronServiceOptions': { + // custom application args + appArgs: [] + } + }], - // - // =================== - // Test Configurations - // =================== - // Define all options that are relevant for the WebdriverIO instance here - // - // Level of logging verbosity: trace | debug | info | warn | error | silent - logLevel: 'info', - // - // Set specific log levels per logger - // loggers: - // - webdriver, webdriverio - // - @wdio/browserstack-service, @wdio/devtools-service, @wdio/sauce-service - // - @wdio/mocha-framework, @wdio/jasmine-framework - // - @wdio/local-runner - // - @wdio/sumologic-reporter - // - @wdio/cli, @wdio/config, @wdio/utils - // Level of logging verbosity: trace | debug | info | warn | error | silent - // logLevels: { - // webdriver: 'info', - // '@wdio/appium-service': 'info' - // }, - // - // If you only want to run your tests until a specific amount of tests have failed use - // bail (default is 0 - don't bail, run all tests). - bail: 0, - // - // Set a base URL in order to shorten url command calls. If your `url` parameter starts - // with `/`, the base url gets prepended, not including the path portion of your baseUrl. - // If your `url` parameter starts without a scheme or `/` (like `some/path`), the base url - // gets prepended directly. - baseUrl: '', - // - // Default timeout for all waitFor* commands. - waitforTimeout: 10000, - // - // Default timeout in milliseconds for request - // if browser driver or grid doesn't send response - connectionRetryTimeout: 120000, - // - // Default request retries count - connectionRetryCount: 3, - // - // Test runner services - // Services take over a specific job you don't want to take care of. They enhance - // your test setup with almost no effort. Unlike plugins, they don't add new - // commands. Instead, they hook themselves up into the test process. - services: ['electron'], + // + // =================== + // Test Configurations + // =================== + // Define all options that are relevant for the WebdriverIO instance here + // + // Level of logging verbosity: trace | debug | info | warn | error | silent + logLevel: 'debug', + // + // Set specific log levels per logger + // loggers: + // - webdriver, webdriverio + // - @wdio/browserstack-service, @wdio/devtools-service, @wdio/sauce-service + // - @wdio/mocha-framework, @wdio/jasmine-framework + // - @wdio/local-runner + // - @wdio/sumologic-reporter + // - @wdio/cli, @wdio/config, @wdio/utils + // Level of logging verbosity: trace | debug | info | warn | error | silent + // logLevels: { + // webdriver: 'info', + // '@wdio/appium-service': 'info' + // }, + // + // If you only want to run your tests until a specific amount of tests have failed use + // bail (default is 0 - don't bail, run all tests). + bail: 0, + // + // Set a base URL in order to shorten url command calls. If your `url` parameter starts + // with `/`, the base url gets prepended, not including the path portion of your baseUrl. + // If your `url` parameter starts without a scheme or `/` (like `some/path`), the base url + // gets prepended directly. + baseUrl: '', + // + // Default timeout for all waitFor* commands. + waitforTimeout: 10000, + // + // Default timeout in milliseconds for request + // if browser driver or grid doesn't send response + connectionRetryTimeout: 120000, + // + // Default request retries count + connectionRetryCount: 3, + // + // Test runner services + // Services take over a specific job you don't want to take care of. They enhance + // your test setup with almost no effort. Unlike plugins, they don't add new + // commands. Instead, they hook themselves up into the test process. + services: ['electron'], - // Framework you want to run your specs with. - // The following are supported: Mocha, Jasmine, and Cucumber - // see also: https://webdriver.io/docs/frameworks - // - // Make sure you have the wdio adapter package for the specific framework installed - // before running any tests. - framework: 'mocha', - - // - // The number of times to retry the entire specfile when it fails as a whole - // specFileRetries: 1, - // - // Delay in seconds between the spec file retry attempts - // specFileRetriesDelay: 0, - // - // Whether or not retried spec files should be retried immediately or deferred to the end of the queue - // specFileRetriesDeferred: false, - // - // Test reporter for stdout. - // The only one supported by default is 'dot' - // see also: https://webdriver.io/docs/dot-reporter - reporters: ['spec'], + // Framework you want to run your specs with. + // The following are supported: Mocha, Jasmine, and Cucumber + // see also: https://webdriver.io/docs/frameworks + // + // Make sure you have the wdio adapter package for the specific framework installed + // before running any tests. + framework: 'mocha', - // Options to be passed to Mocha. - // See the full list at http://mochajs.org/ - mochaOpts: { - ui: 'bdd', - timeout: 60000 - }, + // + // The number of times to retry the entire specfile when it fails as a whole + // specFileRetries: 1, + // + // Delay in seconds between the spec file retry attempts + // specFileRetriesDelay: 0, + // + // Whether or not retried spec files should be retried immediately or deferred to the end of the queue + // specFileRetriesDeferred: false, + // + // Test reporter for stdout. + // The only one supported by default is 'dot' + // see also: https://webdriver.io/docs/dot-reporter + reporters: ['spec'], - // - // ===== - // Hooks - // ===== - // WebdriverIO provides several hooks you can use to interfere with the test process in order to enhance - // it and to build services around it. You can either apply a single function or an array of - // methods to it. If one of them returns with a promise, WebdriverIO will wait until that promise got - // resolved to continue. - /** - * Gets executed once before all workers get launched. - * @param {object} config wdio configuration object - * @param {Array.} capabilities list of capabilities details - */ - // onPrepare: function (config, capabilities) { - // }, - /** - * Gets executed before a worker process is spawned and can be used to initialise specific service - * for that worker as well as modify runtime environments in an async fashion. - * @param {string} cid capability id (e.g 0-0) - * @param {object} caps object containing capabilities for session that will be spawn in the worker - * @param {object} specs specs to be run in the worker process - * @param {object} args object that will be merged with the main configuration once worker is initialized - * @param {object} execArgv list of string arguments passed to the worker process - */ - // onWorkerStart: function (cid, caps, specs, args, execArgv) { - // }, - /** - * Gets executed just after a worker process has exited. - * @param {string} cid capability id (e.g 0-0) - * @param {number} exitCode 0 - success, 1 - fail - * @param {object} specs specs to be run in the worker process - * @param {number} retries number of retries used - */ - // onWorkerEnd: function (cid, exitCode, specs, retries) { - // }, - /** - * Gets executed just before initialising the webdriver session and test framework. It allows you - * to manipulate configurations depending on the capability or spec. - * @param {object} config wdio configuration object - * @param {Array.} capabilities list of capabilities details - * @param {Array.} specs List of spec file paths that are to be run - * @param {string} cid worker id (e.g. 0-0) - */ - // beforeSession: function (config, capabilities, specs, cid) { - // }, - /** - * Gets executed before test execution begins. At this point you can access to all global - * variables like `browser`. It is the perfect place to define custom commands. - * @param {Array.} capabilities list of capabilities details - * @param {Array.} specs List of spec file paths that are to be run - * @param {object} browser instance of created browser/device session - */ - // before: function (capabilities, specs) { - // }, - /** - * Runs before a WebdriverIO command gets executed. - * @param {string} commandName hook command name - * @param {Array} args arguments that command would receive - */ - // beforeCommand: function (commandName, args) { - // }, - /** - * Hook that gets executed before the suite starts - * @param {object} suite suite details - */ - // beforeSuite: function (suite) { - // }, - /** - * Function to be executed before a test (in Mocha/Jasmine) starts. - */ - // beforeTest: function (test, context) { - // }, - /** - * Hook that gets executed _before_ a hook within the suite starts (e.g. runs before calling - * beforeEach in Mocha) - */ - // beforeHook: function (test, context, hookName) { - // }, - /** - * Hook that gets executed _after_ a hook within the suite starts (e.g. runs after calling - * afterEach in Mocha) - */ - // afterHook: function (test, context, { error, result, duration, passed, retries }, hookName) { - // }, - /** - * Function to be executed after a test (in Mocha/Jasmine only) - * @param {object} test test object - * @param {object} context scope object the test was executed with - * @param {Error} result.error error object in case the test fails, otherwise `undefined` - * @param {*} result.result return object of test function - * @param {number} result.duration duration of test - * @param {boolean} result.passed true if test has passed, otherwise false - * @param {object} result.retries information about spec related retries, e.g. `{ attempts: 0, limit: 0 }` - */ - // afterTest: function(test, context, { error, result, duration, passed, retries }) { - // }, + // Options to be passed to Mocha. + // See the full list at http://mochajs.org/ + mochaOpts: { + ui: 'bdd', + timeout: 60000 + } + // + // ===== + // Hooks + // ===== + // WebdriverIO provides several hooks you can use to interfere with the test process in order to enhance + // it and to build services around it. You can either apply a single function or an array of + // methods to it. If one of them returns with a promise, WebdriverIO will wait until that promise got + // resolved to continue. + /** + * Gets executed once before all workers get launched. + * @param {object} config wdio configuration object + * @param {Array.} capabilities list of capabilities details + */ + // onPrepare: function (config, capabilities) { + // }, + /** + * Gets executed before a worker process is spawned and can be used to initialise specific service + * for that worker as well as modify runtime environments in an async fashion. + * @param {string} cid capability id (e.g 0-0) + * @param {object} caps object containing capabilities for session that will be spawn in the worker + * @param {object} specs specs to be run in the worker process + * @param {object} args object that will be merged with the main configuration once worker is initialized + * @param {object} execArgv list of string arguments passed to the worker process + */ + // onWorkerStart: function (cid, caps, specs, args, execArgv) { + // }, + /** + * Gets executed just after a worker process has exited. + * @param {string} cid capability id (e.g 0-0) + * @param {number} exitCode 0 - success, 1 - fail + * @param {object} specs specs to be run in the worker process + * @param {number} retries number of retries used + */ + // onWorkerEnd: function (cid, exitCode, specs, retries) { + // }, + /** + * Gets executed just before initialising the webdriver session and test framework. It allows you + * to manipulate configurations depending on the capability or spec. + * @param {object} config wdio configuration object + * @param {Array.} capabilities list of capabilities details + * @param {Array.} specs List of spec file paths that are to be run + * @param {string} cid worker id (e.g. 0-0) + */ + // beforeSession: function (config, capabilities, specs, cid) { + // }, + /** + * Gets executed before test execution begins. At this point you can access to all global + * variables like `browser`. It is the perfect place to define custom commands. + * @param {Array.} capabilities list of capabilities details + * @param {Array.} specs List of spec file paths that are to be run + * @param {object} browser instance of created browser/device session + */ + // before: function (capabilities, specs) { + // }, + /** + * Runs before a WebdriverIO command gets executed. + * @param {string} commandName hook command name + * @param {Array} args arguments that command would receive + */ + // beforeCommand: function (commandName, args) { + // }, + /** + * Hook that gets executed before the suite starts + * @param {object} suite suite details + */ + // beforeSuite: function (suite) { + // }, + /** + * Function to be executed before a test (in Mocha/Jasmine) starts. + */ + // beforeTest: function (test, context) { + // }, + /** + * Hook that gets executed _before_ a hook within the suite starts (e.g. runs before calling + * beforeEach in Mocha) + */ + // beforeHook: function (test, context, hookName) { + // }, + /** + * Hook that gets executed _after_ a hook within the suite starts (e.g. runs after calling + * afterEach in Mocha) + */ + // afterHook: function (test, context, { error, result, duration, passed, retries }, hookName) { + // }, + /** + * Function to be executed after a test (in Mocha/Jasmine only) + * @param {object} test test object + * @param {object} context scope object the test was executed with + * @param {Error} result.error error object in case the test fails, otherwise `undefined` + * @param {*} result.result return object of test function + * @param {number} result.duration duration of test + * @param {boolean} result.passed true if test has passed, otherwise false + * @param {object} result.retries information about spec related retries, e.g. `{ attempts: 0, limit: 0 }` + */ + // afterTest: function(test, context, { error, result, duration, passed, retries }) { + // }, - /** - * Hook that gets executed after the suite has ended - * @param {object} suite suite details - */ - // afterSuite: function (suite) { - // }, - /** - * Runs after a WebdriverIO command gets executed - * @param {string} commandName hook command name - * @param {Array} args arguments that command would receive - * @param {number} result 0 - command success, 1 - command error - * @param {object} error error object if any - */ - // afterCommand: function (commandName, args, result, error) { - // }, - /** - * Gets executed after all tests are done. You still have access to all global variables from - * the test. - * @param {number} result 0 - test pass, 1 - test fail - * @param {Array.} capabilities list of capabilities details - * @param {Array.} specs List of spec file paths that ran - */ - // after: function (result, capabilities, specs) { - // }, - /** - * Gets executed right after terminating the webdriver session. - * @param {object} config wdio configuration object - * @param {Array.} capabilities list of capabilities details - * @param {Array.} specs List of spec file paths that ran - */ - // afterSession: function (config, capabilities, specs) { - // }, - /** - * Gets executed after all workers got shut down and the process is about to exit. An error - * thrown in the onComplete hook will result in the test run failing. - * @param {object} exitCode 0 - success, 1 - fail - * @param {object} config wdio configuration object - * @param {Array.} capabilities list of capabilities details - * @param {} results object containing test results - */ - // onComplete: function(exitCode, config, capabilities, results) { - // }, - /** - * Gets executed when a refresh happens. - * @param {string} oldSessionId session ID of the old session - * @param {string} newSessionId session ID of the new session - */ - // onReload: function(oldSessionId, newSessionId) { - // } + /** + * Hook that gets executed after the suite has ended + * @param {object} suite suite details + */ + // afterSuite: function (suite) { + // }, + /** + * Runs after a WebdriverIO command gets executed + * @param {string} commandName hook command name + * @param {Array} args arguments that command would receive + * @param {number} result 0 - command success, 1 - command error + * @param {object} error error object if any + */ + // afterCommand: function (commandName, args, result, error) { + // }, + /** + * Gets executed after all tests are done. You still have access to all global variables from + * the test. + * @param {number} result 0 - test pass, 1 - test fail + * @param {Array.} capabilities list of capabilities details + * @param {Array.} specs List of spec file paths that ran + */ + // after: function (result, capabilities, specs) { + // }, + /** + * Gets executed right after terminating the webdriver session. + * @param {object} config wdio configuration object + * @param {Array.} capabilities list of capabilities details + * @param {Array.} specs List of spec file paths that ran + */ + // afterSession: function (config, capabilities, specs) { + // }, + /** + * Gets executed after all workers got shut down and the process is about to exit. An error + * thrown in the onComplete hook will result in the test run failing. + * @param {object} exitCode 0 - success, 1 - fail + * @param {object} config wdio configuration object + * @param {Array.} capabilities list of capabilities details + * @param {} results object containing test results + */ + // onComplete: function(exitCode, config, capabilities, results) { + // }, + /** + * Gets executed when a refresh happens. + * @param {string} oldSessionId session ID of the old session + * @param {string} newSessionId session ID of the new session + */ + // onReload: function(oldSessionId, newSessionId) { + // } } From e6248b2572141eb0dc851c4513f233bce481a6a0 Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Fri, 3 Nov 2023 11:59:09 +0200 Subject: [PATCH 10/66] Rework electron-builder config to be able to launch e2e tests --- electron-builder-config.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/electron-builder-config.js b/electron-builder-config.js index 8d4f2cee..255b85fd 100644 --- a/electron-builder-config.js +++ b/electron-builder-config.js @@ -73,7 +73,6 @@ module.exports = { updaterCacheDirName: 'bfx-report-electron-updater' }, linux: { - executableName: 'app', description: 'Bitfinex Report', maintainer: '', category: 'Network', @@ -143,6 +142,16 @@ module.exports = { to: 'bfx-report-ui/bfx-report-express/node_modules', filter: nodeModulesFilter }, + { + from: 'node_modules/wdio-electron-service', + to: 'node_modules/wdio-electron-service', + filter: nodeModulesFilter + }, + { + from: 'node_modules/wdio-electron-service/node_modules', + to: 'node_modules/wdio-electron-service/node_modules', + filter: nodeModulesFilter + }, ...getNodeModulesSubSources('bfx-reports-framework'), ...getNodeModulesSubSources('bfx-report-ui/bfx-report-express') ], From f4b6c41e588b8fd6e5b5cb9a816374727915ac66 Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Fri, 3 Nov 2023 12:01:31 +0200 Subject: [PATCH 11/66] Fix app e2e test spec --- test/e2e/application.spec.js | 7 +++++++ test/specs/test.e2e.js | 7 ------- 2 files changed, 7 insertions(+), 7 deletions(-) create mode 100644 test/e2e/application.spec.js delete mode 100644 test/specs/test.e2e.js diff --git a/test/e2e/application.spec.js b/test/e2e/application.spec.js new file mode 100644 index 00000000..bb4f2077 --- /dev/null +++ b/test/e2e/application.spec.js @@ -0,0 +1,7 @@ +const { browser, expect } = require('@wdio/globals') + +describe('Electron Testing', () => { + it('should print application title', async () => { + expect(await await browser.getTitle()).toBe('Bitfinex Reporting & Performance Tools') + }) +}) diff --git a/test/specs/test.e2e.js b/test/specs/test.e2e.js deleted file mode 100644 index 4ccd45e0..00000000 --- a/test/specs/test.e2e.js +++ /dev/null @@ -1,7 +0,0 @@ -const { browser } = require('@wdio/globals') - -describe('Electron Testing', () => { - it('should print application title', async () => { - expect(await await browser.getTitle()).toBe('Bitfinex Reporting & Performance Tools') - }) -}) From c5fc5f395a9f4b8250e6505cb83b11dbe29c0ac3 Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Fri, 3 Nov 2023 16:40:00 +0200 Subject: [PATCH 12/66] Add junit reporter for wdio --- package.json | 1 + wdio.conf.js | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 12300366..f8bd95c1 100644 --- a/package.json +++ b/package.json @@ -36,6 +36,7 @@ "devDependencies": { "@mapbox/node-pre-gyp": "1.0.6", "@wdio/cli": "8.20.5", + "@wdio/junit-reporter": "8.21.0", "@wdio/local-runner": "8.20.5", "@wdio/mocha-framework": "8.20.3", "@wdio/spec-reporter": "8.20.0", diff --git a/wdio.conf.js b/wdio.conf.js index 08e2a7b4..b12f3388 100644 --- a/wdio.conf.js +++ b/wdio.conf.js @@ -132,7 +132,15 @@ exports.config = { // Test reporter for stdout. // The only one supported by default is 'dot' // see also: https://webdriver.io/docs/dot-reporter - reporters: ['spec'], + reporters: [ + ['spec', { + showPreface: false + }], + ['junit', { + outputDir: './', + outputFileFormat: () => 'e2e-test-report.xml' + }] + ], // Options to be passed to Mocha. // See the full list at http://mochajs.org/ From 45044a4622c1c5bb9bfe8029f93ca2ff1dad0ad3 Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Fri, 3 Nov 2023 16:41:11 +0200 Subject: [PATCH 13/66] Add test reports to ignore files --- .dockerignore | 2 ++ .gitignore | 2 ++ 2 files changed, 4 insertions(+) diff --git a/.dockerignore b/.dockerignore index 437cb0ee..752df873 100644 --- a/.dockerignore +++ b/.dockerignore @@ -19,3 +19,5 @@ bfx-report-ui/build bfx-report-ui/bfx-report-express/logs/*.log bfx-report-ui/bfx-report-express/config/*.json stub.AppImage +e2e-test-report.xml +test-report.json diff --git a/.gitignore b/.gitignore index 63b4b0c8..204379e2 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,5 @@ package-lock.json lastCommit.json electronEnv.json stub.AppImage +e2e-test-report.xml +test-report.json From 2136dc0b363ad9f4a5c8d41fbb5de3b3d5777689 Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Fri, 3 Nov 2023 16:42:29 +0200 Subject: [PATCH 14/66] Add linux e2e test runner to github actions --- .github/workflows/build-electron-app.yml | 40 ++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/.github/workflows/build-electron-app.yml b/.github/workflows/build-electron-app.yml index f020e287..2b370607 100644 --- a/.github/workflows/build-electron-app.yml +++ b/.github/workflows/build-electron-app.yml @@ -76,6 +76,16 @@ jobs: max_attempts: 3 retry_on: any command: ./scripts/launch.sh -lwp + - name: Upload Linux Unpacked build + uses: actions/upload-artifact@v3 + with: + name: linux-unpacked + path: dist/linux-unpacked + - name: Upload Win Unpacked build + uses: actions/upload-artifact@v3 + with: + name: win-unpacked + path: dist/win-unpacked - name: Prepare cache folders run: | sudo chown -R $(id -u):$(id -g) ~/.cache/electron @@ -135,3 +145,33 @@ jobs: max_attempts: 3 retry_on: any command: ./scripts/build-release.sh -mp + - name: Upload Mac Unpacked build + uses: actions/upload-artifact@v3 + with: + name: mac-unpacked + path: dist/mac + + linux-e2e-test-runner: + name: Linux E2E Test Runner + timeout-minutes: 30 + runs-on: ubuntu-22.04 + steps: + - name: Checkout + uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: 18.17.1 + - name: Install main dev deps + run: npm i --development --no-audit --progress=false --force + - name: Download Linux Unpacked build + uses: actions/download-artifact@v3 + with: + name: linux-unpacked + path: dist + - name: Run tests + run: npm run e2e + - name: Upload Linux E2E test report + uses: actions/upload-artifact@v3 + with: + name: linux-e2e-test-report + path: e2e-test-report.xml From 8e1c38e366efa5297810b75fb4596db4e6837013 Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Mon, 6 Nov 2023 09:55:49 +0200 Subject: [PATCH 15/66] Launch e2e test runner after builder job --- .github/workflows/build-electron-app.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-electron-app.yml b/.github/workflows/build-electron-app.yml index 2b370607..5a00128d 100644 --- a/.github/workflows/build-electron-app.yml +++ b/.github/workflows/build-electron-app.yml @@ -155,6 +155,7 @@ jobs: name: Linux E2E Test Runner timeout-minutes: 30 runs-on: ubuntu-22.04 + needs: [linux-win-docker-builder] steps: - name: Checkout uses: actions/checkout@v3 @@ -170,8 +171,8 @@ jobs: path: dist - name: Run tests run: npm run e2e - - name: Upload Linux E2E test report + - name: Upload Linux E2E test results uses: actions/upload-artifact@v3 with: - name: linux-e2e-test-report + name: linux-e2e-test-results path: e2e-test-report.xml From 1daca16f3b6605cc4262fdd26ed465b084f26c17 Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Mon, 6 Nov 2023 09:57:05 +0200 Subject: [PATCH 16/66] Add e2e test report workflow --- .github/workflows/e2e-test-report.yml | 31 +++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 .github/workflows/e2e-test-report.yml diff --git a/.github/workflows/e2e-test-report.yml b/.github/workflows/e2e-test-report.yml new file mode 100644 index 00000000..17c06864 --- /dev/null +++ b/.github/workflows/e2e-test-report.yml @@ -0,0 +1,31 @@ +name: 'E2E Test Report' +run-name: 'E2E Test Report: Commit ${{ github.sha }}' + +on: + workflow_run: + workflows: ['Build release'] + types: + - completed + +permissions: + contents: read + actions: read + checks: write + +jobs: + e2e-web-page-report: + name: E2E Web Page Report + runs-on: ubuntu-22.04 + steps: + - uses: dorny/test-reporter@v1 + id: linux-e2e-test-results + with: + artifact: linux-e2e-test-results + name: Linux E2E Tests + path: e2e-test-report.xml + reporter: jest-junit + - name: E2E Test Report Summary + run: | + echo "### E2E Test Report page is ready! :rocket:" >> $GITHUB_STEP_SUMMARY + echo "And available at the following links for applicable OSs:" >> $GITHUB_STEP_SUMMARY + echo "- [Linux](${{ steps.linux-e2e-test-results.outputs.url_html }})" >> $GITHUB_STEP_SUMMARY From b1b5b9640b04c79a65652bb6207ddd897ee99175 Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Mon, 6 Nov 2023 12:58:25 +0200 Subject: [PATCH 17/66] Fix issue with low uploading speed on gh actions --- .github/workflows/build-electron-app.yml | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-electron-app.yml b/.github/workflows/build-electron-app.yml index 5a00128d..bc68d5fe 100644 --- a/.github/workflows/build-electron-app.yml +++ b/.github/workflows/build-electron-app.yml @@ -76,16 +76,20 @@ jobs: max_attempts: 3 retry_on: any command: ./scripts/launch.sh -lwp + - name: Zip Linux Unpacked build + run: zip -r dist/linux-unpacked.zip dist/linux-unpacked - name: Upload Linux Unpacked build uses: actions/upload-artifact@v3 with: name: linux-unpacked - path: dist/linux-unpacked + path: dist/linux-unpacked.zip + - name: Zip Win Unpacked build + run: zip -r dist/win-unpacked.zip dist/win-unpacked - name: Upload Win Unpacked build uses: actions/upload-artifact@v3 with: name: win-unpacked - path: dist/win-unpacked + path: dist/win-unpacked.zip - name: Prepare cache folders run: | sudo chown -R $(id -u):$(id -g) ~/.cache/electron @@ -145,11 +149,13 @@ jobs: max_attempts: 3 retry_on: any command: ./scripts/build-release.sh -mp + - name: Zip Mac Unpacked build + run: zip -r dist/mac.zip dist/mac - name: Upload Mac Unpacked build uses: actions/upload-artifact@v3 with: name: mac-unpacked - path: dist/mac + path: dist/mac.zip linux-e2e-test-runner: name: Linux E2E Test Runner @@ -169,6 +175,8 @@ jobs: with: name: linux-unpacked path: dist + - name: Unzip Linux Unpacked build + run: unzip dist/linux-unpacked.zip - name: Run tests run: npm run e2e - name: Upload Linux E2E test results From f6533356e0492b9c2091c47b1b2e451c1a24b93d Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Mon, 6 Nov 2023 13:47:06 +0200 Subject: [PATCH 18/66] Fix deps installation for e2e tests --- package.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index f8bd95c1..e8bf6c94 100644 --- a/package.json +++ b/package.json @@ -35,17 +35,17 @@ }, "devDependencies": { "@mapbox/node-pre-gyp": "1.0.6", - "@wdio/cli": "8.20.5", + "@wdio/cli": "8.21.0", "@wdio/junit-reporter": "8.21.0", - "@wdio/local-runner": "8.20.5", - "@wdio/mocha-framework": "8.20.3", - "@wdio/spec-reporter": "8.20.0", + "@wdio/local-runner": "8.21.0", + "@wdio/mocha-framework": "8.21.0", + "@wdio/spec-reporter": "8.21.0", "app-builder-bin": "4.1.0", "electron": "27.0.2", "electron-builder": "23.6.0", "mocha": "10.2.0", "standard": "16.0.4", - "wdio-electron-service": "5.3.0" + "wdio-electron-service": "5.4.0" }, "standard": { "globals": [ From 45acf890b2ef16b14f9c3d49a55c7eee3899a0d7 Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Tue, 7 Nov 2023 09:33:00 +0200 Subject: [PATCH 19/66] Skip redundant files in build --- electron-builder-config.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/electron-builder-config.js b/electron-builder-config.js index 255b85fd..92e4def2 100644 --- a/electron-builder-config.js +++ b/electron-builder-config.js @@ -106,6 +106,10 @@ module.exports = { 'build/icon.*', 'build/loader.*', '!scripts${/*}', + '!test/${/*}', + '!electronEnv.json.example', + '!e2e-test-report.xml', + '!wdio.conf.js', '!bfx-report-ui', 'bfx-report-ui/build', @@ -132,6 +136,8 @@ module.exports = { '!**/LICENSE.md', '!**/.gitmodules', '!**/.npmrc', + '!**/.mocharc.json', + '!**/.github/${/*}', { from: 'bfx-reports-framework/node_modules', to: 'bfx-reports-framework/node_modules', From db0fdb451127ab5f3330ad1b9a7b54cb59d79410 Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Tue, 7 Nov 2023 09:35:00 +0200 Subject: [PATCH 20/66] Run e2e tests headlessly by enabling xvfb --- .github/workflows/build-electron-app.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-electron-app.yml b/.github/workflows/build-electron-app.yml index bc68d5fe..b49a444b 100644 --- a/.github/workflows/build-electron-app.yml +++ b/.github/workflows/build-electron-app.yml @@ -178,7 +178,9 @@ jobs: - name: Unzip Linux Unpacked build run: unzip dist/linux-unpacked.zip - name: Run tests - run: npm run e2e + uses: coactions/setup-xvfb@v1.0.1 + with: + run: npm run e2e - name: Upload Linux E2E test results uses: actions/upload-artifact@v3 with: From 907e8cc7a6ee871b7a49500be2b628a3a9dd15e6 Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Tue, 7 Nov 2023 09:35:50 +0200 Subject: [PATCH 21/66] Bump electron up to 27.0.3 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index e8bf6c94..2c23212a 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ "@wdio/mocha-framework": "8.21.0", "@wdio/spec-reporter": "8.21.0", "app-builder-bin": "4.1.0", - "electron": "27.0.2", + "electron": "27.0.3", "electron-builder": "23.6.0", "mocha": "10.2.0", "standard": "16.0.4", From b6d324930529e8378eb7b0950786c5debf1d41ca Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Tue, 7 Nov 2023 14:48:43 +0200 Subject: [PATCH 22/66] Add script for adding time attr to testsuites tag --- scripts/node/normalize-e2e-test-report.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 scripts/node/normalize-e2e-test-report.js diff --git a/scripts/node/normalize-e2e-test-report.js b/scripts/node/normalize-e2e-test-report.js new file mode 100644 index 00000000..4de742b1 --- /dev/null +++ b/scripts/node/normalize-e2e-test-report.js @@ -0,0 +1,20 @@ +'use strict' + +const path = require('path') +const { + readFileSync, + writeFileSync +} = require('fs') + +const cwd = process.cwd() +const fileName = process.argv[2] +const filePath = path.join(cwd, fileName) + +const content = readFileSync(filePath, { encoding: 'utf8' }) +/* + * For compatibility with the dorny/test-reporter, + * there needs to be 'time' attribute to '' tag + */ +const normalizedContent = content + .replace(//gi, '') +writeFileSync(filePath, normalizedContent) From 7e7dfacf8f0c3c5fc646e9725b222ead1c3f37dd Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Tue, 7 Nov 2023 14:50:01 +0200 Subject: [PATCH 23/66] Normalize e2e test report before uploading --- .github/workflows/build-electron-app.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/build-electron-app.yml b/.github/workflows/build-electron-app.yml index b49a444b..f6a60672 100644 --- a/.github/workflows/build-electron-app.yml +++ b/.github/workflows/build-electron-app.yml @@ -181,6 +181,8 @@ jobs: uses: coactions/setup-xvfb@v1.0.1 with: run: npm run e2e + - name: Normalize E2E test report + run: node ./scripts/node/normalize-e2e-test-report e2e-test-report.xml - name: Upload Linux E2E test results uses: actions/upload-artifact@v3 with: From 90f8f7cdc5dc1285cf0be35f83ee991c6fb90618 Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Wed, 8 Nov 2023 12:26:02 +0200 Subject: [PATCH 24/66] Add mac e2e test runner --- .github/workflows/build-electron-app.yml | 34 +++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-electron-app.yml b/.github/workflows/build-electron-app.yml index f6a60672..663232e3 100644 --- a/.github/workflows/build-electron-app.yml +++ b/.github/workflows/build-electron-app.yml @@ -97,7 +97,7 @@ jobs: mac-builder: timeout-minutes: 90 - runs-on: macos-11 + runs-on: macos-12 steps: - name: Checkout uses: actions/checkout@v3 @@ -188,3 +188,35 @@ jobs: with: name: linux-e2e-test-results path: e2e-test-report.xml + + mac-e2e-test-runner: + name: Mac E2E Test Runner + timeout-minutes: 30 + runs-on: macos-12 + needs: [mac-builder] + steps: + - name: Checkout + uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: 18.17.1 + - name: Install main dev deps + run: npm i --development --no-audit --progress=false --force + - name: Download Mac Unpacked build + uses: actions/download-artifact@v3 + with: + name: mac-unpacked + path: dist + - name: Unzip Mac Unpacked build + run: unzip dist/mac.zip + - name: Run tests + uses: coactions/setup-xvfb@v1.0.1 + with: + run: npm run e2e + - name: Normalize E2E test report + run: node ./scripts/node/normalize-e2e-test-report e2e-test-report.xml + - name: Upload Mac E2E test results + uses: actions/upload-artifact@v3 + with: + name: mac-e2e-test-results + path: e2e-test-report.xml From 6f956913f5f3ddcae3a1140077a5fdbc2bfe86bb Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Wed, 8 Nov 2023 12:26:48 +0200 Subject: [PATCH 25/66] Add mac e2e test reporter --- .github/workflows/e2e-test-report.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/e2e-test-report.yml b/.github/workflows/e2e-test-report.yml index 17c06864..32786fcd 100644 --- a/.github/workflows/e2e-test-report.yml +++ b/.github/workflows/e2e-test-report.yml @@ -24,8 +24,16 @@ jobs: name: Linux E2E Tests path: e2e-test-report.xml reporter: jest-junit + - uses: dorny/test-reporter@v1 + id: mac-e2e-test-results + with: + artifact: mac-e2e-test-results + name: Mac E2E Tests + path: e2e-test-report.xml + reporter: jest-junit - name: E2E Test Report Summary run: | echo "### E2E Test Report page is ready! :rocket:" >> $GITHUB_STEP_SUMMARY echo "And available at the following links for applicable OSs:" >> $GITHUB_STEP_SUMMARY echo "- [Linux](${{ steps.linux-e2e-test-results.outputs.url_html }})" >> $GITHUB_STEP_SUMMARY + echo "- [Mac](${{ steps.mac-e2e-test-results.outputs.url_html }})" >> $GITHUB_STEP_SUMMARY From 29b6adf412197a172f4be0eb6ad446816acffcce Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Wed, 8 Nov 2023 12:43:26 +0200 Subject: [PATCH 26/66] Add cross-env for dev/test scripts --- package.json | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 2c23212a..17d9fc45 100644 --- a/package.json +++ b/package.json @@ -41,6 +41,7 @@ "@wdio/mocha-framework": "8.21.0", "@wdio/spec-reporter": "8.21.0", "app-builder-bin": "4.1.0", + "cross-env": "7.0.3", "electron": "27.0.3", "electron-builder": "23.6.0", "mocha": "10.2.0", @@ -56,12 +57,12 @@ ] }, "scripts": { - "start": "export NODE_ENV=development&&export DEBUG=*&&electron .", + "start": "cross-env NODE_ENV=development export DEBUG=*&&electron .", "test": "standard && npm run unit", - "unit": "export NODE_ENV=test && mocha './src/**/__test__/*.spec.js' --config .mocharc.json", + "unit": "cross-env NODE_ENV=test mocha './src/**/__test__/*.spec.js' --config .mocharc.json", "setup": "./scripts/setup.sh", "launch": "./scripts/launch.sh", "sync-repo": "./scripts/sync-repo.sh", - "e2e": "export NODE_ENV=test && wdio run ./wdio.conf.js" + "e2e": "cross-env NODE_ENV=test wdio run ./wdio.conf.js" } } From e8d29a052d9975e3465344aabcbba7171a374862 Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Wed, 8 Nov 2023 12:44:10 +0200 Subject: [PATCH 27/66] Add win e2e test runner --- .github/workflows/build-electron-app.yml | 32 ++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/.github/workflows/build-electron-app.yml b/.github/workflows/build-electron-app.yml index 663232e3..4a2d2425 100644 --- a/.github/workflows/build-electron-app.yml +++ b/.github/workflows/build-electron-app.yml @@ -189,6 +189,38 @@ jobs: name: linux-e2e-test-results path: e2e-test-report.xml + win-e2e-test-runner: + name: Win E2E Test Runner + timeout-minutes: 30 + runs-on: windows-2022 + needs: [linux-win-docker-builder] + steps: + - name: Checkout + uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: 18.17.1 + - name: Install main dev deps + run: npm i --development --no-audit --progress=false --force + - name: Download Linux Unpacked build + uses: actions/download-artifact@v3 + with: + name: win-unpacked + path: dist + - name: Unzip Win Unpacked build + run: 7z e dist/win-unpacked.zip + - name: Run tests + uses: coactions/setup-xvfb@v1.0.1 + with: + run: npm run e2e + - name: Normalize E2E test report + run: node ./scripts/node/normalize-e2e-test-report e2e-test-report.xml + - name: Upload Win E2E test results + uses: actions/upload-artifact@v3 + with: + name: win-e2e-test-results + path: e2e-test-report.xml + mac-e2e-test-runner: name: Mac E2E Test Runner timeout-minutes: 30 From 72203b0ee57f3ac3c4077f883bd2c47d7c34dd95 Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Wed, 8 Nov 2023 12:45:00 +0200 Subject: [PATCH 28/66] Add win e2e test reporter --- .github/workflows/e2e-test-report.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/e2e-test-report.yml b/.github/workflows/e2e-test-report.yml index 32786fcd..f8d8a397 100644 --- a/.github/workflows/e2e-test-report.yml +++ b/.github/workflows/e2e-test-report.yml @@ -24,6 +24,13 @@ jobs: name: Linux E2E Tests path: e2e-test-report.xml reporter: jest-junit + - uses: dorny/test-reporter@v1 + id: win-e2e-test-results + with: + artifact: win-e2e-test-results + name: Win E2E Tests + path: e2e-test-report.xml + reporter: jest-junit - uses: dorny/test-reporter@v1 id: mac-e2e-test-results with: @@ -36,4 +43,5 @@ jobs: echo "### E2E Test Report page is ready! :rocket:" >> $GITHUB_STEP_SUMMARY echo "And available at the following links for applicable OSs:" >> $GITHUB_STEP_SUMMARY echo "- [Linux](${{ steps.linux-e2e-test-results.outputs.url_html }})" >> $GITHUB_STEP_SUMMARY + echo "- [Win](${{ steps.win-e2e-test-results.outputs.url_html }})" >> $GITHUB_STEP_SUMMARY echo "- [Mac](${{ steps.mac-e2e-test-results.outputs.url_html }})" >> $GITHUB_STEP_SUMMARY From d08b967d81c52126872e8391849641d82ed47a61 Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Thu, 9 Nov 2023 09:49:44 +0200 Subject: [PATCH 29/66] Bump actions/checkout up to v4 --- .github/workflows/build-electron-app.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build-electron-app.yml b/.github/workflows/build-electron-app.yml index 4a2d2425..b0c6e33f 100644 --- a/.github/workflows/build-electron-app.yml +++ b/.github/workflows/build-electron-app.yml @@ -30,7 +30,7 @@ jobs: runs-on: ubuntu-22.04 steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: submodules: recursive - name: Set repo owner @@ -100,7 +100,7 @@ jobs: runs-on: macos-12 steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: submodules: recursive - name: Set repo owner @@ -164,7 +164,7 @@ jobs: needs: [linux-win-docker-builder] steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - uses: actions/setup-node@v3 with: node-version: 18.17.1 @@ -196,7 +196,7 @@ jobs: needs: [linux-win-docker-builder] steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - uses: actions/setup-node@v3 with: node-version: 18.17.1 @@ -228,7 +228,7 @@ jobs: needs: [mac-builder] steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - uses: actions/setup-node@v3 with: node-version: 18.17.1 From b6e070c29d870c04114bba8430d147d7650ed737 Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Thu, 9 Nov 2023 09:51:03 +0200 Subject: [PATCH 30/66] Fix unzipping win unpacked build --- .github/workflows/build-electron-app.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-electron-app.yml b/.github/workflows/build-electron-app.yml index b0c6e33f..10cbe394 100644 --- a/.github/workflows/build-electron-app.yml +++ b/.github/workflows/build-electron-app.yml @@ -208,7 +208,7 @@ jobs: name: win-unpacked path: dist - name: Unzip Win Unpacked build - run: 7z e dist/win-unpacked.zip + run: 7z -y x dist/win-unpacked.zip - name: Run tests uses: coactions/setup-xvfb@v1.0.1 with: From 6d48bbb8d93157f5f4649aede6cd556ef62e43a5 Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Thu, 9 Nov 2023 11:02:38 +0200 Subject: [PATCH 31/66] Bump electron-builder up to 24.8.1 to have executable name fix --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 17d9fc45..5514c26f 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,7 @@ "app-builder-bin": "4.1.0", "cross-env": "7.0.3", "electron": "27.0.3", - "electron-builder": "23.6.0", + "electron-builder": "24.8.1", "mocha": "10.2.0", "standard": "16.0.4", "wdio-electron-service": "5.4.0" From 181f1afb64aef4d039fa744b520fc1b5a6bac413 Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Thu, 9 Nov 2023 11:04:40 +0200 Subject: [PATCH 32/66] Add common executableName opt for all builds --- electron-builder-config.js | 1 + 1 file changed, 1 insertion(+) diff --git a/electron-builder-config.js b/electron-builder-config.js index 92e4def2..6a03eadd 100644 --- a/electron-builder-config.js +++ b/electron-builder-config.js @@ -59,6 +59,7 @@ module.exports = { extends: null, asar: false, productName: 'Bitfinex Report', + executableName: 'bfx-report-electron', artifactName: 'BitfinexReport-${version}-x64-${os}.${ext}', appId: 'com.bitfinex.report', publish: { From e28fb6b4025f5c0297ecd53b2f50b3e94c9196e7 Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Thu, 9 Nov 2023 11:05:50 +0200 Subject: [PATCH 33/66] Fix making mac app-update-yml in build --- scripts/node/make-mac-app-update-yml.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/node/make-mac-app-update-yml.js b/scripts/node/make-mac-app-update-yml.js index 955a3a7d..b6a10fde 100644 --- a/scripts/node/make-mac-app-update-yml.js +++ b/scripts/node/make-mac-app-update-yml.js @@ -19,7 +19,7 @@ if ( const ymlName = 'app-update.yml' const ymlPath = path.join( cwd, - 'dist/mac/Bitfinex Report.app/Contents/Resources', + 'dist/mac/bfx-report-electron.app/Contents/Resources', ymlName ) From f935b67d840be9d9da0f5a0d82621fa5ec3c4730 Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Thu, 9 Nov 2023 11:07:14 +0200 Subject: [PATCH 34/66] Fix mac updater for new executable name --- src/auto-updater/bfx.mac.updater.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/auto-updater/bfx.mac.updater.js b/src/auto-updater/bfx.mac.updater.js index 0709539f..3479b8d9 100644 --- a/src/auto-updater/bfx.mac.updater.js +++ b/src/auto-updater/bfx.mac.updater.js @@ -53,7 +53,7 @@ class BfxMacUpdater extends MacUpdater { const root = path.join(appDir, '../../..') const dist = path.join(root, '..') - const exec = path.join(root, 'Contents/MacOS/Bitfinex Report') + const exec = path.join(root, 'Contents/MacOS/bfx-report-electron') await fsPromises.rm(root, { recursive: true }) From a8cfff1388259b16fef55034c50348a753b7a3a2 Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Thu, 9 Nov 2023 11:08:59 +0200 Subject: [PATCH 35/66] Add correct app binary path to wdio conf according to os --- wdio.conf.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/wdio.conf.js b/wdio.conf.js index b12f3388..4d564f77 100644 --- a/wdio.conf.js +++ b/wdio.conf.js @@ -1,5 +1,17 @@ process.env.TEST = 'true' +const getAppBinaryPath = () => { + if (process.platform === 'win32') { + return './dist/win-unpacked/bfx-report-electron.exe' + } + if (process.platform === 'darwin') { + return './dist/mac/bfx-report-electron.app/Contents/MacOS/bfx-report-electron' + } + if (process.platform === 'linux') { + return './dist/linux-unpacked/bfx-report-electron' + } +} + exports.config = { // // ==================== @@ -57,6 +69,8 @@ exports.config = { // Electron service options // see https://webdriver.io/docs/wdio-electron-service/#configuration 'wdio:electronServiceOptions': { + appBinaryPath: getAppBinaryPath(), + // custom application args appArgs: [] } From 4d03af905504de5d19c0af2d8268f013119659a0 Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Fri, 10 Nov 2023 08:48:24 +0200 Subject: [PATCH 36/66] Add bash script to turn uninterrupted e2e testing on macOS --- scripts/mac/prepare-macos-runner.sh | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 scripts/mac/prepare-macos-runner.sh diff --git a/scripts/mac/prepare-macos-runner.sh b/scripts/mac/prepare-macos-runner.sh new file mode 100644 index 00000000..7497b44e --- /dev/null +++ b/scripts/mac/prepare-macos-runner.sh @@ -0,0 +1,23 @@ +#!/usr/bin/env bash + +# Turn uninterrupted testing on macOS + +# Change Local name to avoid name clash causing alert +uniqueComputerName="${GITHUB_WORKFLOW:-"mac-e2e-test-runner"}-$RANDOM" +sudo scutil --set LocalHostName "$uniqueComputerName" +sudo scutil --set ComputerName "$uniqueComputerName" + +# Close Notification window +sudo killall UserNotificationCenter || true + +# Do not disturb +defaults -currentHost write com.apple.notificationcenterui doNotDisturb -boolean true +defaults -currentHost write com.apple.notificationcenterui doNotDisturbDate -date "`date -u +\"%Y-%m-%d %H:%M:%S +0000\"`" +sudo killall NotificationCenter + +# Disable firewall +sudo /usr/libexec/ApplicationFirewall/socketfilterfw --setglobalstate off +sudo /usr/libexec/ApplicationFirewall/socketfilterfw -k + +# Close Finder Windows using Apple Script +sudo osascript -e 'tell application "Finder" to close windows' From d9b706089ca88b1e39ca00e185e7fddf7b266c6a Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Fri, 10 Nov 2023 08:49:41 +0200 Subject: [PATCH 37/66] Add gh workflow step to prepare mac e2e test runner --- .github/workflows/build-electron-app.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/build-electron-app.yml b/.github/workflows/build-electron-app.yml index 10cbe394..9c2876fd 100644 --- a/.github/workflows/build-electron-app.yml +++ b/.github/workflows/build-electron-app.yml @@ -229,6 +229,8 @@ jobs: steps: - name: Checkout uses: actions/checkout@v4 + - name: Prepare macOS runner + run: ./scripts/mac/prepare-macos-runner.sh - uses: actions/setup-node@v3 with: node-version: 18.17.1 From 0b31eff8ab4d0867a99f3e1c50fae13cb5bddd26 Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Fri, 10 Nov 2023 09:58:32 +0200 Subject: [PATCH 38/66] Move prepare-mac-runner script to local gh actions --- .github/actions/prepare-mac-runner/action.yml | 7 +++++++ .../actions/prepare-mac-runner/prepare-mac-runner.sh | 2 +- .github/workflows/build-electron-app.yml | 4 ++-- 3 files changed, 10 insertions(+), 3 deletions(-) create mode 100644 .github/actions/prepare-mac-runner/action.yml rename scripts/mac/prepare-macos-runner.sh => .github/actions/prepare-mac-runner/prepare-mac-runner.sh (95%) mode change 100644 => 100755 diff --git a/.github/actions/prepare-mac-runner/action.yml b/.github/actions/prepare-mac-runner/action.yml new file mode 100644 index 00000000..f5a52f0f --- /dev/null +++ b/.github/actions/prepare-mac-runner/action.yml @@ -0,0 +1,7 @@ +name: 'Prepare Mac runner' +description: 'Turn uninterrupted testing on mac' +runs: + using: composite + steps: + - run: ${{ github.action_path }}/prepare-mac-runner.sh + shell: bash diff --git a/scripts/mac/prepare-macos-runner.sh b/.github/actions/prepare-mac-runner/prepare-mac-runner.sh old mode 100644 new mode 100755 similarity index 95% rename from scripts/mac/prepare-macos-runner.sh rename to .github/actions/prepare-mac-runner/prepare-mac-runner.sh index 7497b44e..a392a975 --- a/scripts/mac/prepare-macos-runner.sh +++ b/.github/actions/prepare-mac-runner/prepare-mac-runner.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -# Turn uninterrupted testing on macOS +# Turn uninterrupted testing on mac # Change Local name to avoid name clash causing alert uniqueComputerName="${GITHUB_WORKFLOW:-"mac-e2e-test-runner"}-$RANDOM" diff --git a/.github/workflows/build-electron-app.yml b/.github/workflows/build-electron-app.yml index 9c2876fd..0f07009b 100644 --- a/.github/workflows/build-electron-app.yml +++ b/.github/workflows/build-electron-app.yml @@ -229,8 +229,8 @@ jobs: steps: - name: Checkout uses: actions/checkout@v4 - - name: Prepare macOS runner - run: ./scripts/mac/prepare-macos-runner.sh + - name: Prepare Mac runner + uses: ./.github/actions/prepare-mac-runner - uses: actions/setup-node@v3 with: node-version: 18.17.1 From cb352435b65b5a3f20592a8249bb8e829cc1523f Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Fri, 10 Nov 2023 10:23:01 +0200 Subject: [PATCH 39/66] Use macos-11 in gh actions --- .github/workflows/build-electron-app.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-electron-app.yml b/.github/workflows/build-electron-app.yml index 0f07009b..53f9cbe9 100644 --- a/.github/workflows/build-electron-app.yml +++ b/.github/workflows/build-electron-app.yml @@ -97,7 +97,7 @@ jobs: mac-builder: timeout-minutes: 90 - runs-on: macos-12 + runs-on: macos-11 steps: - name: Checkout uses: actions/checkout@v4 @@ -224,7 +224,7 @@ jobs: mac-e2e-test-runner: name: Mac E2E Test Runner timeout-minutes: 30 - runs-on: macos-12 + runs-on: macos-11 needs: [mac-builder] steps: - name: Checkout From aaf9e2695b76ee80324744d217052321232a5cb2 Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Fri, 10 Nov 2023 10:54:48 +0200 Subject: [PATCH 40/66] Prevent spaces in mac unique computer name --- .github/actions/prepare-mac-runner/prepare-mac-runner.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/prepare-mac-runner/prepare-mac-runner.sh b/.github/actions/prepare-mac-runner/prepare-mac-runner.sh index a392a975..37a25e0c 100755 --- a/.github/actions/prepare-mac-runner/prepare-mac-runner.sh +++ b/.github/actions/prepare-mac-runner/prepare-mac-runner.sh @@ -3,7 +3,7 @@ # Turn uninterrupted testing on mac # Change Local name to avoid name clash causing alert -uniqueComputerName="${GITHUB_WORKFLOW:-"mac-e2e-test-runner"}-$RANDOM" +uniqueComputerName="mac-e2e-test-runner-$RANDOM" sudo scutil --set LocalHostName "$uniqueComputerName" sudo scutil --set ComputerName "$uniqueComputerName" From 5c7fb5b5950e404b315afa1c388dd1f266dda9b4 Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Fri, 10 Nov 2023 12:58:13 +0200 Subject: [PATCH 41/66] Fix electron issue with executableName specifying https://github.com/electron-userland/electron-builder/issues/6962 https://github.com/electron/electron/issues/34253 --- electron-builder-config.js | 2 +- scripts/node/make-mac-app-update-yml.js | 2 +- src/auto-updater/bfx.mac.updater.js | 2 +- wdio.conf.js | 6 +++--- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/electron-builder-config.js b/electron-builder-config.js index 6a03eadd..3b970ca7 100644 --- a/electron-builder-config.js +++ b/electron-builder-config.js @@ -59,7 +59,6 @@ module.exports = { extends: null, asar: false, productName: 'Bitfinex Report', - executableName: 'bfx-report-electron', artifactName: 'BitfinexReport-${version}-x64-${os}.${ext}', appId: 'com.bitfinex.report', publish: { @@ -74,6 +73,7 @@ module.exports = { updaterCacheDirName: 'bfx-report-electron-updater' }, linux: { + executableName: 'app', description: 'Bitfinex Report', maintainer: '', category: 'Network', diff --git a/scripts/node/make-mac-app-update-yml.js b/scripts/node/make-mac-app-update-yml.js index b6a10fde..955a3a7d 100644 --- a/scripts/node/make-mac-app-update-yml.js +++ b/scripts/node/make-mac-app-update-yml.js @@ -19,7 +19,7 @@ if ( const ymlName = 'app-update.yml' const ymlPath = path.join( cwd, - 'dist/mac/bfx-report-electron.app/Contents/Resources', + 'dist/mac/Bitfinex Report.app/Contents/Resources', ymlName ) diff --git a/src/auto-updater/bfx.mac.updater.js b/src/auto-updater/bfx.mac.updater.js index 3479b8d9..0709539f 100644 --- a/src/auto-updater/bfx.mac.updater.js +++ b/src/auto-updater/bfx.mac.updater.js @@ -53,7 +53,7 @@ class BfxMacUpdater extends MacUpdater { const root = path.join(appDir, '../../..') const dist = path.join(root, '..') - const exec = path.join(root, 'Contents/MacOS/bfx-report-electron') + const exec = path.join(root, 'Contents/MacOS/Bitfinex Report') await fsPromises.rm(root, { recursive: true }) diff --git a/wdio.conf.js b/wdio.conf.js index 4d564f77..77d8a794 100644 --- a/wdio.conf.js +++ b/wdio.conf.js @@ -2,13 +2,13 @@ process.env.TEST = 'true' const getAppBinaryPath = () => { if (process.platform === 'win32') { - return './dist/win-unpacked/bfx-report-electron.exe' + return './dist/win-unpacked/Bitfinex Report.exe' } if (process.platform === 'darwin') { - return './dist/mac/bfx-report-electron.app/Contents/MacOS/bfx-report-electron' + return './dist/mac/Bitfinex Report.app/Contents/MacOS/Bitfinex Report' } if (process.platform === 'linux') { - return './dist/linux-unpacked/bfx-report-electron' + return './dist/linux-unpacked/app' } } From 9c12e64f297008e727739933568b7fea41d9ad40 Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Fri, 10 Nov 2023 13:01:59 +0200 Subject: [PATCH 42/66] Bump wdio up to 8.22.0 --- package.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 5514c26f..1f78f946 100644 --- a/package.json +++ b/package.json @@ -35,10 +35,10 @@ }, "devDependencies": { "@mapbox/node-pre-gyp": "1.0.6", - "@wdio/cli": "8.21.0", + "@wdio/cli": "8.22.1", "@wdio/junit-reporter": "8.21.0", - "@wdio/local-runner": "8.21.0", - "@wdio/mocha-framework": "8.21.0", + "@wdio/local-runner": "8.22.1", + "@wdio/mocha-framework": "8.22.0", "@wdio/spec-reporter": "8.21.0", "app-builder-bin": "4.1.0", "cross-env": "7.0.3", From 08b9a05748eb597b51ef7cb835d631735e7340be Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Fri, 10 Nov 2023 13:02:36 +0200 Subject: [PATCH 43/66] Bump electon up to 27.0.4 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 1f78f946..5d08302f 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "@wdio/spec-reporter": "8.21.0", "app-builder-bin": "4.1.0", "cross-env": "7.0.3", - "electron": "27.0.3", + "electron": "27.0.4", "electron-builder": "24.8.1", "mocha": "10.2.0", "standard": "16.0.4", From 2ffbd3e4ed4a5c46cdc703d6df28dda48c5c4efe Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Fri, 10 Nov 2023 13:04:20 +0200 Subject: [PATCH 44/66] Disable enforce macos app location for e2e test runner --- src/enforce-macos-app-location.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/enforce-macos-app-location.js b/src/enforce-macos-app-location.js index d2e1c5a7..ae16b33f 100644 --- a/src/enforce-macos-app-location.js +++ b/src/enforce-macos-app-location.js @@ -10,6 +10,7 @@ const { module.exports = async () => { if ( + process.env.NODE_ENV === 'test' || process.env.NODE_ENV === 'development' || process.platform !== 'darwin' ) { From 6ce902efad5a15830a46329e41d80894e4d01f42 Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Fri, 10 Nov 2023 13:06:22 +0200 Subject: [PATCH 45/66] Use macos-12 in gh actions --- .github/workflows/build-electron-app.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-electron-app.yml b/.github/workflows/build-electron-app.yml index 53f9cbe9..0f07009b 100644 --- a/.github/workflows/build-electron-app.yml +++ b/.github/workflows/build-electron-app.yml @@ -97,7 +97,7 @@ jobs: mac-builder: timeout-minutes: 90 - runs-on: macos-11 + runs-on: macos-12 steps: - name: Checkout uses: actions/checkout@v4 @@ -224,7 +224,7 @@ jobs: mac-e2e-test-runner: name: Mac E2E Test Runner timeout-minutes: 30 - runs-on: macos-11 + runs-on: macos-12 needs: [mac-builder] steps: - name: Checkout From 3285cff357cc42d3d921967d870e9e2144852929 Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Fri, 10 Nov 2023 16:15:11 +0200 Subject: [PATCH 46/66] Fix npm start script --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 5d08302f..f4d9bf9f 100644 --- a/package.json +++ b/package.json @@ -57,7 +57,7 @@ ] }, "scripts": { - "start": "cross-env NODE_ENV=development export DEBUG=*&&electron .", + "start": "cross-env NODE_ENV=development DEBUG=* electron .", "test": "standard && npm run unit", "unit": "cross-env NODE_ENV=test mocha './src/**/__test__/*.spec.js' --config .mocharc.json", "setup": "./scripts/setup.sh", From 2af7deb99307b327a87b80c25ca0f35783b56d78 Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Fri, 10 Nov 2023 16:16:10 +0200 Subject: [PATCH 47/66] Fix browser window creation --- src/window-creators.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/window-creators.js b/src/window-creators.js index 79f9a016..82779b60 100644 --- a/src/window-creators.js +++ b/src/window-creators.js @@ -6,7 +6,6 @@ const { URL } = require('url') const { BrowserWindow } = electron const isDevEnv = process.env.NODE_ENV === 'development' -const isTestEnv = process.env.NODE_ENV === 'test' const isMac = process.platform === 'darwin' const wins = require('./windows') @@ -97,7 +96,6 @@ const _createWindow = async ( ...props, webPreferences: { - sandbox: !isTestEnv, preload: path.join(__dirname, 'preload.js'), ...props?.webPreferences } From 16e763a57cd045a3202cb4b8599aeb164ea1ea3f Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Wed, 3 Jan 2024 12:04:00 +0200 Subject: [PATCH 48/66] Bump app-builder-bin up to 4.2.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index f4d9bf9f..9eab1a83 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,7 @@ "@wdio/local-runner": "8.22.1", "@wdio/mocha-framework": "8.22.0", "@wdio/spec-reporter": "8.21.0", - "app-builder-bin": "4.1.0", + "app-builder-bin": "4.2.0", "cross-env": "7.0.3", "electron": "27.0.4", "electron-builder": "24.8.1", From c5314196ee2fc2d28ea320f6be262217625b6508 Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Wed, 3 Jan 2024 12:33:35 +0200 Subject: [PATCH 49/66] Fix execute permission for app-builder-bin It's required as binary does not have an execute permission by default https://github.com/develar/app-builder/issues/97 --- scripts/node/generate-mac-zipand-blockmap.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/scripts/node/generate-mac-zipand-blockmap.js b/scripts/node/generate-mac-zipand-blockmap.js index 644d0093..6af9fd6c 100644 --- a/scripts/node/generate-mac-zipand-blockmap.js +++ b/scripts/node/generate-mac-zipand-blockmap.js @@ -3,6 +3,7 @@ 'use strict' const path = require('path') +const { chmodSync } = require('fs') const { execSync } = require('child_process') @@ -34,6 +35,10 @@ const APP_GENERATED_BINARY_PATH = path.join( const ymlPath = path.join(APP_DIST_PATH, `${channel}-mac.yml`) try { + // It's required as binary does not have an execute permission by default + // https://github.com/develar/app-builder/issues/97 + chmodSync(appBuilderPath, '755') + const output = execSync(`${appBuilderPath} blockmap --input=${APP_GENERATED_BINARY_PATH} --output=${APP_GENERATED_BINARY_PATH}.blockmap --compression=gzip`) const { sha512, size } = JSON.parse(output) const ymlData = { From a78cd9d067022c1cbe55827fd63901fa6a442de9 Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Wed, 3 Jan 2024 12:37:11 +0200 Subject: [PATCH 50/66] Bump standard up to 17.1.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 9eab1a83..4e30219e 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ "electron": "27.0.4", "electron-builder": "24.8.1", "mocha": "10.2.0", - "standard": "16.0.4", + "standard": "17.1.0", "wdio-electron-service": "5.4.0" }, "standard": { From 0a82d906bb742707fb189d4c0cbfcf3380b16da7 Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Wed, 3 Jan 2024 12:38:36 +0200 Subject: [PATCH 51/66] Fix code style considering standardjs 17 --- src/auto-updater/index.js | 2 +- src/manage-worker-messages.js | 2 -- src/window-creators.js | 6 +++--- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/auto-updater/index.js b/src/auto-updater/index.js index ec3473a9..92fd97f5 100644 --- a/src/auto-updater/index.js +++ b/src/auto-updater/index.js @@ -180,7 +180,7 @@ const _fireToast = ( const boundsOpts = { x: (x + width) - alWidth, - y: y, + y, height } diff --git a/src/manage-worker-messages.js b/src/manage-worker-messages.js index 82bf707a..9395e38e 100644 --- a/src/manage-worker-messages.js +++ b/src/manage-worker-messages.js @@ -235,8 +235,6 @@ module.exports = (ipc) => { } ipc.send({ state: PROCESS_STATES.REMOVE_ALL_TABLES }) - - return } } catch (err) { console.error(err) diff --git a/src/window-creators.js b/src/window-creators.js index 82779b60..104230f4 100644 --- a/src/window-creators.js +++ b/src/window-creators.js @@ -74,9 +74,9 @@ const _createWindow = async ( manage } = isMainWindow ? windowStateKeeper({ - defaultWidth, - defaultHeight - }) + defaultWidth, + defaultHeight + }) : {} const _props = { autoHideMenuBar: true, From 5afb233df5303af0090d682a5ee6f0550806018a Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Wed, 3 Jan 2024 12:40:18 +0200 Subject: [PATCH 52/66] Bump electron up to 27.2.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 4e30219e..045f582b 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "@wdio/spec-reporter": "8.21.0", "app-builder-bin": "4.2.0", "cross-env": "7.0.3", - "electron": "27.0.4", + "electron": "27.2.0", "electron-builder": "24.8.1", "mocha": "10.2.0", "standard": "17.1.0", From 5b9abfd73a2cdb3f000bc0144615c4891df8d677 Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Wed, 3 Jan 2024 12:41:13 +0200 Subject: [PATCH 53/66] Bump electron-builder up to 24.10.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 045f582b..77717903 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,7 @@ "app-builder-bin": "4.2.0", "cross-env": "7.0.3", "electron": "27.2.0", - "electron-builder": "24.8.1", + "electron-builder": "24.10.0", "mocha": "10.2.0", "standard": "17.1.0", "wdio-electron-service": "5.4.0" From e0d042a7da788e4b425e7ddf4f959e387c587e08 Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Wed, 3 Jan 2024 12:41:57 +0200 Subject: [PATCH 54/66] Bump @mapbox/node-pre-gyp up to 1.0.11 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 77717903..46d44ee8 100644 --- a/package.json +++ b/package.json @@ -34,7 +34,7 @@ "yauzl": "2.10.0" }, "devDependencies": { - "@mapbox/node-pre-gyp": "1.0.6", + "@mapbox/node-pre-gyp": "1.0.11", "@wdio/cli": "8.22.1", "@wdio/junit-reporter": "8.21.0", "@wdio/local-runner": "8.22.1", From ec8a4df6e2855a1715ebfc34dffb1db71aa88ee9 Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Wed, 3 Jan 2024 12:48:17 +0200 Subject: [PATCH 55/66] Bump get-port up to 7.0.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 46d44ee8..1fb576ba 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,7 @@ "electron-root-path": "1.0.16", "electron-updater": "5.3.0", "extract-zip": "2.0.1", - "get-port": "6.1.2", + "get-port": "7.0.0", "github-markdown-css": "5.1.0", "grenache-grape": "git+https://github.com/bitfinexcom/grenache-grape.git", "js-yaml": "4.1.0", From 9e0c2f85179805e30fde327add9c8d94005f6e69 Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Wed, 3 Jan 2024 12:48:54 +0200 Subject: [PATCH 56/66] Bump changelog-parser up to 3.0.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 1fb576ba..0c594f1b 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,7 @@ "archiver": "5.3.0", "bfx-svc-test-helper": "git+https://github.com/bitfinexcom/bfx-svc-test-helper.git", "bittorrent-dht": "10.0.2", - "changelog-parser": "2.8.0", + "changelog-parser": "3.0.1", "clean-stack": "3.0.1", "compare-versions": "4.1.1", "cron-validate": "1.4.3", From 5fce0f53e87f6fde9c971cff31c2cdf5c17351ae Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Fri, 5 Jan 2024 14:35:56 +0200 Subject: [PATCH 57/66] Fix skipping publishing of artifact for mac by electron-builder --- electron-builder-config.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/electron-builder-config.js b/electron-builder-config.js index 3b970ca7..64d7ae71 100644 --- a/electron-builder-config.js +++ b/electron-builder-config.js @@ -9,6 +9,7 @@ const exec = promisify(require('child_process').exec) let version let zippedAppImageArtifactPath +let zippedMacArtifactPath const appOutDirs = new Map() /* eslint-disable no-template-curly-in-string */ @@ -205,24 +206,25 @@ module.exports = { !targets.has('zip') ) { targets.set('zip', {}) - artifactPaths.push(path.join( - outDir, - `BitfinexReport-${version}-x64-${targetPlatform}.zip` - )) } for (const [targetName] of targets) { const ext = targetName === 'nsis' ? 'exe' : targetName - const appFilePath = artifactPaths.find((path) => ( + const foundAppFilePath = artifactPaths.find((path) => ( new RegExp(`${targetPlatform}.*${ext}$`, 'i').test(path) )) + const appFilePath = foundAppFilePath ?? path.join( + outDir, + `BitfinexReport-${version}-x64-${targetPlatform}.${ext}` + ) if ( targetPlatform === 'mac' && targetName === 'zip' ) { + zippedMacArtifactPath = appFilePath macBlockmapFilePaths.push( `${appFilePath}.blockmap`, path.join(outDir, `${channel}-mac.yml`) @@ -299,7 +301,7 @@ module.exports = { } const macFiles = macBlockmapFilePaths.length > 0 - ? [...artifactPaths, ...macBlockmapFilePaths] + ? [zippedMacArtifactPath, ...macBlockmapFilePaths] : [] const linuxFiles = zippedAppImageArtifactPath ? [zippedAppImageArtifactPath] From c0efffc3dc5ae190095927926f213c05cab6695a Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Tue, 14 Nov 2023 11:08:44 +0200 Subject: [PATCH 58/66] Provide apple credential env vars to mac-builder workflow --- .github/workflows/build-electron-app.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/build-electron-app.yml b/.github/workflows/build-electron-app.yml index 0f07009b..166ba785 100644 --- a/.github/workflows/build-electron-app.yml +++ b/.github/workflows/build-electron-app.yml @@ -141,6 +141,11 @@ jobs: uses: nick-fields/retry@v2 continue-on-error: false env: + APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }} + APPLE_ID: ${{ secrets.APPLE_ID }} + APPLE_APP_SPECIFIC_PASSWORD: ${{ secrets.APPLE_APP_SPECIFIC_PASSWORD }} + CSC_LINK: ${{ secrets.APPLE_CERTIFICATE }} + CSC_KEY_PASSWORD: ${{ secrets.APPLE_CERTIFICATE_PASSWORD }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} ELECTRON_CACHE: ~/Library/Caches/electron with: From 1daada83c3940bc3c6a0bc7ce787b0669b2a101b Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Tue, 14 Nov 2023 11:09:51 +0200 Subject: [PATCH 59/66] Add apple credential env vars to .env file --- .env.example | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.env.example b/.env.example index ea127aaf..55ba52c3 100644 --- a/.env.example +++ b/.env.example @@ -4,3 +4,9 @@ IS_DEV_ENV=0 IS_AUTO_UPDATE_DISABLED=0 EP_GH_IGNORE_TIME=true GH_TOKEN= + +APPLE_TEAM_ID= +APPLE_ID= +APPLE_APP_SPECIFIC_PASSWORD= +CSC_LINK= +CSC_KEY_PASSWORD= From 609e1a5136934e31385b925d54d04515d4a625dd Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Tue, 14 Nov 2023 11:40:13 +0200 Subject: [PATCH 60/66] Add required apple app sandbox entitlements --- build/entitlements.mac.plist | 10 ++++++++++ build/entitlements.mas.inherit.plist | 8 ++++++++ 2 files changed, 18 insertions(+) diff --git a/build/entitlements.mac.plist b/build/entitlements.mac.plist index 34d93599..5a5f39bc 100644 --- a/build/entitlements.mac.plist +++ b/build/entitlements.mac.plist @@ -4,6 +4,8 @@ com.apple.security.app-sandbox + com.apple.security.inherit + com.apple.security.network.client com.apple.security.network.server @@ -22,5 +24,13 @@ com.apple.security.cs.disable-library-validation + com.apple.security.cs.allow-jit + + com.apple.security.cs.allow-dyld-environment-variables + + com.apple.security.cs.debugger + + com.apple.security.automation.apple-events + diff --git a/build/entitlements.mas.inherit.plist b/build/entitlements.mas.inherit.plist index 4b8d65fa..5a5f39bc 100644 --- a/build/entitlements.mas.inherit.plist +++ b/build/entitlements.mas.inherit.plist @@ -24,5 +24,13 @@ com.apple.security.cs.disable-library-validation + com.apple.security.cs.allow-jit + + com.apple.security.cs.allow-dyld-environment-variables + + com.apple.security.cs.debugger + + com.apple.security.automation.apple-events + From a9ef1320230406f9a6bbd57d36bfc4ab11553a10 Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Tue, 14 Nov 2023 12:25:01 +0200 Subject: [PATCH 61/66] Add mac dmg target release --- electron-builder-config.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/electron-builder-config.js b/electron-builder-config.js index 64d7ae71..9d00f7ef 100644 --- a/electron-builder-config.js +++ b/electron-builder-config.js @@ -92,16 +92,19 @@ module.exports = { verifyUpdateCodeSignature: false }, mac: { - type: 'development', hardenedRuntime: true, gatekeeperAssess: false, entitlements: 'build/entitlements.mac.plist', entitlementsInherit: 'build/entitlements.mas.inherit.plist', category: 'public.app-category.finance', target: [ - 'dir' + 'dir', + 'dmg' ] }, + dmg: { + sign: false + }, files: [ '**/*', 'build/icons', From be0aeb666aca24ef18b62bb2d87d4fb6e329daf8 Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Tue, 14 Nov 2023 12:26:03 +0200 Subject: [PATCH 62/66] Set mac type opt as distribution --- electron-builder-config.js | 1 + 1 file changed, 1 insertion(+) diff --git a/electron-builder-config.js b/electron-builder-config.js index 9d00f7ef..d3dc0b59 100644 --- a/electron-builder-config.js +++ b/electron-builder-config.js @@ -92,6 +92,7 @@ module.exports = { verifyUpdateCodeSignature: false }, mac: { + type: 'distribution', hardenedRuntime: true, gatekeeperAssess: false, entitlements: 'build/entitlements.mac.plist', From 5e0adfc7be3d68350d668932a65b3dde4c395a7e Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Tue, 14 Nov 2023 12:27:04 +0200 Subject: [PATCH 63/66] Enable dark mode support for mac --- electron-builder-config.js | 1 + 1 file changed, 1 insertion(+) diff --git a/electron-builder-config.js b/electron-builder-config.js index d3dc0b59..562d7f02 100644 --- a/electron-builder-config.js +++ b/electron-builder-config.js @@ -98,6 +98,7 @@ module.exports = { entitlements: 'build/entitlements.mac.plist', entitlementsInherit: 'build/entitlements.mas.inherit.plist', category: 'public.app-category.finance', + darkModeSupport: true, target: [ 'dir', 'dmg' From 03c786651e0bb818bdc99b7d5a37e95189571746 Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Tue, 14 Nov 2023 12:28:09 +0200 Subject: [PATCH 64/66] Hardcode 11 minimum system version for mac --- electron-builder-config.js | 1 + 1 file changed, 1 insertion(+) diff --git a/electron-builder-config.js b/electron-builder-config.js index 562d7f02..60526728 100644 --- a/electron-builder-config.js +++ b/electron-builder-config.js @@ -98,6 +98,7 @@ module.exports = { entitlements: 'build/entitlements.mac.plist', entitlementsInherit: 'build/entitlements.mas.inherit.plist', category: 'public.app-category.finance', + minimumSystemVersion: '11', darkModeSupport: true, target: [ 'dir', From b0a63567081e2ccfce39de3405ea8399be391d86 Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Tue, 14 Nov 2023 12:34:10 +0200 Subject: [PATCH 65/66] Add ability to set teamId from env var --- electron-builder-config.js | 4 ++++ package.json | 1 + 2 files changed, 5 insertions(+) diff --git a/electron-builder-config.js b/electron-builder-config.js index 60526728..0fb4b4f0 100644 --- a/electron-builder-config.js +++ b/electron-builder-config.js @@ -1,5 +1,6 @@ 'use strict' +require('dotenv').config() const fs = require('fs') const path = require('path') const zlib = require('zlib') @@ -100,6 +101,9 @@ module.exports = { category: 'public.app-category.finance', minimumSystemVersion: '11', darkModeSupport: true, + notarize: { + teamId: process.env.APPLE_TEAM_ID + }, target: [ 'dir', 'dmg' diff --git a/package.json b/package.json index 0c594f1b..38ea92cc 100644 --- a/package.json +++ b/package.json @@ -42,6 +42,7 @@ "@wdio/spec-reporter": "8.21.0", "app-builder-bin": "4.2.0", "cross-env": "7.0.3", + "dotenv": "16.3.1", "electron": "27.2.0", "electron-builder": "24.10.0", "mocha": "10.2.0", From 994af02cf874e889b101ed9d49ac8b3d91e6a96a Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Tue, 9 Jan 2024 13:00:42 +0200 Subject: [PATCH 66/66] Add ability to turn off notarizing --- .env.example | 1 + .github/workflows/build-electron-app.yml | 18 +++++++++++++----- docker-compose.yaml | 6 ++++++ electron-builder-config.js | 22 ++++++++++++++++++---- 4 files changed, 38 insertions(+), 9 deletions(-) diff --git a/.env.example b/.env.example index 55ba52c3..9f778853 100644 --- a/.env.example +++ b/.env.example @@ -5,6 +5,7 @@ IS_AUTO_UPDATE_DISABLED=0 EP_GH_IGNORE_TIME=true GH_TOKEN= +NOTARIZE=0 APPLE_TEAM_ID= APPLE_ID= APPLE_APP_SPECIFIC_PASSWORD= diff --git a/.github/workflows/build-electron-app.yml b/.github/workflows/build-electron-app.yml index 166ba785..392d1613 100644 --- a/.github/workflows/build-electron-app.yml +++ b/.github/workflows/build-electron-app.yml @@ -19,6 +19,9 @@ on: isBfxApiStaging: description: 'Is it necessary to use BFX API Staging? (true / 1)?' required: false + isNotarizeDisabled: + description: 'Is notarize disabled (true / 1)?' + required: false env: DOCKER_BUILDKIT: 1 @@ -118,6 +121,10 @@ jobs: name: Turn off auto-update run: | echo "IS_AUTO_UPDATE_DISABLED=1" >> $GITHUB_ENV + - if: ${{ !contains(fromJson('["true", "1", true, 1]'), github.event.inputs.isNotarizeDisabled) }} + name: Turn on notarize + run: | + echo "NOTARIZE=1" >> $GITHUB_ENV - if: contains(fromJson('["true", "1", true, 1]'), github.event.inputs.isBfxApiStaging) name: Use BFX API Staging for queries run: | @@ -141,11 +148,12 @@ jobs: uses: nick-fields/retry@v2 continue-on-error: false env: - APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }} - APPLE_ID: ${{ secrets.APPLE_ID }} - APPLE_APP_SPECIFIC_PASSWORD: ${{ secrets.APPLE_APP_SPECIFIC_PASSWORD }} - CSC_LINK: ${{ secrets.APPLE_CERTIFICATE }} - CSC_KEY_PASSWORD: ${{ secrets.APPLE_CERTIFICATE_PASSWORD }} + NOTARIZE: true + APPLE_TEAM_ID: ${{ secrets.BFX_APPLE_TEAM_ID }} + APPLE_ID: ${{ secrets.BFX_APPLE_ID_USERNAME }} + APPLE_APP_SPECIFIC_PASSWORD: ${{ secrets.BFX_APPLE_ID_REPORT_PASSWORD }} + CSC_LINK: ${{ secrets.BFX_APPLE_BUILD_CERTIFICATE_B64 }} + CSC_KEY_PASSWORD: ${{ secrets.BFX_APPLE_BUILD_CERTIFICATE_PASSWORD }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} ELECTRON_CACHE: ~/Library/Caches/electron with: diff --git a/docker-compose.yaml b/docker-compose.yaml index 71f96c1b..c2741927 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -74,6 +74,12 @@ services: IS_DEV_ENV: ${IS_DEV_ENV:-0} IS_AUTO_UPDATE_DISABLED: ${IS_AUTO_UPDATE_DISABLED:-0} IS_PUBLISHED: ${IS_PUBLISHED:-0} + NOTARIZE: ${NOTARIZE:-} + APPLE_TEAM_ID: ${APPLE_TEAM_ID:-} + APPLE_ID: ${APPLE_ID:-} + APPLE_APP_SPECIFIC_PASSWORD: ${APPLE_APP_SPECIFIC_PASSWORD:-} + CSC_LINK: ${CSC_LINK:-} + CSC_KEY_PASSWORD: ${CSC_KEY_PASSWORD:-} GH_TOKEN: ${GH_TOKEN:-} GITHUB_TOKEN: ${GITHUB_TOKEN:-} EP_GH_IGNORE_TIME: ${EP_GH_IGNORE_TIME:-true} diff --git a/electron-builder-config.js b/electron-builder-config.js index 0fb4b4f0..92f7cb87 100644 --- a/electron-builder-config.js +++ b/electron-builder-config.js @@ -13,6 +13,22 @@ let zippedAppImageArtifactPath let zippedMacArtifactPath const appOutDirs = new Map() +// Notarize can be done only on MacOS +const macNotarize = ( + process.platform === 'darwin' && + process.env.NOTARIZE +) + ? { + notarize: { + teamId: process.env.APPLE_TEAM_ID + } + } + : {} +// DMG can be built only on MacOS +const macSpecificTargets = process.platform === 'darwin' + ? ['dmg'] + : [] + /* eslint-disable no-template-curly-in-string */ const nodeModulesFilter = [ @@ -101,12 +117,10 @@ module.exports = { category: 'public.app-category.finance', minimumSystemVersion: '11', darkModeSupport: true, - notarize: { - teamId: process.env.APPLE_TEAM_ID - }, + ...macNotarize, target: [ 'dir', - 'dmg' + ...macSpecificTargets ] }, dmg: {