From bcc719cec635cdbd246e1e4cccf01ae1684351ba Mon Sep 17 00:00:00 2001 From: Ghian Date: Sat, 18 Jan 2025 12:47:19 +0800 Subject: [PATCH] ci: add build workflow for client (#107) * ci: add build workflow for client - Implemented a GitHub Actions workflow for building the client application. - Ensures that changes to the client are validated through automated builds. * fix: cd to client directory * fix: remove updated at UserDTO property * fix: resolve config plugin overload --- .github/workflows/client-build.yaml | 37 +++++++++++++++++++++++++ .github/workflows/client-test.yaml | 2 +- client/package-lock.json | 6 ++-- client/src/lib/services/sign-in.test.ts | 1 - client/vite.config.ts | 14 ++++++++-- 5 files changed, 52 insertions(+), 8 deletions(-) create mode 100644 .github/workflows/client-build.yaml diff --git a/.github/workflows/client-build.yaml b/.github/workflows/client-build.yaml new file mode 100644 index 0000000..de7cb61 --- /dev/null +++ b/.github/workflows/client-build.yaml @@ -0,0 +1,37 @@ +name: Client - Build + +on: + pull_request: + branches: + - develop + workflow_dispatch: + +jobs: + build: + name: Build Application + runs-on: ubuntu-latest + + steps: + - name: Checkout Code + uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: 18 + + - name: Install Dependencies + run: | + cd client + npm ci --cache .npm --prefer-offline + + - name: Run Build + run: | + cd client + npm run build + + - name: Upload Build Artifact + uses: actions/upload-artifact@v4 + with: + name: client-app + path: app diff --git a/.github/workflows/client-test.yaml b/.github/workflows/client-test.yaml index a7da4b1..4a5044d 100644 --- a/.github/workflows/client-test.yaml +++ b/.github/workflows/client-test.yaml @@ -22,7 +22,7 @@ jobs: - name: Install dependencies run: | cd client - npm install + npm ci --cache .npm --prefer-offline - name: Run vitest run: | diff --git a/client/package-lock.json b/client/package-lock.json index eb46b1b..727b401 100644 --- a/client/package-lock.json +++ b/client/package-lock.json @@ -3558,9 +3558,9 @@ } }, "node_modules/nanoid": { - "version": "3.3.7", - "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.7.tgz", - "integrity": "sha512-eSRppjcPIatRIMC1U6UngP8XFcz8MQWGQdt1MTBQ7NaAmvXDfvNxbvWV3x2y6CdEUciCSsDHDQZbhYaB8QEo2g==", + "version": "3.3.8", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.8.tgz", + "integrity": "sha512-WNLf5Sd8oZxOm+TzppcYk8gVOgP+l58xNy58D0nbUnOxOWRWvlcCV4kUF7ltmI6PsrLl/BgKEyS4mqsGChFN0w==", "dev": true, "funding": [ { diff --git a/client/src/lib/services/sign-in.test.ts b/client/src/lib/services/sign-in.test.ts index 7308d0d..bf8c3bb 100644 --- a/client/src/lib/services/sign-in.test.ts +++ b/client/src/lib/services/sign-in.test.ts @@ -19,7 +19,6 @@ const user: UserDTO = { last_signed_in: new Date(), is_verified: false, created_at: new Date(), - updated_at: new Date(), }; describe("signIn", () => { diff --git a/client/vite.config.ts b/client/vite.config.ts index d6ec937..5a3384e 100644 --- a/client/vite.config.ts +++ b/client/vite.config.ts @@ -1,17 +1,25 @@ +import { defineConfig as testConfig } from "vitest/config"; +import { defineConfig as viteConfig } from "vite"; import react from "@vitejs/plugin-react-swc"; -import { defineConfig } from "vitest/config"; import path from "path"; -// https://vitejs.dev/config/ -export default defineConfig({ +const defineViteConfig = viteConfig({ plugins: [react()], resolve: { alias: { "@": path.resolve(__dirname, "src"), }, }, +}); + +const defineTestConfig = testConfig({ test: { globals: true, environment: "jsdom", }, }); + +export default { + ...defineViteConfig, + ...defineTestConfig, +};