diff --git a/.github/workflows/build-electron-app.yml b/.github/workflows/build-electron-app.yml index 6f2cded9..37c05978 100644 --- a/.github/workflows/build-electron-app.yml +++ b/.github/workflows/build-electron-app.yml @@ -83,7 +83,12 @@ jobs: retry_wait_seconds: 10 max_attempts: 3 retry_on: any - command: ./scripts/launch.sh -lwp + command: | + if [[ "${REPO_OWNER}" != "${{ github.repository_owner }}" ]]; then + ./scripts/launch.sh -lw + else + ./scripts/launch.sh -lwp + fi - name: Zip Linux Unpacked build run: zip -r dist/linux-unpacked.zip dist/linux-unpacked - name: Upload Linux Unpacked build @@ -98,6 +103,24 @@ jobs: with: name: win-unpacked path: dist/win-unpacked.zip + - if: env.REPO_OWNER != github.repository_owner + name: Upload Linux Dist Release + uses: actions/upload-artifact@v4 + with: + name: linux-dist-release + path: | + dist/*-linux.AppImage + dist/*-linux.AppImage.zip + dist/latest-linux.yml + - if: env.REPO_OWNER != github.repository_owner + name: Upload Win Dist Release + uses: actions/upload-artifact@v4 + with: + name: win-dist-release + path: | + dist/*-win.exe + dist/*-win.exe.blockmap + dist/latest.yml - name: Prepare cache folders run: | sudo chown -R $(id -u):$(id -g) ~/.cache/electron @@ -178,7 +201,11 @@ jobs: if [[ -z "${APPLE_APP_SPECIFIC_PASSWORD}" || "${NOTARIZE:-}" != "1" ]]; then unset APPLE_APP_SPECIFIC_PASSWORD; fi if [[ -z "${CSC_LINK}" || "${NOTARIZE:-}" != "1" ]]; then unset CSC_LINK; fi if [[ -z "${CSC_KEY_PASSWORD}" || "${NOTARIZE:-}" != "1" ]]; then unset CSC_KEY_PASSWORD; fi - ./scripts/build-release.sh -mp + if [[ "${REPO_OWNER}" != "${{ github.repository_owner }}" ]]; then + ./scripts/build-release.sh -m + else + ./scripts/build-release.sh -mp + fi - name: Zip Mac Unpacked build run: zip -r dist/mac.zip dist/mac - name: Upload Mac Unpacked build @@ -186,6 +213,15 @@ jobs: with: name: mac-unpacked path: dist/mac.zip + - if: env.REPO_OWNER != github.repository_owner + name: Upload Mac Dist Release + uses: actions/upload-artifact@v4 + with: + name: mac-dist-release + path: | + dist/*-mac.zip + dist/*-mac.zip.blockmap + dist/latest-mac.yml linux-e2e-test-runner: name: Linux E2E Test Runner @@ -214,7 +250,7 @@ jobs: - 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 + uses: actions/upload-artifact@v4 with: name: linux-e2e-test-results path: e2e-test-report.xml @@ -246,7 +282,7 @@ jobs: - 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 + uses: actions/upload-artifact@v4 with: name: win-e2e-test-results path: e2e-test-report.xml @@ -280,7 +316,7 @@ jobs: - 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 + uses: actions/upload-artifact@v4 with: name: mac-e2e-test-results path: e2e-test-report.xml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index acf4b350..1941df0c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -25,7 +25,7 @@ jobs: run: ./scripts/setup.sh -u - name: Run tests run: npm test -- -- --reporter=json --reporter-option output=test-report.json - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 if: success() || failure() with: name: test-results diff --git a/.github/workflows/e2e-test-report.yml b/.github/workflows/e2e-test-report.yml index b353f0ad..7ce5edd3 100644 --- a/.github/workflows/e2e-test-report.yml +++ b/.github/workflows/e2e-test-report.yml @@ -18,27 +18,50 @@ jobs: runs-on: ubuntu-22.04 if: ${{ github.event.workflow_run.conclusion == 'success' }} steps: - - uses: dorny/test-reporter@v1 + - name: Download Linux E2E test results + uses: actions/download-artifact@v4 + with: + run-id: ${{ github.event.workflow_run.id }} + github-token: ${{ secrets.GITHUB_TOKEN }} + name: linux-e2e-test-results + path: linux-e2e-test-results + - uses: dorny/test-reporter@v1.8.0 id: linux-e2e-test-results with: - artifact: linux-e2e-test-results name: Linux E2E Tests - path: e2e-test-report.xml + path: linux-e2e-test-results/e2e-test-report.xml reporter: jest-junit - - uses: dorny/test-reporter@v1 + # Workaround for error 'fatal: not a git repository' caused by a call to 'git ls-files' + # See: https://github.com/dorny/test-reporter/issues/169#issuecomment-1583560458 + max-annotations: 0 + - name: Download Win E2E test results + uses: actions/download-artifact@v4 + with: + run-id: ${{ github.event.workflow_run.id }} + github-token: ${{ secrets.GITHUB_TOKEN }} + name: win-e2e-test-results + path: win-e2e-test-results + - uses: dorny/test-reporter@v1.8.0 id: win-e2e-test-results with: - artifact: win-e2e-test-results name: Win E2E Tests - path: e2e-test-report.xml + path: win-e2e-test-results/e2e-test-report.xml reporter: jest-junit - - uses: dorny/test-reporter@v1 + max-annotations: 0 + - name: Download Mac E2E test results + uses: actions/download-artifact@v4 + with: + run-id: ${{ github.event.workflow_run.id }} + github-token: ${{ secrets.GITHUB_TOKEN }} + name: mac-e2e-test-results + path: mac-e2e-test-results + - uses: dorny/test-reporter@v1.8.0 id: mac-e2e-test-results with: - artifact: mac-e2e-test-results name: Mac E2E Tests - path: e2e-test-report.xml + path: mac-e2e-test-results/e2e-test-report.xml reporter: jest-junit + max-annotations: 0 - name: E2E Test Report Summary run: | echo "### E2E Test Report page is ready! :rocket:" >> $GITHUB_STEP_SUMMARY diff --git a/.github/workflows/test-report.yml b/.github/workflows/test-report.yml index 107c4a83..bf11d9d5 100644 --- a/.github/workflows/test-report.yml +++ b/.github/workflows/test-report.yml @@ -18,13 +18,22 @@ jobs: runs-on: ubuntu-22.04 if: ${{ github.event.workflow_run.conclusion == 'success' }} steps: - - uses: dorny/test-reporter@v1 + - name: Download test results + uses: actions/download-artifact@v4 + with: + run-id: ${{ github.event.workflow_run.id }} + github-token: ${{ secrets.GITHUB_TOKEN }} + name: test-results + path: test-results + - uses: dorny/test-reporter@v1.8.0 id: test-results with: - artifact: test-results name: Mocha Tests - path: test-report.json + path: test-results/test-report.json reporter: mocha-json + # Workaround for error 'fatal: not a git repository' caused by a call to 'git ls-files' + # See: https://github.com/dorny/test-reporter/issues/169#issuecomment-1583560458 + max-annotations: 0 - name: Test Report Summary run: | echo "### Test Report page is ready! :rocket:" >> $GITHUB_STEP_SUMMARY diff --git a/CHANGELOG.md b/CHANGELOG.md index a4740f0f..c459631a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,28 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [4.21.0] - 2024-03-20 + +### Added + +- Added ability to handle `PDFBufferUnderElectronCreationError` error to use WebSockets to inform users for better UX. PRs: [bfx-report#354](https://github.com/bitfinexcom/bfx-report/pull/354), [bfx-reports-framework#359](https://github.com/bitfinexcom/bfx-reports-framework/pull/359) +- Implemented support for `emitReportFileGenerationFailedToOne` ws events on UI side to inform users about report generation failing. PR: [bfx-report-ui#787](https://github.com/bitfinexcom/bfx-report-ui/pull/787) +- Added missing translations for PDF reports. PRs: [bfx-report#356](https://github.com/bitfinexcom/bfx-report/pull/356), [bfx-reports-framework#362](https://github.com/bitfinexcom/bfx-reports-framework/pull/362) +- Added DB migration for `publicCollsConf` table name with Cyrillic `c`. PR: [bfx-reports-framework#360](https://github.com/bitfinexcom/bfx-reports-framework/pull/360) +- Added migration for public colls conf endpoint name with Cyrillic `c`. PR: [bfx-report-ui#788](https://github.com/bitfinexcom/bfx-report-ui/pull/788) +- Added ability to upload dist release if repo owner is customized using manual build run. PR: [bfx-report-electron#347](https://github.com/bitfinexcom/bfx-report-electron/pull/347) + +### Changed + +- Updated `GH Actions` to use Nodejs `v20` to prevent breaking changes in workflow. PRs: [bfx-report#355](https://github.com/bitfinexcom/bfx-report/pull/355), [bfx-reports-framework#361](https://github.com/bitfinexcom/bfx-reports-framework/pull/361), [bfx-report-electron#344](https://github.com/bitfinexcom/bfx-report-electron/pull/344), [bfx-facs-db-better-sqlite#9](https://github.com/bitfinexcom/bfx-facs-db-better-sqlite/pull/9) +- Migrated from the `deprecated` reports generation methods usage to the actual ones according to the latest backend changes. PR: [bfx-report-ui#784](https://github.com/bitfinexcom/bfx-report-ui/pull/784) +- Allowed all pairs removal at the `Market History / Spot` section according to the latest UX improvement proposals: We should allow the user to remove the current pair and display an empty table that says `No history to display`. PR: [bfx-report-ui#786](https://github.com/bitfinexcom/bfx-report-ui/pull/786) +- Improved print PDF under Electronjs. Turned off ipc log transport between render and main process as unused, it prevents ipc transport error from `electron-log` lib. Suppressed error modal window if pdf gen failed: the idea here is to inform the user if something goes wrong using WS event for better UX instead of showing a modal window error as it is annoying in most cases. Improved pdf generation performance for big html templates, uses `loadFile` method of electron api instead of `base64` encoding. Bumped up Electronjs minor version to have the last fixes. PR: [bfx-report-electron#342](https://github.com/bitfinexcom/bfx-report-electron/pull/342) + +### Fixed + +- Prevented duplication possibility for items in the selectors of the UI. PR: [bfx-report-ui#785](https://github.com/bitfinexcom/bfx-report-ui/pull/785) + ## [4.20.0] - 2024-03-06 ### Added diff --git a/bfx-report-ui b/bfx-report-ui index 3bad3486..a94ca364 160000 --- a/bfx-report-ui +++ b/bfx-report-ui @@ -1 +1 @@ -Subproject commit 3bad3486986d3cc5b44f7c85aa33591d55a5ab7c +Subproject commit a94ca364bd79d2852a69f86cc18ddefff860e895 diff --git a/bfx-reports-framework b/bfx-reports-framework index be1ed7b4..908d9cba 160000 --- a/bfx-reports-framework +++ b/bfx-reports-framework @@ -1 +1 @@ -Subproject commit be1ed7b41947675ed4bee8599fbed1dca747b80e +Subproject commit 908d9cba7dace99efee3f8f13aac3c31699fb72a diff --git a/package.json b/package.json index c048db90..72d11c2d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "bfx-report-electron", - "version": "4.20.0", + "version": "4.21.0", "repository": "https://github.com/bitfinexcom/bfx-report-electron", "description": "Reporting tool", "author": "bitfinex.com", @@ -43,7 +43,7 @@ "app-builder-bin": "4.2.0", "cross-env": "7.0.3", "dotenv": "16.3.1", - "electron": "27.2.0", + "electron": "27.3.5", "electron-builder": "24.10.0", "mocha": "10.2.0", "standard": "17.1.0", diff --git a/scripts/build-release.sh b/scripts/build-release.sh index 27f93e1d..9c0a5b1b 100755 --- a/scripts/build-release.sh +++ b/scripts/build-release.sh @@ -226,6 +226,8 @@ publishOption="" if [ $isPublished == 1 ]; then # Available: 'onTag', 'onTagOrDraft', 'always', 'never' publishOption="--publish always" +else + publishOption="--publish never" fi rm -rf "$DIST_FOLDER/"*"$targetPlatform"* diff --git a/src/error-manager/index.js b/src/error-manager/index.js index f8479831..5a82a4bf 100644 --- a/src/error-manager/index.js +++ b/src/error-manager/index.js @@ -169,6 +169,7 @@ const manageNewGithubIssue = async (params) => { } const initLogger = () => { + log.transports.ipc.level = false log.transports.console.level = isDevEnv ? 'debug' : 'warn' @@ -215,7 +216,9 @@ const initLogger = () => { if ( /Cannot download differentially/gi.test(error) || /ERR_CONNECTION_REFUSED/gi.test(error) || - /objects\.githubusercontent\.com/gi.test(error) + /objects\.githubusercontent\.com/gi.test(error) || + /Error: ERR_FAILED \(-2\) loading 'file:.*\.html'/gi.test(error) || + /Failed to generate PDF/gi.test(error) ) { return message } diff --git a/src/print-to-pdf/index.js b/src/print-to-pdf/index.js index 150b421a..460738e6 100644 --- a/src/print-to-pdf/index.js +++ b/src/print-to-pdf/index.js @@ -16,6 +16,8 @@ const PROCESS_STATES = require( module.exports = () => { ipcs.serverIpc.on('message', async (mess) => { + let templateFilePathForRm = null + try { if (mess?.state !== PROCESS_MESSAGES.REQUEST_PDF_CREATION) { return @@ -33,14 +35,9 @@ module.exports = () => { templateFilePath && typeof templateFilePath === 'string' ) - - const html = isTemplateFilePathUsed - ? await fs.readFile(templateFilePath, { encoding: 'utf8' }) - : template - - if (isTemplateFilePathUsed) { - await fs.rm(templateFilePath, { force: true, maxRetries: 3 }) - } + templateFilePathForRm = isTemplateFilePathUsed + ? templateFilePath + : null const win = new BrowserWindow({ show: false, @@ -49,14 +46,15 @@ module.exports = () => { nodeIntegration: true } }) - win.loadURL(`data:text/html;charset=utf-8,${encodeURIComponent(html)}`) + const closedEventPromise = new Promise((resolve) => ( + win.once('closed', resolve) + )) + const loadPromise = isTemplateFilePathUsed + ? win.loadFile(templateFilePath) + : win.loadURL(`data:text/html;charset=utf-8,${encodeURIComponent(template)}`) + + await loadPromise - await new Promise((resolve, reject) => { - win.webContents.on('did-finish-load', resolve) - win.webContents.on('did-fail-load', (e, code, err) => { - reject(err) - }) - }) const buffer = await win.webContents.printToPDF({ landscape: format !== 'portrait', pageSize: orientation, @@ -79,7 +77,12 @@ module.exports = () => { ` }) + win.close() + await closedEventPromise + if (isTemplateFilePathUsed) { + await fs.rm(templateFilePath, { force: true, maxRetries: 3 }) + const { dir, name } = path.parse(templateFilePath) const pdfFilePath = path.format({ dir, name, ext: '.pdf' }) @@ -98,9 +101,14 @@ module.exports = () => { data: { buffer, uid } }) } catch (err) { + if (templateFilePathForRm) { + fs.rm(templateFilePathForRm, { force: true, maxRetries: 3 }) + .then(() => {}, (err) => { console.debug(err) }) + } + ipcs.serverIpc.send({ state: PROCESS_STATES.RESPONSE_PDF_CREATION, - data: { err, uid: mess?.data?.uid ?? null } + data: { err: err.stack ?? err, uid: mess?.data?.uid ?? null } }) console.error(err)