这是indexloc提供的服务,不要输入任何密码
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
e3e2917
Merge pull request #287 from bitfinexcom/staging
ezewer Dec 14, 2023
d797bc5
Add main dev deps for e2e tests
ZIMkaRU Nov 1, 2023
8e47c61
Add base webdriverio config
ZIMkaRU Nov 1, 2023
03a1de1
Add test case for app title
ZIMkaRU Nov 1, 2023
d05239b
Expose electron api in test env for main process
ZIMkaRU Nov 1, 2023
a8037e8
Add preload script for browser windows
ZIMkaRU Nov 1, 2023
46c2f10
Expose electron api in test env for browser wins
ZIMkaRU Nov 1, 2023
1b95cd3
Add npm script to launch e2e tests
ZIMkaRU Nov 1, 2023
e1e74ea
Prevent removal app unpacked folder for e2e test runner
ZIMkaRU Nov 3, 2023
53aadf7
Improve wdio config
ZIMkaRU Nov 3, 2023
e6248b2
Rework electron-builder config to be able to launch e2e tests
ZIMkaRU Nov 3, 2023
f4b6c41
Fix app e2e test spec
ZIMkaRU Nov 3, 2023
c5fc5f3
Add junit reporter for wdio
ZIMkaRU Nov 3, 2023
45044a4
Add test reports to ignore files
ZIMkaRU Nov 3, 2023
2136dc0
Add linux e2e test runner to github actions
ZIMkaRU Nov 3, 2023
8e1c38e
Launch e2e test runner after builder job
ZIMkaRU Nov 6, 2023
1daca16
Add e2e test report workflow
ZIMkaRU Nov 6, 2023
b1b5b96
Fix issue with low uploading speed on gh actions
ZIMkaRU Nov 6, 2023
f653335
Fix deps installation for e2e tests
ZIMkaRU Nov 6, 2023
45acf89
Skip redundant files in build
ZIMkaRU Nov 7, 2023
db0fdb4
Run e2e tests headlessly by enabling xvfb
ZIMkaRU Nov 7, 2023
907e8cc
Bump electron up to 27.0.3
ZIMkaRU Nov 7, 2023
b6d3249
Add script for adding time attr to testsuites tag
ZIMkaRU Nov 7, 2023
7e7dfac
Normalize e2e test report before uploading
ZIMkaRU Nov 7, 2023
90f8f7c
Add mac e2e test runner
ZIMkaRU Nov 8, 2023
6f95691
Add mac e2e test reporter
ZIMkaRU Nov 8, 2023
29b6adf
Add cross-env for dev/test scripts
ZIMkaRU Nov 8, 2023
e8d29a0
Add win e2e test runner
ZIMkaRU Nov 8, 2023
72203b0
Add win e2e test reporter
ZIMkaRU Nov 8, 2023
d08b967
Bump actions/checkout up to v4
ZIMkaRU Nov 9, 2023
b6e070c
Fix unzipping win unpacked build
ZIMkaRU Nov 9, 2023
6d48bbb
Bump electron-builder up to 24.8.1 to have executable name fix
ZIMkaRU Nov 9, 2023
181f1af
Add common executableName opt for all builds
ZIMkaRU Nov 9, 2023
e28fb6b
Fix making mac app-update-yml in build
ZIMkaRU Nov 9, 2023
f935b67
Fix mac updater for new executable name
ZIMkaRU Nov 9, 2023
a8cfff1
Add correct app binary path to wdio conf according to os
ZIMkaRU Nov 9, 2023
4d03af9
Add bash script to turn uninterrupted e2e testing on macOS
ZIMkaRU Nov 10, 2023
d9b7060
Add gh workflow step to prepare mac e2e test runner
ZIMkaRU Nov 10, 2023
0b31eff
Move prepare-mac-runner script to local gh actions
ZIMkaRU Nov 10, 2023
cb35243
Use macos-11 in gh actions
ZIMkaRU Nov 10, 2023
aaf9e26
Prevent spaces in mac unique computer name
ZIMkaRU Nov 10, 2023
5c7fb5b
Fix electron issue with executableName specifying
ZIMkaRU Nov 10, 2023
9c12e64
Bump wdio up to 8.22.0
ZIMkaRU Nov 10, 2023
08b9a05
Bump electon up to 27.0.4
ZIMkaRU Nov 10, 2023
2ffbd3e
Disable enforce macos app location for e2e test runner
ZIMkaRU Nov 10, 2023
6ce902e
Use macos-12 in gh actions
ZIMkaRU Nov 10, 2023
3285cff
Fix npm start script
ZIMkaRU Nov 10, 2023
2af7deb
Fix browser window creation
ZIMkaRU Nov 10, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
7 changes: 7 additions & 0 deletions .github/actions/prepare-mac-runner/action.yml
Original file line number Diff line number Diff line change
@@ -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
23 changes: 23 additions & 0 deletions .github/actions/prepare-mac-runner/prepare-mac-runner.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env bash

