build(web-app): add tests to gitlab ci

This commit is contained in:
fastium
2025-06-08 21:38:03 +02:00
parent c5efa10f1a
commit 25cefc611f
2 changed files with 30 additions and 1 deletions

View File

@@ -1,6 +1,7 @@
stages: stages:
- gateway-build - gateway-build
- web-app-build - web-app-build
- web-app-tests
include: include:
- local: gateway/.gitlab-ci.yml - local: gateway/.gitlab-ci.yml

View File

@@ -1,11 +1,13 @@
variables: variables:
DOCKER_IMAGE: registry.forge.hefr.ch/team-raclette/project-softweng/web-app:latest DOCKER_IMAGE: registry.forge.hefr.ch/team-raclette/project-softweng/web-app:latest
NODE_IMAGE: cypress/included:cypress-14.4.1-node-22.16.0-chrome-137.0.7151.68-1-ff-139.0.1-edge-137.0.3296.62-1
default: default:
image: $DOCKER_IMAGE image: $DOCKER_IMAGE
stages: stages:
- web-app-build - web-app-build
- web-app-tests
web-app-docker-build: web-app-docker-build:
image: docker:latest image: docker:latest
@@ -20,3 +22,29 @@ web-app-docker-build:
- if: $CI_PIPELINE_SOURCE == 'merge_request_event' && $CI_COMMIT_BRANCH == 'main' - if: $CI_PIPELINE_SOURCE == 'merge_request_event' && $CI_COMMIT_BRANCH == 'main'
- changes: - changes:
- web-app/* - web-app/*
web-app-unit-tests:
image: $NODE_IMAGE
stage: web-app-tests
script:
- echo "Running unit tests"
- cd ./web-app
- npm install --include=dev
- npm run test:unit
web-app-e2e-tests:
image: $NODE_IMAGE
stage: web-app-tests
services:
- name: $DOCKER_IMAGE
alias: app
script:
- echo "Running e2e tests"
- apt-get update
- apt-get install curl
- cd ./web-app
- npm install --include=dev
- echo "Wait web-app app is running"
- for i in {1..6}; do curl -f http://app:8080 && break || sleep 5; done
- echo "Flask app is running"
- npm run test:e2e