diff --git a/.github/workflows/people.yml b/.github/workflows/people.yml index 5638572..d74211c 100644 --- a/.github/workflows/people.yml +++ b/.github/workflows/people.yml @@ -75,30 +75,56 @@ jobs: - name: Install dependencies run: yarn install --frozen-lockfile - name: Test Desk App - env: - CI: true run: yarn test - build-front-desk: + test-e2e: runs-on: ubuntu-latest - env: - NEXT_PUBLIC_API_URL: http://localhost:8071/api/v1.0/ - defaults: - run: - working-directory: src/frontend/apps/desk + steps: - name: Checkout repository uses: actions/checkout@v4 + + - name: Set services env variables + run: | + make create-env-files + + - name: Build and Start Docker Servers + env: + DOCKER_BUILDKIT: 1 + COMPOSE_DOCKER_CLI_BUILD: 1 + run: | + docker-compose build --pull --build-arg BUILDKIT_INLINE_CACHE=1 + make run + + - name: Apply DRH migrations + run: | + make migrate + - name: Setup Node.js uses: actions/setup-node@v4 with: node-version: '18.x' cache: 'yarn' - cache-dependency-path: src/frontend/apps/desk/yarn.lock + cache-dependency-path: src/frontend/yarn.lock + - name: Install dependencies - run: yarn install --frozen-lockfile - - name: Build Desk App - run: yarn build + run: cd src/frontend/ && yarn install --frozen-lockfile + + - name: Install Playwright Browsers + run: cd src/frontend/apps/e2e && yarn install + + - name: Build CI App + run: cd src/frontend/ && yarn ci:build + + - name: Run e2e tests + run: cd src/frontend/ && yarn e2e:test + + - uses: actions/upload-artifact@v3 + if: always() + with: + name: playwright-report + path: src/frontend/apps/e2e/report/ + retention-days: 7 build-mails: runs-on: ubuntu-latest diff --git a/Makefile b/Makefile index 1b3c313..42f8cb7 100644 --- a/Makefile +++ b/Makefile @@ -68,14 +68,19 @@ data/static: # -- Project +create-env-files: ## Copy the dist env files to env files +create-env-files: \ + env.d/development/common \ + env.d/development/crowdin \ + env.d/development/postgresql \ + env.d/development/kc_postgresql +.PHONY: create-env-files + bootstrap: ## Prepare Docker images for the project and install frontend dependencies bootstrap: \ data/media \ data/static \ - env.d/development/common \ - env.d/development/crowdin \ - env.d/development/postgresql \ - env.d/development/kc_postgresql \ + create-env-files \ build \ run \ migrate \ diff --git a/docker/auth/realm.json b/docker/auth/realm.json index 11c654a..42213bb 100644 --- a/docker/auth/realm.json +++ b/docker/auth/realm.json @@ -56,6 +56,19 @@ "realmRoles": [ "user" ] + }, + { + "username": "user-e2e", + "enabled": true, + "credentials": [ + { + "type": "password", + "value": "password-e2e" + } + ], + "realmRoles": [ + "user" + ] } ], "roles": { @@ -2259,4 +2272,5 @@ "clientPolicies": { "policies": [] } - } \ No newline at end of file + } + \ No newline at end of file diff --git a/src/frontend/apps/desk/.env.development b/src/frontend/apps/desk/.env.development index e636370..f661e98 100644 --- a/src/frontend/apps/desk/.env.development +++ b/src/frontend/apps/desk/.env.development @@ -2,3 +2,4 @@ NEXT_PUBLIC_API_URL=http://localhost:8071/api/v1.0/ NEXT_PUBLIC_KEYCLOAK_URL=http://localhost:8080/ NEXT_PUBLIC_KEYCLOAK_REALM=people NEXT_PUBLIC_KEYCLOAK_CLIENT_ID=people-front +NEXT_PUBLIC_KEYCLOAK_LOGIN=true diff --git a/src/frontend/apps/desk/package.json b/src/frontend/apps/desk/package.json index 1b554d6..2c67947 100644 --- a/src/frontend/apps/desk/package.json +++ b/src/frontend/apps/desk/package.json @@ -5,6 +5,7 @@ "scripts": { "dev": "next dev", "build": "prettier --check . && yarn stylelint && next build", + "build:ci": "cp .env.development .env.local && yarn build", "build-theme": "cunningham -g css,ts -o src/cunningham --utility-classes", "start": "next start", "lint": "next lint", diff --git a/src/frontend/apps/desk/src/auth/useAuthStore.tsx b/src/frontend/apps/desk/src/auth/useAuthStore.tsx index 2e4c3c3..342624a 100644 --- a/src/frontend/apps/desk/src/auth/useAuthStore.tsx +++ b/src/frontend/apps/desk/src/auth/useAuthStore.tsx @@ -16,7 +16,7 @@ const useAuthStore = create((set) => ({ initAuth: () => set((state) => { - if (process.env.NODE_ENV === 'development' && !state.initialized) { + if (process.env.NEXT_PUBLIC_KEYCLOAK_LOGIN && !state.initialized) { initKeycloak((token) => set({ authenticated: true, token })); return { initialized: true }; } diff --git a/src/frontend/apps/e2e/playwright.config.ts b/src/frontend/apps/e2e/playwright.config.ts index f1b878b..d0c927c 100644 --- a/src/frontend/apps/e2e/playwright.config.ts +++ b/src/frontend/apps/e2e/playwright.config.ts @@ -32,7 +32,7 @@ export default defineConfig({ }, webServer: { - command: 'cd ../.. && yarn dev:desk --port ' + PORT, + command: `cd ../.. && yarn app:${process.env.CI ? "start" : "dev"} --port ${PORT}`, url: baseURL, timeout: 120 * 1000, reuseExistingServer: !process.env.CI, diff --git a/src/frontend/package.json b/src/frontend/package.json index 84924f1..9337f13 100644 --- a/src/frontend/package.json +++ b/src/frontend/package.json @@ -14,6 +14,7 @@ "app:start": "yarn APP_DESK run start", "app:build": "yarn APP_DESK run build", "app:test": "yarn APP_DESK run test", + "ci:build": "yarn APP_DESK run build:ci", "e2e:test": "yarn APP_E2E run test" }, "resolutions": {