# Turn uninterrupted testing on mac

# Change Local name to avoid name clash causing alert
uniqueComputerName="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'
125 changes: 122 additions & 3 deletions .github/workflows/build-electron-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -76,17 +76,31 @@ 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.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.zip
- name: Prepare cache folders
run: |
sudo chown -R $(id -u):$(id -g) ~/.cache/electron
sudo chown -R $(id -u):$(id -g) ~/.cache/electron-builder

mac-builder:
timeout-minutes: 90
runs-on: macos-11
runs-on: macos-12
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
submodules: recursive
- name: Set repo owner
Expand Down Expand Up @@ -135,3 +149,108 @@ 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.zip

linux-e2e-test-runner:
name: Linux E2E Test Runner
timeout-minutes: 30
runs-on: ubuntu-22.04
needs: [linux-win-docker-builder]
steps:
- name: Checkout
uses: actions/checkout@v4
- 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: Unzip Linux Unpacked build
run: unzip dist/linux-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 Linux E2E test results
uses: actions/upload-artifact@v3
with:
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@v4
- 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 -y x 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
runs-on: macos-12
needs: [mac-builder]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Prepare Mac runner
uses: ./.github/actions/prepare-mac-runner
- 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
47 changes: 47 additions & 0 deletions .github/workflows/e2e-test-report.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
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
- 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:
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 "- [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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,5 @@ package-lock.json
lastCommit.json
electronEnv.json
stub.AppImage
e2e-test-report.xml
test-report.json
16 changes: 16 additions & 0 deletions electron-builder-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,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',
Expand All @@ -133,6 +137,8 @@ module.exports = {
'!**/LICENSE.md',
'!**/.gitmodules',
'!**/.npmrc',
'!**/.mocharc.json',
'!**/.github/${/*}',
{
from: 'bfx-reports-framework/node_modules',
to: 'bfx-reports-framework/node_modules',
Expand All @@ -143,6 +149,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')
],
Expand Down
6 changes: 6 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -33,6 +35,10 @@ if (shouldQuit) {
} else {
;(async () => {
try {
if (isTestEnv) {
require('wdio-electron-service/main')
}

await initializeApp()
} catch (err) {
console.error(err)
Expand Down
20 changes: 14 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,18 @@
},
"devDependencies": {
"@mapbox/node-pre-gyp": "1.0.6",
"@wdio/cli": "8.22.1",
"@wdio/junit-reporter": "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",
"electron": "27.0.2",
"electron-builder": "23.6.0",
"cross-env": "7.0.3",
"electron": "27.0.4",
"electron-builder": "24.8.1",
"mocha": "10.2.0",
"standard": "16.0.4"
"standard": "16.0.4",
"wdio-electron-service": "5.4.0"
},
"standard": {
"globals": [
Expand All @@ -50,11 +57,12 @@
]
},
"scripts": {
"start": "export NODE_ENV=development&&export DEBUG=*&&electron .",
"start": "cross-env NODE_ENV=development 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"
"sync-repo": "./scripts/sync-repo.sh",
"e2e": "cross-env NODE_ENV=test wdio run ./wdio.conf.js"
}
}
4 changes: 3 additions & 1 deletion scripts/build-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
20 changes: 20 additions & 0 deletions scripts/node/normalize-e2e-test-report.js
Original file line number Diff line number Diff line change
@@ -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 '<testsuites>' tag
*/
const normalizedContent = content
.replace(/<testsuites>/gi, '<testsuites time="0">')
writeFileSync(filePath, normalizedContent)
1 change: 1 addition & 0 deletions src/enforce-macos-app-location.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const {

module.exports = async () => {
if (
process.env.NODE_ENV === 'test' ||
process.env.NODE_ENV === 'development' ||
process.platform !== 'darwin'
) {
Expand Down
16 changes: 16 additions & 0 deletions src/preload.js
Original file line number Diff line number Diff line change
@@ -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)
})
Loading