👷(CI) add test-e2e job to people.yml

Add test-e2e to people.yml, it will run e2e tests on every PR.
Steps:
  - set env vars for e2e tests
  - build and start docker servers
  (backend, keycloak, DB)
  - install playwright
  - build apps
  - run e2e tests
  - save reports
This commit is contained in:
Anthony LC
2024-01-11 17:06:25 +01:00
committed by Anthony LC
parent 5f280ae3fc
commit da851f508a
8 changed files with 67 additions and 19 deletions

View File

@@ -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

View File

@@ -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 \

View File

@@ -56,6 +56,19 @@
"realmRoles": [
"user"
]
},
{
"username": "user-e2e",
"enabled": true,
"credentials": [
{
"type": "password",
"value": "password-e2e"
}
],
"realmRoles": [
"user"
]
}
],
"roles": {
@@ -2260,3 +2273,4 @@
"policies": []
}
}

View File

@@ -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

View File

@@ -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",

View File

@@ -16,7 +16,7 @@ const useAuthStore = create<AuthStore>((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 };
}

View File

@@ -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,

View File

@@ -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": {