Skip to content

Commit

Permalink
test on linux
Browse files Browse the repository at this point in the history
  • Loading branch information
LabhanshAgrawal committed Jul 26, 2023
1 parent 36ff6e9 commit 4d3b66c
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 111 deletions.
111 changes: 9 additions & 102 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ jobs:
strategy:
matrix:
os:
- macos-latest
- ubuntu-latest
- windows-latest
fail-fast: false
steps:
- name: Checkout
Expand All @@ -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
Expand All @@ -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/[email protected]
# 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
Expand All @@ -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/[email protected]
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
9 changes: 5 additions & 4 deletions app/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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');
Expand Down
25 changes: 25 additions & 0 deletions app/utils/shell-fallback.ts
Original file line number Diff line number Diff line change
@@ -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;
};
6 changes: 1 addition & 5 deletions electron-builder.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,7 @@
"linux": {
"category": "TerminalEmulator",
"target": [
"deb",
"AppImage",
"rpm",
"snap",
"pacman"
"deb"
]
},
"win": {
Expand Down

0 comments on commit 4d3b66c

Please sign in to comment.