From 55920b6f001af203e59fbd6587312f068ee4a8b6 Mon Sep 17 00:00:00 2001 From: Oj Date: Tue, 1 Feb 2022 20:54:35 +0000 Subject: [PATCH] [CI > Test] Initial Add --- .github/workflows/test_startup.yml | 43 ++++++++++++++++++++++++++++++ scripts/testStartup.js | 19 +++++++++++++ 2 files changed, 62 insertions(+) create mode 100644 .github/workflows/test_startup.yml create mode 100644 scripts/testStartup.js diff --git a/.github/workflows/test_startup.yml b/.github/workflows/test_startup.yml new file mode 100644 index 0000000..4d3ef09 --- /dev/null +++ b/.github/workflows/test_startup.yml @@ -0,0 +1,43 @@ +name: Release Nightly + +on: + push: + branches: [ main ] + paths: + - 'src/**' + - 'scripts/**' + - 'polyfills/**' + - '.github/workflows/test_startup.yml' + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Setup Node.js v16.x + uses: actions/setup-node@v2 + with: + node-version: 16.x + + - name: Pack base asar + run: | + npm i -g asar uglify-js + bash scripts/injectPolyfills.sh + sed -i -e "s/nightly/nightly-$(git rev-parse HEAD | cut -c 1-7)/" src/index.js + + npx asar pack src app.asar + + - name: Download Discord with OpenAsar + run: | + wget "https://discord.com/api/download/canary?platform=linux&format=tar.gz" -O discord.tar.gz + tar xf discord.tar.gz + cp app.asar DiscordCanary/resources/app.asar + + - name: Check if Discord will startup + run: | + ./DiscordCanary/DiscordCanary + # node scripts/testStartup.js ./DiscordCanary/DiscordCanary \ No newline at end of file diff --git a/scripts/testStartup.js b/scripts/testStartup.js new file mode 100644 index 0000000..f7f8e16 --- /dev/null +++ b/scripts/testStartup.js @@ -0,0 +1,19 @@ +const { execFile } = require('child_process'); + +const test = () => { + const proc = execFile(process.argv[2], ['--enable-logging']); + + let success = false; + proc.stderr.on('data', (data) => { + if (data.toString().includes('FAST CONNECT')) { // Main window JS running, startup success + success = true; + proc.kill(); + } + }); + + proc.on('close', async () => { + process.exit(success ? 0 : 1); + }); +}; + +test(); \ No newline at end of file