From a6694921e8bdc324e86ee684136e4fada5788c8c Mon Sep 17 00:00:00 2001 From: hiento09 <136591877+hiento09@users.noreply.github.com> Date: Thu, 19 Oct 2023 15:29:40 +0700 Subject: [PATCH] Refactor cicd (#397) * Refactor cicd * Correct version plugin core --------- Co-authored-by: Hien To --- .github/workflows/jan-docs-test.yml | 29 -------------- .../{deploy-jan-docs.yml => jan-docs.yml} | 12 +++++- .../{build-app.yml => jan-electron-build.yml} | 2 +- ...t.yml => jan-electron-linter-and-test.yml} | 4 +- ...sh-plugin-core.yml => jan-plugin-core.yml} | 13 ++++++- .../{publish-plugins.yml => jan-plugins.yml} | 16 ++++++-- .github/workflows/quality-gate.yml | 39 ------------------- plugins/data-plugin/package-lock.json | 12 +++--- plugins/data-plugin/package.json | 2 +- plugins/inference-plugin/package-lock.json | 26 ++++++++++--- plugins/inference-plugin/package.json | 2 +- .../model-management-plugin/package-lock.json | 34 +++------------- plugins/model-management-plugin/package.json | 2 +- plugins/monitoring-plugin/package-lock.json | 12 +++--- plugins/monitoring-plugin/package.json | 2 +- plugins/openai-plugin/package.json | 2 +- yarn.lock | 8 ++-- 17 files changed, 84 insertions(+), 133 deletions(-) delete mode 100644 .github/workflows/jan-docs-test.yml rename .github/workflows/{deploy-jan-docs.yml => jan-docs.yml} (82%) rename .github/workflows/{build-app.yml => jan-electron-build.yml} (99%) rename .github/workflows/{linter-and-test.yml => jan-electron-linter-and-test.yml} (96%) rename .github/workflows/{publish-plugin-core.yml => jan-plugin-core.yml} (84%) rename .github/workflows/{publish-plugins.yml => jan-plugins.yml} (86%) delete mode 100644 .github/workflows/quality-gate.yml diff --git a/.github/workflows/jan-docs-test.yml b/.github/workflows/jan-docs-test.yml deleted file mode 100644 index 941111b9f..000000000 --- a/.github/workflows/jan-docs-test.yml +++ /dev/null @@ -1,29 +0,0 @@ -name: Jan Docs Test Build - -on: - pull_request: - branches: - - main - paths: - - 'docs/**' - - '.github/workflows/deploy-jan-docs.yml' - - '.github/workflows/jan-docs-test.yml' - -jobs: - deploy: - name: Test Build - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 - with: - node-version: 18 - cache: 'yarn' - cache-dependency-path: './docs/yarn.lock' - - - name: Install dependencies - run: yarn install - working-directory: docs - - name: Test Build Command - run: sed -i '/process.env.DEBUG = namespaces;/c\// process.env.DEBUG = namespaces;' ./node_modules/debug/src/node.js && yarn build - working-directory: docs \ No newline at end of file diff --git a/.github/workflows/deploy-jan-docs.yml b/.github/workflows/jan-docs.yml similarity index 82% rename from .github/workflows/deploy-jan-docs.yml rename to .github/workflows/jan-docs.yml index c0dd9656a..4aeb89df2 100644 --- a/.github/workflows/deploy-jan-docs.yml +++ b/.github/workflows/jan-docs.yml @@ -1,4 +1,4 @@ -name: Deploy to GitHub Pages +name: Jan Docs on: push: @@ -6,7 +6,13 @@ on: - main paths: - 'docs/**' - - '.github/workflows/deploy-jan-docs.yml' + - '.github/workflows/jan-docs.yml' + pull_request: + branches: + - main + paths: + - 'docs/**' + - '.github/workflows/jan-docs.yml' # Review gh actions docs if you want to further define triggers, paths, etc # https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#on @@ -30,11 +36,13 @@ jobs: working-directory: docs - name: Add Custome Domain file + if: github.event_name == 'push' && github.event.pull_request.head.repo.full_name != github.repository run: echo "${{ vars.DOCUSAURUS_DOMAIN }}" > ./docs/build/CNAME # Popular action to deploy to GitHub Pages: # Docs: https://github.com/peaceiris/actions-gh-pages#%EF%B8%8F-docusaurus - name: Deploy to GitHub Pages + if: github.event_name == 'push' && github.event.pull_request.head.repo.full_name != github.repository uses: peaceiris/actions-gh-pages@v3 with: github_token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/build-app.yml b/.github/workflows/jan-electron-build.yml similarity index 99% rename from .github/workflows/build-app.yml rename to .github/workflows/jan-electron-build.yml index 38093eba8..8483df303 100644 --- a/.github/workflows/build-app.yml +++ b/.github/workflows/jan-electron-build.yml @@ -1,4 +1,4 @@ -name: Jan Build MacOS App +name: Jan Build Electron App on: push: diff --git a/.github/workflows/linter-and-test.yml b/.github/workflows/jan-electron-linter-and-test.yml similarity index 96% rename from .github/workflows/linter-and-test.yml rename to .github/workflows/jan-electron-linter-and-test.yml index c8c214faa..e9e3f091a 100644 --- a/.github/workflows/linter-and-test.yml +++ b/.github/workflows/jan-electron-linter-and-test.yml @@ -1,11 +1,11 @@ -name: Linter & Test +name: Jan Electron Linter & Test on: push: branches: - main paths: - 'electron/**' - - .github/workflows/linter-and-test.yml + - .github/workflows/jan-electron-linter-and-test.yml - 'web/**' - 'package.json' - 'node_modules/**' diff --git a/.github/workflows/publish-plugin-core.yml b/.github/workflows/jan-plugin-core.yml similarity index 84% rename from .github/workflows/publish-plugin-core.yml rename to .github/workflows/jan-plugin-core.yml index 0ce1f36e1..6ede3e2d2 100644 --- a/.github/workflows/publish-plugin-core.yml +++ b/.github/workflows/jan-plugin-core.yml @@ -1,11 +1,18 @@ -name: Publish plugin core Package to npmjs +name: Plugin Core on: push: branches: - main paths: - "core/**" - - ".github/workflows/publish-core.yml" + - ".github/workflows/jan-plugin-core.yml" + - "!core/package.json" + pull_request: + branches: + - main + paths: + - "core/**" + - ".github/workflows/jan-plugin-core.yml" - "!core/package.json" jobs: build-and-publish-plugins: @@ -50,11 +57,13 @@ jobs: - run: npm install && npm run build working-directory: ./core - run: npm publish --access public + if: github.event_name == 'push' && github.event.pull_request.head.repo.full_name != github.repository env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} working-directory: ./core - name: "Commit new version to main and create tag" + if: github.event_name == 'push' && github.event.pull_request.head.repo.full_name != github.repository run: | version=$(jq -r '.version' core/package.json) git config --global user.email "service@jan.ai" diff --git a/.github/workflows/publish-plugins.yml b/.github/workflows/jan-plugins.yml similarity index 86% rename from .github/workflows/publish-plugins.yml rename to .github/workflows/jan-plugins.yml index 1c4be6b0e..e1e303f64 100644 --- a/.github/workflows/publish-plugins.yml +++ b/.github/workflows/jan-plugins.yml @@ -1,11 +1,18 @@ -name: Publish plugins/$dir Package to npmjs +name: Jan Default Plugins on: push: branches: - main paths: - "plugins/**" - - ".github/workflows/publish-plugins.yml" + - ".github/workflows/jan-plugins.yml" + - "!plugins/*/package.json" + pull_request: + branches: + - main + paths: + - "plugins/**" + - ".github/workflows/jan-plugins.yml" - "!plugins/*/package.json" jobs: build: @@ -69,13 +76,16 @@ jobs: echo $dir cd $dir npm install && npm run build - npm publish --access public + if [[ $GITHUB_EVENT_NAME == 'push' && $GITHUB_EVENT_PULL_REQUEST_HEAD_REPO_FULL_NAME != $GITHUB_REPOSITORY ]]; then + npm publish --access public + fi cd .. done env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} - name: "Commit new version to main and create tag" + if: github.event_name == 'push' && github.event.pull_request.head.repo.full_name != github.repository run: | for dir in $(cat /tmp/change_dir.txt) do diff --git a/.github/workflows/quality-gate.yml b/.github/workflows/quality-gate.yml deleted file mode 100644 index f49f19abe..000000000 --- a/.github/workflows/quality-gate.yml +++ /dev/null @@ -1,39 +0,0 @@ -name: Linter & Sonarqube scanner -on: - push: - branches: - - main - pull_request: - branches: - - main - -jobs: - test-lint: - runs-on: ubuntu-latest - steps: - - name: Getting the repo - uses: actions/checkout@v2 - - - name: create sonar properties file - run: | - echo "Branch Name ${GITHUB_REF#refs/heads/}" - echo -e "sonar.sources = ." > sonar-project.properties - echo -e "sonar.projectKey = ${{ secrets.PROJECT_KEY }}" >> sonar-project.properties - if [[ "${{ github.event_name }}" == "push" ]]; then - echo -e "sonar.branch.name = ${GITHUB_REF#refs/heads/}" >> sonar-project.properties - fi - - - name: SonarQube Scan - uses: sonarsource/sonarqube-scan-action@master - env: - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }} - # Check the Quality Gate status. - - name: SonarQube Quality Gate check - id: sonarqube-quality-gate-check - uses: sonarsource/sonarqube-quality-gate-action@master - # Force to fail step after specific time. - timeout-minutes: 5 - env: - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }} #OPTIONAL diff --git a/plugins/data-plugin/package-lock.json b/plugins/data-plugin/package-lock.json index bf15e35b5..2e1cfb38b 100644 --- a/plugins/data-plugin/package-lock.json +++ b/plugins/data-plugin/package-lock.json @@ -1,12 +1,12 @@ { "name": "@janhq/data-plugin", - "version": "1.0.1", + "version": "1.0.3", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@janhq/data-plugin", - "version": "1.0.1", + "version": "1.0.3", "bundleDependencies": [ "pouchdb-node", "pouchdb-find" @@ -14,7 +14,7 @@ "hasInstallScript": true, "license": "MIT", "dependencies": { - "@janhq/core": "^0.1.1", + "@janhq/core": "^0.1.3", "pouchdb-find": "^8.0.1", "pouchdb-node": "^8.0.1" }, @@ -51,9 +51,9 @@ } }, "node_modules/@janhq/core": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/@janhq/core/-/core-0.1.1.tgz", - "integrity": "sha512-p6T+7gc7Bfwmef9Y+whdHxWAwdvcJ3psyni/sKgraLV4kuVIiGZuhcIrah/3PtTB2Jcoo5Sl4Cp51PC50xY2Tg==" + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/@janhq/core/-/core-0.1.3.tgz", + "integrity": "sha512-MZhNp6dPqd7pZaou81c+BBH5CXnyh9ZF2GH5ri+JNHiMs+LaZd1GlxQBzseWnaoVZWghOUI1hf8GxlrCdLb7ew==" }, "node_modules/@jridgewell/gen-mapping": { "version": "0.3.3", diff --git a/plugins/data-plugin/package.json b/plugins/data-plugin/package.json index a0cf1e301..a14c5a9b7 100644 --- a/plugins/data-plugin/package.json +++ b/plugins/data-plugin/package.json @@ -40,7 +40,7 @@ "node_modules" ], "dependencies": { - "@janhq/core": "^0.1.1", + "@janhq/core": "^0.1.3", "pouchdb-find": "^8.0.1", "pouchdb-node": "^8.0.1" } diff --git a/plugins/inference-plugin/package-lock.json b/plugins/inference-plugin/package-lock.json index d3ffbf4ba..e8a277f00 100644 --- a/plugins/inference-plugin/package-lock.json +++ b/plugins/inference-plugin/package-lock.json @@ -1,12 +1,12 @@ { "name": "@janhq/inference-plugin", - "version": "1.0.1", + "version": "1.0.4", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@janhq/inference-plugin", - "version": "1.0.1", + "version": "1.0.4", "bundleDependencies": [ "tcp-port-used", "kill-port-process" @@ -14,8 +14,9 @@ "hasInstallScript": true, "license": "MIT", "dependencies": { - "@janhq/core": "^0.1.1", + "@janhq/core": "^0.1.3", "kill-port-process": "^3.2.0", + "rxjs": "^7.8.1", "tcp-port-used": "^1.0.2", "ts-loader": "^9.5.0" }, @@ -39,9 +40,9 @@ } }, "node_modules/@janhq/core": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/@janhq/core/-/core-0.1.1.tgz", - "integrity": "sha512-p6T+7gc7Bfwmef9Y+whdHxWAwdvcJ3psyni/sKgraLV4kuVIiGZuhcIrah/3PtTB2Jcoo5Sl4Cp51PC50xY2Tg==" + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/@janhq/core/-/core-0.1.3.tgz", + "integrity": "sha512-MZhNp6dPqd7pZaou81c+BBH5CXnyh9ZF2GH5ri+JNHiMs+LaZd1GlxQBzseWnaoVZWghOUI1hf8GxlrCdLb7ew==" }, "node_modules/@jridgewell/gen-mapping": { "version": "0.3.3", @@ -3026,6 +3027,14 @@ "url": "https://github.com/sponsors/isaacs" } }, + "node_modules/rxjs": { + "version": "7.8.1", + "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-7.8.1.tgz", + "integrity": "sha512-AA3TVj+0A2iuIoQkWEK/tqFjBq2j+6PO6Y0zJcvzLAFhEFIO3HL0vls9hWLncZbAAbK0mar7oZ4V079I/qPMxg==", + "dependencies": { + "tslib": "^2.1.0" + } + }, "node_modules/safe-buffer": { "version": "5.2.1", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", @@ -3725,6 +3734,11 @@ "node": ">=8.0" } }, + "node_modules/tslib": { + "version": "2.6.2", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.2.tgz", + "integrity": "sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==" + }, "node_modules/typescript": { "version": "5.2.2", "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.2.2.tgz", diff --git a/plugins/inference-plugin/package.json b/plugins/inference-plugin/package.json index 01740d5a6..7fcb892c6 100644 --- a/plugins/inference-plugin/package.json +++ b/plugins/inference-plugin/package.json @@ -26,7 +26,7 @@ "webpack-cli": "^5.1.4" }, "dependencies": { - "@janhq/core": "^0.1.2", + "@janhq/core": "^0.1.3", "kill-port-process": "^3.2.0", "rxjs": "^7.8.1", "tcp-port-used": "^1.0.2", diff --git a/plugins/model-management-plugin/package-lock.json b/plugins/model-management-plugin/package-lock.json index a9df23628..db5391709 100644 --- a/plugins/model-management-plugin/package-lock.json +++ b/plugins/model-management-plugin/package-lock.json @@ -1,20 +1,16 @@ { "name": "@janhq/model-management-plugin", - "version": "1.0.1", + "version": "1.0.4", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@janhq/model-management-plugin", - "version": "1.0.1", - "bundleDependencies": [ - "@huggingface/hub" - ], + "version": "1.0.4", "hasInstallScript": true, "license": "MIT", "dependencies": { - "@huggingface/hub": "^0.8.5", - "@janhq/core": "^0.1.1", + "@janhq/core": "^0.1.3", "ts-loader": "^9.5.0" }, "devDependencies": { @@ -33,22 +29,10 @@ "node": ">=10.0.0" } }, - "node_modules/@huggingface/hub": { - "version": "0.8.6", - "resolved": "https://registry.npmjs.org/@huggingface/hub/-/hub-0.8.6.tgz", - "integrity": "sha512-V2f1+BiBd3PIRYkEjvjrqJuCWqZQniaHMYcNvwB+PcubvEECkmgBt3tvXMpNUK4M27YK1RjflQbCVXSZMuQeow==", - "inBundle": true, - "dependencies": { - "hash-wasm": "^4.9.0" - }, - "engines": { - "node": ">=18" - } - }, "node_modules/@janhq/core": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/@janhq/core/-/core-0.1.1.tgz", - "integrity": "sha512-p6T+7gc7Bfwmef9Y+whdHxWAwdvcJ3psyni/sKgraLV4kuVIiGZuhcIrah/3PtTB2Jcoo5Sl4Cp51PC50xY2Tg==" + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/@janhq/core/-/core-0.1.3.tgz", + "integrity": "sha512-MZhNp6dPqd7pZaou81c+BBH5CXnyh9ZF2GH5ri+JNHiMs+LaZd1GlxQBzseWnaoVZWghOUI1hf8GxlrCdLb7ew==" }, "node_modules/@jridgewell/gen-mapping": { "version": "0.3.3", @@ -1397,12 +1381,6 @@ "node": ">=0.10.0" } }, - "node_modules/hash-wasm": { - "version": "4.9.0", - "resolved": "https://registry.npmjs.org/hash-wasm/-/hash-wasm-4.9.0.tgz", - "integrity": "sha512-7SW7ejyfnRxuOc7ptQHSf4LDoZaWOivfzqw+5rpcQku0nHfmicPKE51ra9BiRLAmT8+gGLestr1XroUkqdjL6w==", - "inBundle": true - }, "node_modules/import-local": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/import-local/-/import-local-3.1.0.tgz", diff --git a/plugins/model-management-plugin/package.json b/plugins/model-management-plugin/package.json index 264fef6a6..310f8f3bd 100644 --- a/plugins/model-management-plugin/package.json +++ b/plugins/model-management-plugin/package.json @@ -27,7 +27,7 @@ "README.md" ], "dependencies": { - "@janhq/core": "^0.1.2", + "@janhq/core": "^0.1.3", "ts-loader": "^9.5.0" } } diff --git a/plugins/monitoring-plugin/package-lock.json b/plugins/monitoring-plugin/package-lock.json index c2f26fe9b..f9cb36683 100644 --- a/plugins/monitoring-plugin/package-lock.json +++ b/plugins/monitoring-plugin/package-lock.json @@ -1,19 +1,19 @@ { "name": "@janhq/monitoring-plugin", - "version": "1.0.1", + "version": "1.0.3", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@janhq/monitoring-plugin", - "version": "1.0.1", + "version": "1.0.3", "bundleDependencies": [ "systeminformation" ], "hasInstallScript": true, "license": "MIT", "dependencies": { - "@janhq/core": "^0.1.1", + "@janhq/core": "^0.1.3", "systeminformation": "^5.21.8", "ts-loader": "^9.5.0" }, @@ -33,9 +33,9 @@ } }, "node_modules/@janhq/core": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/@janhq/core/-/core-0.1.1.tgz", - "integrity": "sha512-p6T+7gc7Bfwmef9Y+whdHxWAwdvcJ3psyni/sKgraLV4kuVIiGZuhcIrah/3PtTB2Jcoo5Sl4Cp51PC50xY2Tg==" + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/@janhq/core/-/core-0.1.3.tgz", + "integrity": "sha512-MZhNp6dPqd7pZaou81c+BBH5CXnyh9ZF2GH5ri+JNHiMs+LaZd1GlxQBzseWnaoVZWghOUI1hf8GxlrCdLb7ew==" }, "node_modules/@jridgewell/gen-mapping": { "version": "0.3.3", diff --git a/plugins/monitoring-plugin/package.json b/plugins/monitoring-plugin/package.json index f7195daec..12267c664 100644 --- a/plugins/monitoring-plugin/package.json +++ b/plugins/monitoring-plugin/package.json @@ -21,7 +21,7 @@ "webpack-cli": "^5.1.4" }, "dependencies": { - "@janhq/core": "^0.1.1", + "@janhq/core": "^0.1.3", "systeminformation": "^5.21.8", "ts-loader": "^9.5.0" }, diff --git a/plugins/openai-plugin/package.json b/plugins/openai-plugin/package.json index b2470ed89..945fc9d5f 100644 --- a/plugins/openai-plugin/package.json +++ b/plugins/openai-plugin/package.json @@ -26,7 +26,7 @@ "webpack-cli": "^5.1.4" }, "dependencies": { - "@janhq/core": "^0.1.1", + "@janhq/core": "^0.1.3", "azure-openai": "^0.9.4", "kill-port-process": "^3.2.0", "tcp-port-used": "^1.0.2", diff --git a/yarn.lock b/yarn.lock index bcdd83ba8..10c090407 100644 --- a/yarn.lock +++ b/yarn.lock @@ -194,10 +194,10 @@ resolved "https://registry.npmjs.org/@isaacs/string-locale-compare/-/string-locale-compare-1.1.0.tgz" integrity sha512-SQ7Kzhh9+D+ZW9MA0zkYv3VXhIDNx+LzM6EJ+/65I3QY+enU6Itte7E5XX7EWrqLW2FN4n06GWzBnPoC3th2aQ== -"@janhq/plugin-core@^0.1.8": - version "0.1.8" - resolved "https://registry.yarnpkg.com/@janhq/plugin-core/-/plugin-core-0.1.8.tgz#abd61ce05831ee03f16be1f4d18512cfb22ebb4e" - integrity sha512-wJe+8ndMQLGLSV36Jt1V3s5lmH+nQw87ol2NMhHuVWXfwf+DAO1GTdTeHfemHWdcB/oUY1HVRvsNh8DvBgbh/w== +"@janhq/core@^0.1.2": + version "0.1.3" + resolved "https://registry.yarnpkg.com/@janhq/core/-/core-0.1.3.tgz#9315bc19c692183e64ada17b85276c629df91eb4" + integrity sha512-MZhNp6dPqd7pZaou81c+BBH5CXnyh9ZF2GH5ri+JNHiMs+LaZd1GlxQBzseWnaoVZWghOUI1hf8GxlrCdLb7ew== "@jridgewell/gen-mapping@^0.3.2": version "0.3.3"