Skip to content

Commit

Permalink
Merge pull request #350 from bitfinexcom/staging
Browse files Browse the repository at this point in the history
Release version 4.21.0
  • Loading branch information
ezewer authored Mar 21, 2024
2 parents c683605 + f58ff4c commit 3c77fd2
Show file tree
Hide file tree
Showing 11 changed files with 142 additions and 39 deletions.
46 changes: 41 additions & 5 deletions .github/workflows/build-electron-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -178,14 +201,27 @@ 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
uses: actions/upload-artifact@v4
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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
41 changes: 32 additions & 9 deletions .github/workflows/e2e-test-report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 12 additions & 3 deletions .github/workflows/test-report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 22 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down Expand Up @@ -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",
Expand Down
2 changes: 2 additions & 0 deletions scripts/build-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"*
Expand Down
5 changes: 4 additions & 1 deletion src/error-manager/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ const manageNewGithubIssue = async (params) => {
}

const initLogger = () => {
log.transports.ipc.level = false
log.transports.console.level = isDevEnv
? 'debug'
: 'warn'
Expand Down Expand Up @@ -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
}
Expand Down
40 changes: 24 additions & 16 deletions src/print-to-pdf/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -79,7 +77,12 @@ module.exports = () => {
</span>`
})

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' })

Expand All @@ -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)
Expand Down

0 comments on commit 3c77fd2

Please sign in to comment.