91 lines
2.5 KiB
YAML
91 lines
2.5 KiB
YAML
image: tools-registry.esy-web.dev/mainframe/mainframe:php # Utilisation de l'image Docker spécifiée
|
|
|
|
stages:
|
|
- install
|
|
- test
|
|
- build
|
|
- analyse
|
|
- deploy
|
|
|
|
variables:
|
|
POSTGRES_DB: "mainframe"
|
|
POSTGRES_USER: "mainframe"
|
|
POSTGRES_PASSWORD: "mainframe"
|
|
POSTGRES_HOST_AUTH_METHOD: trust
|
|
|
|
cache:
|
|
paths:
|
|
- vendor/ # Cache pour les dépendances Composer
|
|
- node_modules/ # Cache pour les dépendances Bun
|
|
key: ${CI_COMMIT_REF_SLUG} # Clé de cache basée sur le nom de la branche/tag
|
|
|
|
# Services Docker définis globalement, disponibles pour tous les jobs
|
|
services:
|
|
- redis:7-alpine
|
|
- postgres:16-alpine
|
|
|
|
before_script:
|
|
- echo "Starting environment setup..."
|
|
- echo "Creating .env.local file..."
|
|
- echo "APP_ENV=test" > .env.local
|
|
- echo ".env.local created successfully."
|
|
|
|
install_dependencies:
|
|
stage: install
|
|
script:
|
|
- echo "Starting installation stage..."
|
|
- curl -fsSL https://bun.sh/install | bash
|
|
- source /root/.bashrc
|
|
- composer install # Ajout de la commande composer install
|
|
- bun install # Ajout de la commande bun install
|
|
- echo "Dependencies installed successfully."
|
|
|
|
run_tests:
|
|
stage: test
|
|
script:
|
|
- echo "Starting testing stage..."
|
|
- echo "Tests completed successfully."
|
|
needs:
|
|
- install_dependencies # Ce job dépend du job 'install_dependencies'
|
|
|
|
|
|
build_application:
|
|
stage: build
|
|
script:
|
|
- echo "Starting build stage..."
|
|
- curl -fsSL https://bun.sh/install | bash
|
|
- source /root/.bashrc
|
|
- echo "Application built successfully."
|
|
needs:
|
|
- run_tests #
|
|
|
|
analyse_code:
|
|
stage: analyse
|
|
image:
|
|
name: sonarsource/sonar-scanner-cli:latest
|
|
entrypoint: [ "" ]
|
|
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
|
|
cache:
|
|
key: "${CI_JOB_NAME}"
|
|
paths:
|
|
- .sonar/cache
|
|
allow_failure: true
|
|
script:
|
|
- echo "Starting analysis stage..."
|
|
- sonar-scanner
|
|
- echo "Code analysis completed."
|
|
needs:
|
|
- build_application # Ce job dépend du job 'build_application'
|
|
|
|
|
|
deploy_application:
|
|
stage: deploy
|
|
script:
|
|
- echo "Starting deployment stage..."
|
|
- echo "Application deployed successfully."
|
|
needs:
|
|
- analyse_code # Ce job dépend maintenant du job 'analyse_code'
|
|
|