From 2de7fe7098f555622bb47e8f712eba5d2d6d37d7 Mon Sep 17 00:00:00 2001 From: l-silvestre <43357028+l-silvestre@users.noreply.github.com> Date: Thu, 11 May 2023 23:26:16 +0100 Subject: [PATCH 1/9] chore: update pipelines --- .github/workflows/deployment.yml | 4 ---- .github/workflows/development.yml | 7 +++---- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/.github/workflows/deployment.yml b/.github/workflows/deployment.yml index 391d1710..a1b4d3f0 100644 --- a/.github/workflows/deployment.yml +++ b/.github/workflows/deployment.yml @@ -30,10 +30,6 @@ jobs: uses: actions/checkout@v3 - name: Setup Pages uses: actions/configure-pages@v3 - - name: Upload artifact - uses: actions/upload-pages-artifact@v1 - with: - path: './client/dist/' - name: Deploy to GitHub Pages id: deployment uses: actions/deploy-pages@v2 diff --git a/.github/workflows/development.yml b/.github/workflows/development.yml index f13903e7..aa157b13 100644 --- a/.github/workflows/development.yml +++ b/.github/workflows/development.yml @@ -108,10 +108,9 @@ jobs: env: NODE_OPTIONS: "--max_old_space_size=4096" run: cd client && npm run build - - name: Upload Build artifacts - uses: actions/upload-artifact@v3.1.2 + - name: Upload Build artifacts For Pages + uses: actions/upload-pages-artifact@v1 with: - name: Build artifacts path: ./client/dist/ test: @@ -134,5 +133,5 @@ jobs: with: path: ./client/node_modules key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package.json') }} - - name: Build + - name: Test With Coverage run: cd client && npm run test:cov From 377f216afa22db7de4c4042f502e85fe9b58a0f4 Mon Sep 17 00:00:00 2001 From: l-silvestre <43357028+l-silvestre@users.noreply.github.com> Date: Thu, 11 May 2023 23:42:04 +0100 Subject: [PATCH 2/9] fix: update pipelines --- .github/workflows/deployment.yml | 8 ++++++++ .github/workflows/development.yml | 4 ++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deployment.yml b/.github/workflows/deployment.yml index a1b4d3f0..6cb25cce 100644 --- a/.github/workflows/deployment.yml +++ b/.github/workflows/deployment.yml @@ -28,6 +28,14 @@ jobs: steps: - name: Checkout uses: actions/checkout@v3 + - uses: actions/download-artifact@v3 + with: + name: dist-artifact + path: './client/dist/' + - name: Upload artifact + uses: actions/upload-pages-artifact@v1 + with: + path: './client/dist/' - name: Setup Pages uses: actions/configure-pages@v3 - name: Deploy to GitHub Pages diff --git a/.github/workflows/development.yml b/.github/workflows/development.yml index aa157b13..ea9cf28c 100644 --- a/.github/workflows/development.yml +++ b/.github/workflows/development.yml @@ -108,9 +108,9 @@ jobs: env: NODE_OPTIONS: "--max_old_space_size=4096" run: cd client && npm run build - - name: Upload Build artifacts For Pages - uses: actions/upload-pages-artifact@v1 + - uses: actions/upload-artifact@v3 with: + name: dist-artifact path: ./client/dist/ test: From 8dd0fb98156c311654fd07c5879ff7fc27e263c5 Mon Sep 17 00:00:00 2001 From: l-silvestre <43357028+l-silvestre@users.noreply.github.com> Date: Thu, 11 May 2023 23:52:49 +0100 Subject: [PATCH 3/9] fix: update pipelines --- .github/workflows/deployment.yml | 20 +++++++++++++++++--- .github/workflows/development.yml | 6 +----- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/.github/workflows/deployment.yml b/.github/workflows/deployment.yml index 6cb25cce..02c15b2a 100644 --- a/.github/workflows/deployment.yml +++ b/.github/workflows/deployment.yml @@ -25,13 +25,27 @@ jobs: name: github-pages url: ${{ steps.deployment.outputs.page_url }} runs-on: ubuntu-latest + strategy: + matrix: + node-version: [18.x] steps: - name: Checkout uses: actions/checkout@v3 - - uses: actions/download-artifact@v3 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v3 with: - name: dist-artifact - path: './client/dist/' + node-version: ${{ matrix.node-version }} + - name: Load Cache + uses: actions/cache@v3 + env: + cache-name: cache-deps + with: + path: ./client/node_modules + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package.json') }} + - name: Build + env: + NODE_OPTIONS: "--max_old_space_size=4096" + run: cd client && npm run build - name: Upload artifact uses: actions/upload-pages-artifact@v1 with: diff --git a/.github/workflows/development.yml b/.github/workflows/development.yml index ea9cf28c..a0db8a3b 100644 --- a/.github/workflows/development.yml +++ b/.github/workflows/development.yml @@ -108,11 +108,7 @@ jobs: env: NODE_OPTIONS: "--max_old_space_size=4096" run: cd client && npm run build - - uses: actions/upload-artifact@v3 - with: - name: dist-artifact - path: ./client/dist/ - + test: needs: [build-and-install-deps] runs-on: ubuntu-latest From 75e1c68d7e061a55391a61bf690854cd1f235576 Mon Sep 17 00:00:00 2001 From: l-silvestre <43357028+l-silvestre@users.noreply.github.com> Date: Fri, 12 May 2023 00:02:53 +0100 Subject: [PATCH 4/9] fix: update deploy pipeline to install files instead of using cache --- .github/workflows/deployment.yml | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/.github/workflows/deployment.yml b/.github/workflows/deployment.yml index 02c15b2a..93d23d48 100644 --- a/.github/workflows/deployment.yml +++ b/.github/workflows/deployment.yml @@ -35,13 +35,8 @@ jobs: uses: actions/setup-node@v3 with: node-version: ${{ matrix.node-version }} - - name: Load Cache - uses: actions/cache@v3 - env: - cache-name: cache-deps - with: - path: ./client/node_modules - key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package.json') }} + - name: Install Dependencies + run: cd client && npm install - name: Build env: NODE_OPTIONS: "--max_old_space_size=4096" From be7a793b68695ea4af131844f0f08fcad2b6dc00 Mon Sep 17 00:00:00 2001 From: l-silvestre <43357028+l-silvestre@users.noreply.github.com> Date: Fri, 12 May 2023 13:14:22 +0100 Subject: [PATCH 5/9] fix: update deploy script to remove old manifest files and check for wallet in workspace --- client/scripts/deploy.ts | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/client/scripts/deploy.ts b/client/scripts/deploy.ts index 7bb71637..8ef923b1 100644 --- a/client/scripts/deploy.ts +++ b/client/scripts/deploy.ts @@ -4,6 +4,11 @@ import Bundlr from 'bundlr-custom'; import fs from 'fs'; const main = async () => { + + if (!fs.existsSync('./wallet.json')) { + console.log('No wallet file found, please add a wallet.json file to the root of the project'); + return; + } const wallet = './wallet.json'; const jwk = JSON.parse(fs.readFileSync(wallet).toString()); @@ -25,10 +30,28 @@ const main = async () => { // Print your wallet address console.log(`wallet address = ${bundlr.address}`); const dist = './dist/'; + + try { + if (fs.existsSync('dist-id.txt')) { + fs.rmSync('dist-id.txt'); + } + if (fs.existsSync('dist-manifest.csv')) { + fs.rmSync('dist-manifest.csv'); + } + if (fs.existsSync('dist-manifest.json')) { + fs.rmSync('dist-manifest.json'); + } + } catch (error) { + // files not found skip + console.log('No previous deploy files found, skipping'); + } + console.log('uploading'); + const response = await bundlr.uploadFolder(dist, { indexFile: 'index.html', // optional index file (file the user will load when accessing the manifest) - batchSize: 50, // number of items to upload at once - keepDeleted: false // whether to keep now deleted items from previous uploads + batchSize: 50, // number of items to upload at once, + keepDeleted: false, // keep deleted files in the manifest + logFunction: async (log: string) => console.log(log), // optional function to handle logs }); // returns the manifest ID console.log(`SPA Uploaded https://arweave.net/${response?.id}`); From da7ac17cecfa4860e3ec9153b97ac1277da63908 Mon Sep 17 00:00:00 2001 From: l-silvestre <43357028+l-silvestre@users.noreply.github.com> Date: Fri, 12 May 2023 13:15:21 +0100 Subject: [PATCH 6/9] chore: [skip ci] update vite config to use different config when in ci workflow --- .github/workflows/deployment.yml | 1 + client/vite.config.ts | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/deployment.yml b/.github/workflows/deployment.yml index 93d23d48..f0d6a849 100644 --- a/.github/workflows/deployment.yml +++ b/.github/workflows/deployment.yml @@ -40,6 +40,7 @@ jobs: - name: Build env: NODE_OPTIONS: "--max_old_space_size=4096" + CI: true run: cd client && npm run build - name: Upload artifact uses: actions/upload-pages-artifact@v1 diff --git a/client/vite.config.ts b/client/vite.config.ts index fc979d15..6acfc712 100644 --- a/client/vite.config.ts +++ b/client/vite.config.ts @@ -4,9 +4,10 @@ import tsconfigPaths from 'vite-tsconfig-paths'; import { nodePolyfills } from 'vite-plugin-node-polyfills'; import eslint from 'vite-plugin-eslint'; +const ci = process.env.CI ?? false; // https://vitejs.dev/config/ export default defineConfig({ - base: './', + base: ci ? '/decentralized-inference' : './', plugins: [react(), tsconfigPaths(), nodePolyfills({ protocolImports: true }), eslint()], optimizeDeps: {disabled: false}, build: { From 805736a8ac29a449cea5500807d2b4e891230c5d Mon Sep 17 00:00:00 2001 From: l-silvestre <43357028+l-silvestre@users.noreply.github.com> Date: Fri, 12 May 2023 14:31:46 +0100 Subject: [PATCH 7/9] test: test update build path for ci [skip ci] --- client/vite.config.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/vite.config.ts b/client/vite.config.ts index 6acfc712..01dfa272 100644 --- a/client/vite.config.ts +++ b/client/vite.config.ts @@ -7,7 +7,7 @@ import eslint from 'vite-plugin-eslint'; const ci = process.env.CI ?? false; // https://vitejs.dev/config/ export default defineConfig({ - base: ci ? '/decentralized-inference' : './', + base: ci ? './decentralized-inference/' : './', plugins: [react(), tsconfigPaths(), nodePolyfills({ protocolImports: true }), eslint()], optimizeDeps: {disabled: false}, build: { From 3c342e9d7bfa069a5e3fcbffcf98169d04a5d5fc Mon Sep 17 00:00:00 2001 From: l-silvestre <43357028+l-silvestre@users.noreply.github.com> Date: Fri, 12 May 2023 14:40:56 +0100 Subject: [PATCH 8/9] fix: change base path for ci build [skip ci] --- client/vite.config.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/client/vite.config.ts b/client/vite.config.ts index 01dfa272..f1aded7b 100644 --- a/client/vite.config.ts +++ b/client/vite.config.ts @@ -5,9 +5,10 @@ import { nodePolyfills } from 'vite-plugin-node-polyfills'; import eslint from 'vite-plugin-eslint'; const ci = process.env.CI ?? false; + // https://vitejs.dev/config/ export default defineConfig({ - base: ci ? './decentralized-inference/' : './', + base: ci ? '/decentralized-inference/' : './', plugins: [react(), tsconfigPaths(), nodePolyfills({ protocolImports: true }), eslint()], optimizeDeps: {disabled: false}, build: { From 8ff82e4c33eb42be2426a1a5f681453a69a1ecba Mon Sep 17 00:00:00 2001 From: l-silvestre <43357028+l-silvestre@users.noreply.github.com> Date: Fri, 12 May 2023 14:51:01 +0100 Subject: [PATCH 9/9] fix: vite config update [skip ci] --- client/vite.config.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/client/vite.config.ts b/client/vite.config.ts index f1aded7b..fc979d15 100644 --- a/client/vite.config.ts +++ b/client/vite.config.ts @@ -4,11 +4,9 @@ import tsconfigPaths from 'vite-tsconfig-paths'; import { nodePolyfills } from 'vite-plugin-node-polyfills'; import eslint from 'vite-plugin-eslint'; -const ci = process.env.CI ?? false; - // https://vitejs.dev/config/ export default defineConfig({ - base: ci ? '/decentralized-inference/' : './', + base: './', plugins: [react(), tsconfigPaths(), nodePolyfills({ protocolImports: true }), eslint()], optimizeDeps: {disabled: false}, build: {