From f760db350220ff690ba550cb8ba7249e623b3320 Mon Sep 17 00:00:00 2001 From: Louis Date: Wed, 1 Nov 2023 13:32:54 +0700 Subject: [PATCH 01/10] chore: disable app update on test --- electron/main.ts | 4 +++- electron/package.json | 1 + package.json | 3 ++- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/electron/main.ts b/electron/main.ts index 4237bca6b9..2affe9a555 100644 --- a/electron/main.ts +++ b/electron/main.ts @@ -129,7 +129,9 @@ function handleAppUpdates() { }); autoUpdater.autoDownload = false; autoUpdater.autoInstallOnAppQuit = true; - autoUpdater.checkForUpdates(); + if (process.env.CI !== "e2e") { + autoUpdater.checkForUpdates(); + } } /** diff --git a/electron/package.json b/electron/package.json index b6834dfdd7..107313fd5d 100644 --- a/electron/package.json +++ b/electron/package.json @@ -53,6 +53,7 @@ "test:e2e": "playwright test --workers=1", "dev": "tsc -p . && electron .", "build": "tsc -p . && electron-builder -p never -m", + "build:test": "tsc -p . && electron-builder --dir -p never -m", "build:darwin": "tsc -p . && electron-builder -p never -m --x64 --arm64", "build:win32": "tsc -p . && electron-builder -p never -w", "build:linux": "tsc -p . && electron-builder -p never --linux deb", diff --git a/package.json b/package.json index e3205fed85..85010b4a6a 100644 --- a/package.json +++ b/package.json @@ -22,10 +22,11 @@ "dev:electron": "yarn workspace jan dev", "dev:web": "yarn workspace jan-web dev", "dev": "concurrently --kill-others \"yarn dev:web\" \"wait-on http://localhost:3000 && yarn dev:electron\"", - "test-local": "yarn lint && yarn build && yarn test", + "test-local": "yarn lint && yarn build:web && yarn build:electron:test && yarn test", "build:core": "cd core && yarn install && yarn run build", "build:web": "yarn workspace jan-web build && cpx \"web/out/**\" \"electron/renderer/\"", "build:electron": "yarn workspace jan build", + "build:electron:test": "yarn workspace jan build:test", "build:plugins": "rimraf ./electron/core/pre-install/*.tgz && concurrently --kill-others-on-fail \"cd ./plugins/data-plugin && npm install && npm run postinstall\" \"cd ./plugins/inference-plugin && npm install && npm run postinstall\" \"cd ./plugins/model-management-plugin && npm install && npm run postinstall\" \"cd ./plugins/monitoring-plugin && npm install && npm run postinstall\" && concurrently --kill-others-on-fail \"cd ./plugins/data-plugin && npm run build:publish\" \"cd ./plugins/inference-plugin && npm run build:publish\" \"cd ./plugins/model-management-plugin && npm run build:publish\" \"cd ./plugins/monitoring-plugin && npm run build:publish\"", "build:plugins-darwin": "rimraf ./electron/core/pre-install/*.tgz && concurrently \"cd ./plugins/data-plugin && npm install && npm run build:deps && npm run postinstall\" \"cd ./plugins/inference-plugin && npm install && npm run postinstall\" \"cd ./plugins/model-management-plugin && npm install && npm run postinstall\" \"cd ./plugins/monitoring-plugin && npm install && npm run postinstall\" && chmod +x ./.github/scripts/auto-sign.sh && ./.github/scripts/auto-sign.sh && concurrently \"cd ./plugins/data-plugin && npm run build:publish\" \"cd ./plugins/inference-plugin && npm run build:publish\" \"cd ./plugins/model-management-plugin && npm run build:publish\" \"cd ./plugins/monitoring-plugin && npm run build:publish\"", "build": "yarn build:web && yarn build:electron", From 890a29b0fabbe2371b1d719af32ff760b6471fc6 Mon Sep 17 00:00:00 2001 From: Louis Date: Wed, 1 Nov 2023 13:40:11 +0700 Subject: [PATCH 02/10] chore: add build:test step --- package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 85010b4a6a..48526ba23e 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ "dev:electron": "yarn workspace jan dev", "dev:web": "yarn workspace jan-web dev", "dev": "concurrently --kill-others \"yarn dev:web\" \"wait-on http://localhost:3000 && yarn dev:electron\"", - "test-local": "yarn lint && yarn build:web && yarn build:electron:test && yarn test", + "test-local": "yarn lint && yarn build:test && yarn test", "build:core": "cd core && yarn install && yarn run build", "build:web": "yarn workspace jan-web build && cpx \"web/out/**\" \"electron/renderer/\"", "build:electron": "yarn workspace jan build", @@ -30,6 +30,7 @@ "build:plugins": "rimraf ./electron/core/pre-install/*.tgz && concurrently --kill-others-on-fail \"cd ./plugins/data-plugin && npm install && npm run postinstall\" \"cd ./plugins/inference-plugin && npm install && npm run postinstall\" \"cd ./plugins/model-management-plugin && npm install && npm run postinstall\" \"cd ./plugins/monitoring-plugin && npm install && npm run postinstall\" && concurrently --kill-others-on-fail \"cd ./plugins/data-plugin && npm run build:publish\" \"cd ./plugins/inference-plugin && npm run build:publish\" \"cd ./plugins/model-management-plugin && npm run build:publish\" \"cd ./plugins/monitoring-plugin && npm run build:publish\"", "build:plugins-darwin": "rimraf ./electron/core/pre-install/*.tgz && concurrently \"cd ./plugins/data-plugin && npm install && npm run build:deps && npm run postinstall\" \"cd ./plugins/inference-plugin && npm install && npm run postinstall\" \"cd ./plugins/model-management-plugin && npm install && npm run postinstall\" \"cd ./plugins/monitoring-plugin && npm install && npm run postinstall\" && chmod +x ./.github/scripts/auto-sign.sh && ./.github/scripts/auto-sign.sh && concurrently \"cd ./plugins/data-plugin && npm run build:publish\" \"cd ./plugins/inference-plugin && npm run build:publish\" \"cd ./plugins/model-management-plugin && npm run build:publish\" \"cd ./plugins/monitoring-plugin && npm run build:publish\"", "build": "yarn build:web && yarn build:electron", + "build:test": "yarn build:web && yarn build:electron:test", "build:darwin": "yarn build:web && yarn workspace jan build:darwin", "build:win32": "yarn build:web && yarn workspace jan build:win32", "build:linux": "yarn build:web && yarn workspace jan build:linux", From 4bbcd49b76463d45be97acb65dd4518311b49ccf Mon Sep 17 00:00:00 2001 From: Hien To Date: Wed, 1 Nov 2023 14:05:44 +0700 Subject: [PATCH 03/10] Update CI test uses yarn build:test --- .github/workflows/jan-electron-linter-and-test.yml | 6 +++--- electron/package.json | 3 +++ package.json | 3 +++ 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/.github/workflows/jan-electron-linter-and-test.yml b/.github/workflows/jan-electron-linter-and-test.yml index e9e3f091a0..a489779ca1 100644 --- a/.github/workflows/jan-electron-linter-and-test.yml +++ b/.github/workflows/jan-electron-linter-and-test.yml @@ -47,7 +47,7 @@ jobs: yarn install yarn lint yarn build:plugins - yarn build + yarn build:test yarn test env: CSC_IDENTITY_AUTO_DISCOVERY: "false" @@ -78,7 +78,7 @@ jobs: yarn install yarn lint yarn build:plugins - yarn build:win32 + yarn build:test-win32 yarn test test-on-ubuntu: @@ -107,5 +107,5 @@ jobs: yarn install yarn lint yarn build:plugins - yarn build:linux + yarn build:test-linux yarn test \ No newline at end of file diff --git a/electron/package.json b/electron/package.json index 107313fd5d..da9b34e38f 100644 --- a/electron/package.json +++ b/electron/package.json @@ -54,6 +54,9 @@ "dev": "tsc -p . && electron .", "build": "tsc -p . && electron-builder -p never -m", "build:test": "tsc -p . && electron-builder --dir -p never -m", + "build:test-darwin": "tsc -p . && electron-builder -p never -m --x64 --arm64 --dir", + "build:test-win32": "tsc -p . && electron-builder -p never -w --dir", + "build:test-linux": "tsc -p . && electron-builder -p never -l --dir", "build:darwin": "tsc -p . && electron-builder -p never -m --x64 --arm64", "build:win32": "tsc -p . && electron-builder -p never -w", "build:linux": "tsc -p . && electron-builder -p never --linux deb", diff --git a/package.json b/package.json index 48526ba23e..fb59cd103a 100644 --- a/package.json +++ b/package.json @@ -31,6 +31,9 @@ "build:plugins-darwin": "rimraf ./electron/core/pre-install/*.tgz && concurrently \"cd ./plugins/data-plugin && npm install && npm run build:deps && npm run postinstall\" \"cd ./plugins/inference-plugin && npm install && npm run postinstall\" \"cd ./plugins/model-management-plugin && npm install && npm run postinstall\" \"cd ./plugins/monitoring-plugin && npm install && npm run postinstall\" && chmod +x ./.github/scripts/auto-sign.sh && ./.github/scripts/auto-sign.sh && concurrently \"cd ./plugins/data-plugin && npm run build:publish\" \"cd ./plugins/inference-plugin && npm run build:publish\" \"cd ./plugins/model-management-plugin && npm run build:publish\" \"cd ./plugins/monitoring-plugin && npm run build:publish\"", "build": "yarn build:web && yarn build:electron", "build:test": "yarn build:web && yarn build:electron:test", + "build:test-darwin": "yarn build:web && yarn workspace jan build:test-darwin", + "build:test-win32": "yarn build:web && yarn workspace jan build:test-win32", + "build:test-linux": "yarn build:web && yarn workspace jan build:test-linux", "build:darwin": "yarn build:web && yarn workspace jan build:darwin", "build:win32": "yarn build:web && yarn workspace jan build:win32", "build:linux": "yarn build:web && yarn workspace jan build:linux", From 71c742ec5e1fe1259c02c768079be611a0c70077 Mon Sep 17 00:00:00 2001 From: Hien To Date: Wed, 1 Nov 2023 14:24:08 +0700 Subject: [PATCH 04/10] Plugin pull from npm registry instead of rebuild --- .github/workflows/jan-electron-build.yml | 6 +++--- .github/workflows/jan-electron-linter-and-test.yml | 6 +++--- package.json | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/jan-electron-build.yml b/.github/workflows/jan-electron-build.yml index c6a2df1b9b..3393656259 100644 --- a/.github/workflows/jan-electron-build.yml +++ b/.github/workflows/jan-electron-build.yml @@ -52,7 +52,7 @@ jobs: - name: Install yarn dependencies run: | yarn install - yarn build:plugins-darwin + yarn build:pull-plugins env: APP_PATH: "." DEVELOPER_ID: ${{ secrets.DEVELOPER_ID }} @@ -104,7 +104,7 @@ jobs: run: | yarn config set network-timeout 300000 yarn install - yarn build:plugins + yarn build:pull-plugins - name: Build and publish app run: | @@ -153,7 +153,7 @@ jobs: run: | yarn config set network-timeout 300000 yarn install - yarn build:plugins + yarn build:pull-plugins - name: Build and publish app run: | diff --git a/.github/workflows/jan-electron-linter-and-test.yml b/.github/workflows/jan-electron-linter-and-test.yml index a489779ca1..8306296e21 100644 --- a/.github/workflows/jan-electron-linter-and-test.yml +++ b/.github/workflows/jan-electron-linter-and-test.yml @@ -46,7 +46,7 @@ jobs: yarn config set network-timeout 300000 yarn install yarn lint - yarn build:plugins + yarn build:pull-plugins yarn build:test yarn test env: @@ -77,7 +77,7 @@ jobs: yarn config set network-timeout 300000 yarn install yarn lint - yarn build:plugins + yarn build:pull-plugins yarn build:test-win32 yarn test @@ -106,6 +106,6 @@ jobs: yarn config set network-timeout 300000 yarn install yarn lint - yarn build:plugins + yarn build:pull-plugins yarn build:test-linux yarn test \ No newline at end of file diff --git a/package.json b/package.json index fb59cd103a..efa2ae07b8 100644 --- a/package.json +++ b/package.json @@ -27,8 +27,8 @@ "build:web": "yarn workspace jan-web build && cpx \"web/out/**\" \"electron/renderer/\"", "build:electron": "yarn workspace jan build", "build:electron:test": "yarn workspace jan build:test", + "build:pull-plugins": "rimraf ./electron/core/pre-install/*.tgz && cd ./electron/core/pre-install && npm pack @janhq/inference-plugin @janhq/data-plugin @janhq/model-management-plugin @janhq/monitoring-plugin", "build:plugins": "rimraf ./electron/core/pre-install/*.tgz && concurrently --kill-others-on-fail \"cd ./plugins/data-plugin && npm install && npm run postinstall\" \"cd ./plugins/inference-plugin && npm install && npm run postinstall\" \"cd ./plugins/model-management-plugin && npm install && npm run postinstall\" \"cd ./plugins/monitoring-plugin && npm install && npm run postinstall\" && concurrently --kill-others-on-fail \"cd ./plugins/data-plugin && npm run build:publish\" \"cd ./plugins/inference-plugin && npm run build:publish\" \"cd ./plugins/model-management-plugin && npm run build:publish\" \"cd ./plugins/monitoring-plugin && npm run build:publish\"", - "build:plugins-darwin": "rimraf ./electron/core/pre-install/*.tgz && concurrently \"cd ./plugins/data-plugin && npm install && npm run build:deps && npm run postinstall\" \"cd ./plugins/inference-plugin && npm install && npm run postinstall\" \"cd ./plugins/model-management-plugin && npm install && npm run postinstall\" \"cd ./plugins/monitoring-plugin && npm install && npm run postinstall\" && chmod +x ./.github/scripts/auto-sign.sh && ./.github/scripts/auto-sign.sh && concurrently \"cd ./plugins/data-plugin && npm run build:publish\" \"cd ./plugins/inference-plugin && npm run build:publish\" \"cd ./plugins/model-management-plugin && npm run build:publish\" \"cd ./plugins/monitoring-plugin && npm run build:publish\"", "build": "yarn build:web && yarn build:electron", "build:test": "yarn build:web && yarn build:electron:test", "build:test-darwin": "yarn build:web && yarn workspace jan build:test-darwin", From aafa75b6772a2508ff32b42d76d06ab50d0bdd6f Mon Sep 17 00:00:00 2001 From: Hien To Date: Wed, 1 Nov 2023 15:29:13 +0700 Subject: [PATCH 05/10] Add build cache for ci test --- .github/workflows/jan-electron-linter-and-test.yml | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/.github/workflows/jan-electron-linter-and-test.yml b/.github/workflows/jan-electron-linter-and-test.yml index 8306296e21..28c5fb7f42 100644 --- a/.github/workflows/jan-electron-linter-and-test.yml +++ b/.github/workflows/jan-electron-linter-and-test.yml @@ -36,6 +36,17 @@ jobs: - name: Getting the repo uses: actions/checkout@v3 + - name: Cache node and yarn + id: jan-cache-all + uses: actions/cache@v3 + with: + path: | + ./node_modules + ./electron/node_modules + ./web/node_modules + ./web/.next/cache + key: ${{ runner.os }}-jan-cache-all + - name: Installing node uses: actions/setup-node@v1 with: @@ -76,7 +87,6 @@ jobs: run: | yarn config set network-timeout 300000 yarn install - yarn lint yarn build:pull-plugins yarn build:test-win32 yarn test @@ -105,7 +115,6 @@ jobs: echo -e "Display ID: $DISPLAY" yarn config set network-timeout 300000 yarn install - yarn lint yarn build:pull-plugins yarn build:test-linux yarn test \ No newline at end of file From a20b0cb357f95841cf7720c48f6d23083ea08c7a Mon Sep 17 00:00:00 2001 From: Hien To Date: Wed, 1 Nov 2023 15:30:33 +0700 Subject: [PATCH 06/10] Add build cache for ci test --- .../jan-electron-linter-and-test.yml | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/.github/workflows/jan-electron-linter-and-test.yml b/.github/workflows/jan-electron-linter-and-test.yml index 28c5fb7f42..ba51ade8a2 100644 --- a/.github/workflows/jan-electron-linter-and-test.yml +++ b/.github/workflows/jan-electron-linter-and-test.yml @@ -78,6 +78,17 @@ jobs: - name: Getting the repo uses: actions/checkout@v3 + - name: Cache node and yarn + id: jan-cache-all + uses: actions/cache@v3 + with: + path: | + ./node_modules + ./electron/node_modules + ./web/node_modules + ./web/.next/cache + key: ${{ runner.os }}-jan-cache-all + - name: Installing node uses: actions/setup-node@v1 with: @@ -104,6 +115,17 @@ jobs: - name: Getting the repo uses: actions/checkout@v3 + - name: Cache node and yarn + id: jan-cache-all + uses: actions/cache@v3 + with: + path: | + ./node_modules + ./electron/node_modules + ./web/node_modules + ./web/.next/cache + key: ${{ runner.os }}-jan-cache-all + - name: Installing node uses: actions/setup-node@v1 with: From 1849944830ba456b78afe4974b68025cc077e7ad Mon Sep 17 00:00:00 2001 From: Hien To Date: Wed, 1 Nov 2023 16:56:47 +0700 Subject: [PATCH 07/10] Switch to local cache for ci test --- .github/workflows/jan-electron-linter-and-test.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/jan-electron-linter-and-test.yml b/.github/workflows/jan-electron-linter-and-test.yml index ba51ade8a2..ef549fd10f 100644 --- a/.github/workflows/jan-electron-linter-and-test.yml +++ b/.github/workflows/jan-electron-linter-and-test.yml @@ -38,7 +38,7 @@ jobs: - name: Cache node and yarn id: jan-cache-all - uses: actions/cache@v3 + uses: MasterworksIO/action-local-cache@2 with: path: | ./node_modules @@ -80,7 +80,7 @@ jobs: - name: Cache node and yarn id: jan-cache-all - uses: actions/cache@v3 + uses: MasterworksIO/action-local-cache@2 with: path: | ./node_modules @@ -117,7 +117,7 @@ jobs: - name: Cache node and yarn id: jan-cache-all - uses: actions/cache@v3 + uses: MasterworksIO/action-local-cache@2 with: path: | ./node_modules From 9439ed47e9ea32304907e9d5da33b9ce43237f9c Mon Sep 17 00:00:00 2001 From: Hien To Date: Wed, 1 Nov 2023 17:06:45 +0700 Subject: [PATCH 08/10] Switch to gihub action cache for ci test --- .github/workflows/jan-electron-linter-and-test.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/jan-electron-linter-and-test.yml b/.github/workflows/jan-electron-linter-and-test.yml index ef549fd10f..ba51ade8a2 100644 --- a/.github/workflows/jan-electron-linter-and-test.yml +++ b/.github/workflows/jan-electron-linter-and-test.yml @@ -38,7 +38,7 @@ jobs: - name: Cache node and yarn id: jan-cache-all - uses: MasterworksIO/action-local-cache@2 + uses: actions/cache@v3 with: path: | ./node_modules @@ -80,7 +80,7 @@ jobs: - name: Cache node and yarn id: jan-cache-all - uses: MasterworksIO/action-local-cache@2 + uses: actions/cache@v3 with: path: | ./node_modules @@ -117,7 +117,7 @@ jobs: - name: Cache node and yarn id: jan-cache-all - uses: MasterworksIO/action-local-cache@2 + uses: actions/cache@v3 with: path: | ./node_modules From 7fbc9e7aa3186278a51546727a82dcdf87199d9b Mon Sep 17 00:00:00 2001 From: Hien To Date: Wed, 1 Nov 2023 17:16:40 +0700 Subject: [PATCH 09/10] windows use GNU tar instead BSD tar --- .github/workflows/jan-electron-linter-and-test.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/jan-electron-linter-and-test.yml b/.github/workflows/jan-electron-linter-and-test.yml index ba51ade8a2..0a97d386e5 100644 --- a/.github/workflows/jan-electron-linter-and-test.yml +++ b/.github/workflows/jan-electron-linter-and-test.yml @@ -36,6 +36,10 @@ jobs: - name: Getting the repo uses: actions/checkout@v3 + - name: "Use GNU tar instead BSD tar" + shell: cmd + run: echo C:\Program Files\Git\usr\bin>>"%GITHUB_PATH%" + - name: Cache node and yarn id: jan-cache-all uses: actions/cache@v3 From 686aa7d07c7a6d76b353602cc6b91e00e9cbda76 Mon Sep 17 00:00:00 2001 From: Hien To Date: Wed, 1 Nov 2023 17:22:01 +0700 Subject: [PATCH 10/10] disable cache due to bad performance on windows --- .../jan-electron-linter-and-test.yml | 37 ------------------- 1 file changed, 37 deletions(-) diff --git a/.github/workflows/jan-electron-linter-and-test.yml b/.github/workflows/jan-electron-linter-and-test.yml index 0a97d386e5..8c0960463f 100644 --- a/.github/workflows/jan-electron-linter-and-test.yml +++ b/.github/workflows/jan-electron-linter-and-test.yml @@ -36,21 +36,6 @@ jobs: - name: Getting the repo uses: actions/checkout@v3 - - name: "Use GNU tar instead BSD tar" - shell: cmd - run: echo C:\Program Files\Git\usr\bin>>"%GITHUB_PATH%" - - - name: Cache node and yarn - id: jan-cache-all - uses: actions/cache@v3 - with: - path: | - ./node_modules - ./electron/node_modules - ./web/node_modules - ./web/.next/cache - key: ${{ runner.os }}-jan-cache-all - - name: Installing node uses: actions/setup-node@v1 with: @@ -82,17 +67,6 @@ jobs: - name: Getting the repo uses: actions/checkout@v3 - - name: Cache node and yarn - id: jan-cache-all - uses: actions/cache@v3 - with: - path: | - ./node_modules - ./electron/node_modules - ./web/node_modules - ./web/.next/cache - key: ${{ runner.os }}-jan-cache-all - - name: Installing node uses: actions/setup-node@v1 with: @@ -119,17 +93,6 @@ jobs: - name: Getting the repo uses: actions/checkout@v3 - - name: Cache node and yarn - id: jan-cache-all - uses: actions/cache@v3 - with: - path: | - ./node_modules - ./electron/node_modules - ./web/node_modules - ./web/.next/cache - key: ${{ runner.os }}-jan-cache-all - - name: Installing node uses: actions/setup-node@v1 with: