From 4d3b66c1ad059163af47faeaa1ffd948a5ee4b25 Mon Sep 17 00:00:00 2001 From: Labhansh Agrawal Date: Wed, 26 Jul 2023 12:08:50 +0530 Subject: [PATCH] test on linux --- .github/workflows/nodejs.yml | 111 +++-------------------------------- app/session.ts | 9 +-- app/utils/shell-fallback.ts | 25 ++++++++ electron-builder.json | 6 +- 4 files changed, 40 insertions(+), 111 deletions(-) create mode 100644 app/utils/shell-fallback.ts diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index 01cb8e958f08..46741479663c 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -16,9 +16,7 @@ jobs: strategy: matrix: os: - - macos-latest - ubuntu-latest - - windows-latest fail-fast: false steps: - name: Checkout @@ -40,18 +38,6 @@ jobs: run: yarn install env: npm_config_node_gyp: ${{ github.workspace }}${{ runner.os == 'Windows' && '\node_modules\node-gyp\bin\node-gyp.js' || '/node_modules/node-gyp/bin/node-gyp.js' }} - - name: Install libarchive-tools - if: runner.os == 'Linux' - run: | - sudo apt update - sudo apt install libarchive-tools - - name: Lint and Run Unit Tests - run: yarn run test - - name: Getting Build Icon - if: github.ref == 'refs/heads/canary' || github.base_ref == 'canary' - run: | - cp build/canary.ico build/icon.ico - cp build/canary.icns build/icon.icns - name: Build run: | if [ -z "$CSC_LINK" ] ; then unset CSC_LINK ; fi @@ -69,22 +55,16 @@ jobs: WIN_CSC_KEY_PASSWORD: ${{ secrets.WIN_CERT_P12_PASSWORD }} APPLE_ID: ${{ secrets.APPLE_ID }} APPLE_APP_SPECIFIC_PASSWORD: ${{ secrets.APPLE_PASSWORD }} - - name: Archive Build Artifacts - uses: LabhanshAgrawal/upload-artifact@v3 - with: - path: | - dist/*.dmg - dist/*.snap - dist/*.AppImage - dist/*.deb - dist/*.rpm - dist/*.pacman - dist/*.exe - - name: Run E2E Tests - if: runner.os != 'Linux' - run: yarn run test:e2e + - name: Run E2E Tests on Linux + if: runner.os == 'Linux' + # uses: GabrielBB/xvfb-action@v1.4 + # with: + # working-directory: . + # run: yarn run test:e2e + run: xvfb-run --auto-servernum --server-args="-screen 0 1280x960x24" -- yarn run test:e2e + env: + DEBUG: 'x' - name: Archive E2E test screenshot - if: runner.os != 'Linux' uses: actions/upload-artifact@v3 with: name: e2e @@ -105,76 +85,3 @@ jobs: with: path: ${{ steps.yarn-cache-dir-path.outputs.dir }} key: ${{ runner.os }}-yarn-${{ hashFiles('yarn.lock', 'app/yarn.lock') }} - - build-linux-arm: - runs-on: ubuntu-latest - strategy: - matrix: - include: - - name: armv7l - cpu: cortex-a8 - image: raspios_lite:latest - - name: arm64 - cpu: cortex-a53 - image: raspios_lite_arm64:latest - fail-fast: false - steps: - - name: Checkout - uses: actions/checkout@v3 - - name: Use Node.js ${{ env.NODE_VERSION }} - uses: actions/setup-node@v3 - with: - node-version: ${{ env.NODE_VERSION }} - - name: Get yarn cache directory path - id: yarn-cache-dir-path - run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT - - uses: actions/cache/restore@v3 - with: - path: ${{ steps.yarn-cache-dir-path.outputs.dir }} - key: ${{ runner.os }}-yarn-${{ hashFiles('yarn.lock', 'app/yarn.lock') }} - restore-keys: | - ${{ runner.os }}-yarn- - - name: Install - run: | - yarn install - sudo apt update - sudo apt install libarchive-tools - - name: Compile - run: yarn run build - - name: rebuild node-pty - uses: pguyot/arm-runner-action@v2.5.2 - with: - image_additional_mb: 2000 - base_image: ${{ matrix.image }} - cpu: ${{ matrix.cpu }} - shell: bash - copy_artifact_path: target/node_modules/node-pty - copy_artifact_dest: target/node_modules - commands: | - wget https://nodejs.org/dist/v18.16.0/node-v18.16.0-linux-${{ matrix.name }}.tar.xz - tar -xJf node-v18.16.0-linux-${{ matrix.name }}.tar.xz - sudo cp node-v18.16.0-linux-${{ matrix.name }}/* /usr/local/ -R - npm run rebuild-node-pty - - name: chown node-pty - run: | - sudo chown -R $USER:$USER target/node_modules/node-pty - - name: Prepare v8 snapshot - if: matrix.name == 'armv7l' - run: | - sudo dpkg --add-architecture i386 - sudo apt update - sudo apt install -y libglib2.0-0:i386 libexpat1:i386 libgcc-s1:i386 - npm_config_arch=armv7l yarn run v8-snapshot:arch - - name: Build - run: yarn run electron-builder -l deb rpm AppImage pacman --${{ matrix.name }} -c electron-builder-linux-ci.json - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Archive Build Artifacts - uses: LabhanshAgrawal/upload-artifact@v3 - with: - path: | - dist/*.snap - dist/*.AppImage - dist/*.deb - dist/*.rpm - dist/*.pacman diff --git a/app/session.ts b/app/session.ts index 74d9d72bb370..8a44466fff26 100644 --- a/app/session.ts +++ b/app/session.ts @@ -11,6 +11,7 @@ import * as config from './config'; import {cliScriptPath} from './config/paths'; import {productName, version} from './package.json'; import {getDecoratedEnv} from './plugins'; +import {getFallBackShellConfig} from './utils/shell-fallback'; const createNodePtyError = () => new Error( @@ -183,16 +184,16 @@ export default class Session extends EventEmitter { // fall back to default shell config if the shell exits within 1 sec with non zero exit code // this will inform users in case there are errors in the config instead of instant exit const runDuration = new Date().getTime() - this.initTimestamp; - if (e.exitCode > 0 && runDuration < 1000) { - const defaultShellConfig = {shell: defaultShell, shellArgs: defaultShellArgs}; + const fallBackShellConfig = getFallBackShellConfig(shell, shellArgs, defaultShell, defaultShellArgs); + if (e.exitCode > 0 && runDuration < 1000 && fallBackShellConfig) { const msg = ` shell exited in ${runDuration} ms with exit code ${e.exitCode} please check the shell config: ${JSON.stringify({shell, shellArgs}, undefined, 2)} -fallback to default shell config: ${JSON.stringify(defaultShellConfig, undefined, 2)} +using fallback shell config: ${JSON.stringify(fallBackShellConfig, undefined, 2)} `; console.warn(msg); this.batcher?.write(msg.replace(/\n/g, '\r\n')); - this.init({uid, rows, cols, cwd, ...defaultShellConfig, profile}); + this.init({uid, rows, cols, cwd, ...fallBackShellConfig, profile}); } else { this.ended = true; this.emit('exit'); diff --git a/app/utils/shell-fallback.ts b/app/utils/shell-fallback.ts new file mode 100644 index 000000000000..0eb7df4bd12d --- /dev/null +++ b/app/utils/shell-fallback.ts @@ -0,0 +1,25 @@ +export const getFallBackShellConfig = ( + shell: string, + shellArgs: string[], + defaultShell: string, + defaultShellArgs: string[] +): { + shell: string; + shellArgs: string[]; +} | null => { + if (shellArgs.length > 0) { + return { + shell, + shellArgs: [] + }; + } + + if (shell != defaultShell) { + return { + shell: defaultShell, + shellArgs: defaultShellArgs + }; + } + + return null; +}; diff --git a/electron-builder.json b/electron-builder.json index e5f0d69198e0..efc19f04ea4f 100644 --- a/electron-builder.json +++ b/electron-builder.json @@ -21,11 +21,7 @@ "linux": { "category": "TerminalEmulator", "target": [ - "deb", - "AppImage", - "rpm", - "snap", - "pacman" + "deb" ] }, "win": {