diff --git a/.github/workflows/build_pat.yaml b/.github/workflows/build_pat.yaml index 6376119e..3da2cbfa 100755 --- a/.github/workflows/build_pat.yaml +++ b/.github/workflows/build_pat.yaml @@ -153,6 +153,20 @@ jobs: ../ cmake --build . --target "$BUILD_TARGET" -j $N + # Starts the built app bundle in the repo's Electron; does not test the packaged installer layout + - name: Electron startup smoke test + timeout-minutes: 3 + shell: bash + env: + PAT_SMOKE_TEST: "1" + run: | + if [ "$RUNNER_OS" == "Linux" ]; then + sudo apt-get install -y xvfb + xvfb-run -a npx electron --no-sandbox build + else + npx electron build + fi + - name: Save artifact if: github.event_name != 'pull_request' uses: actions/upload-artifact@v6 diff --git a/app/background.js b/app/background.js index 5ca5f94b..8d65c3ac 100644 --- a/app/background.js +++ b/app/background.js @@ -53,6 +53,32 @@ app.on('ready', () => { }); remoteMain.enable(mainWindow.webContents); + // CI smoke test: PAT_SMOKE_TEST=1 exits 0 once the AngularJS app has bootstrapped, 1 on load failure/crash/timeout + if (process.env.PAT_SMOKE_TEST === '1') { + const fail = reason => { + console.error('PAT smoke test FAILED: ' + reason); + app.exit(1); + }; + const wc = mainWindow.webContents; + wc.on('did-fail-load', (event, code, description) => fail('did-fail-load ' + code + ' ' + description)); + wc.on('render-process-gone', (event, details) => fail('render-process-gone ' + details.reason)); + wc.on('did-finish-load', () => { + setTimeout(() => { + wc.executeJavaScript('typeof angular !== "undefined" && !!angular.element(document.body).injector()') + .then(ok => { + if (ok) { + console.log('PAT smoke test passed'); + app.exit(0); + } else { + fail('AngularJS app did not bootstrap'); + } + }) + .catch(err => fail(err.message)); + }, 5000); + }); + setTimeout(() => fail('timeout'), 90000); + } + const env = getEnv(app.getAppPath()); if (env.name === 'development') { mainWindow.loadURL('http://localhost:3000/index.html');