Files
MSE-SoftwEng/web-app/.gitlab-ci.yml
2025-06-08 22:31:46 +02:00

51 lines
1.3 KiB
YAML

variables:
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:
image: $DOCKER_IMAGE
stages:
- web-app-build
- web-app-tests
web-app-docker-build:
image: docker:latest
stage: web-app-build
services:
- docker:dind
script:
- docker build -t $DOCKER_IMAGE -f web-app/Dockerfile .
- echo $CI_REGISTRY_PASSWORD | docker login -u $CI_REGISTRY_USER --password-stdin $CI_REGISTRY
- docker push $DOCKER_IMAGE
rules:
- if: $CI_PIPELINE_SOURCE == 'merge_request_event' && $CI_COMMIT_BRANCH == 'main'
- changes:
- 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