Files
livecampus_mcs_p_2027_2/Semaine_13/Jour_03/.gitlab-ci.yml
T
2026-09-04 17:25:11 +02:00

108 lines
2.0 KiB
YAML

stages:
- install
- scan
- test
- build&deploy
# Install JavaScript dependencies
frontend_install:
stage: install
image: node:latest
script:
- npm install
cache:
key:
files:
- package-lock.json
paths:
- node_modules/
# Scan project (linter & security)
eslint_1_4:
stage: scan
image: node:lts
cache:
key:
files:
- package-lock.json
paths:
- node_modules/
script:
- npm run lint
variables:
SONAR_USER_HOME: "${CI_PROJECT_DIR}/.sonar" # Defines the location of the analysis task cache
GIT_DEPTH: "0" # Tells git to fetch all the branches of the project, required by the analysis task
sonarcloud-check:
stage: scan
image:
name: sonarsource/sonar-scanner-cli:latest
entrypoint: [""]
cache:
- key: "${CI_JOB_NAME}"
paths:
- .sonar/cache
- key:
files:
- package-lock.json
paths:
- node_modules/
script:
- sonar-scanner
# Test project (functiunality & charge)
jest_3_4:
stage: test
image: node:lts
cache:
key:
files:
- package-lock.json
paths:
- node_modules/
dependencies:
- sonarcloud-check
script:
- npm run test
cypress_4_4:
stage: test
image: cypress/browsers:latest
dependencies:
- jest_3_4
script:
- npm install
- npm run dev &
- npx cypress run --browser firefox --spec "cypress/e2e/experience.cy.js"
- npx cypress run --browser chrome --spec "cypress/e2e/experience.cy.js"
# Build & Deploy project
pages:
stage: build&deploy
image: node:lts
cache:
key:
files:
- package-lock.json
paths:
- node_modules/
script:
- npm run build
- mv build public
artifacts:
paths:
# The folder that contains the files to be exposed at the Page URL
- public
rules:
# This ensures that only pushes to the default branch will trigger
# a pages deploy
- if: $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "preprod"