From c116a202abf305b9c74fe9a0b60ab34112595d99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Munsch?= Date: Wed, 26 Aug 2026 11:58:32 +0200 Subject: [PATCH] ci: replace deprecated qa image with composer:2.10 and php extensions --- .gitlab-ci.yml | 264 +++++++++++++++++-------------------------------- 1 file changed, 91 insertions(+), 173 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index c4dacfb4..9ed0bd95 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,85 +1,101 @@ +stages: + - install + - lint + - test + - security + - build + - deploy + include: -# - project: "ldc-web/shared-ci" -# ref: "main" -# file: "lint/lint.yml" -- project: "ldc-web/shared-ci" - ref: "main" - file: "security/security.yml" -- project: "ldc-web/shared-ci" - ref: "main" - file: "build/build.yml" -- project: "ldc-web/shared-ci" - ref: "main" - file: "test/test.yml" -- project: "ldc-web/shared-ci" - ref: "main" - file: "deploy/deploy.yml" + - project: "ldc-web/shared-ci" + ref: "main" + file: "security/composer.yml" + - project: "ldc-web/shared-ci" + ref: "main" + file: "build/composer.yml" + - project: "ldc-web/shared-ci" + ref: "main" + file: "build/docker.yml" + - project: "ldc-web/shared-ci" + ref: "main" + file: "test/test.yml" + - project: "ldc-web/shared-ci" + ref: "main" + file: "deploy/deploy.yml" -# * INSTALL DEPS AND CACHE --------------------------- +# * LINT -------------------------------------------------------------------- +.php-lint-base: &php-lint-base + image: composer:2.10 + variables: + COMPOSER_CACHE_DIR: ".composer-cache" + cache: + key: + files: + - composer.lock + prefix: "composer" + policy: pull + paths: + - .composer-cache/ + - vendor/ + before_script: + - apk add --no-cache icu-dev && docker-php-ext-install bcmath intl + - composer config gitlab-token.lab.s-web.fr "${CI_DEPLOY_USER}" "${CI_DEPLOY_PASSWORD}" + - composer install --no-interaction --optimize-autoloader --no-scripts + rules: + - if: $CI_PIPELINE_SOURCE == "merge_request_event" + - if: $CI_COMMIT_BRANCH == "develop" -# NOTE: Pas de serveur de cache partagé disponible, on skip install pour l'instant +parallel-lint: + <<: *php-lint-base + stage: lint + script: + - vendor/bin/parallel-lint --exclude vendor --exclude storage --exclude bootstrap --exclude node_modules . + allow_failure: false -# install-deps-bun: -# stage: install -# image: oven/bun:1.3.11 -# variables: -# BUN_INSTALL_CACHE_DIR: ".bun-cache" -# # NOTE: Pas de serveur de cache partagé disponible -# cache: -# key: -# files: -# - bun.lock -# prefix: "bun" -# paths: -# - .bun-cache/ -# before_script: -# - echo "@ldc-web:registry=https://${CI_SERVER_HOST}/api/v4/packages/npm/" >> .npmrc -# - echo "//${CI_SERVER_HOST}/api/v4/packages/npm/:_authToken=${CI_DEPLOY_PASSWORD}" >> .npmrc -# - echo "@uwil:registry=https://lab.s-web.fr/api/v4/groups/ldc-web/-/packages/npm/" >> .npmrc -# - echo "//lab.s-web.fr/api/v4/groups/ldc-web/-/packages/npm/:_authToken=${CI_DEPLOY_PASSWORD}" >> .npmrc -# script: -# - bun install --frozen-lockfile -# allow_failure: false -# rules: -# - if: $CI_PIPELINE_SOURCE == "merge_request_event" -# - if: $CI_COMMIT_BRANCH == "develop" || $CI_COMMIT_BRANCH == "trunk" || $CI_COMMIT_BRANCH == "master" || $CI_COMMIT_BRANCH == "main" -# - if: $CI_COMMIT_TAG != null +pint: + <<: *php-lint-base + stage: lint + script: + - vendor/bin/pint --test + allow_failure: false +phpcs: + <<: *php-lint-base + stage: lint + script: + - vendor/bin/phpcs --standard=phpcs.xml --extensions=php --ignore=vendor/*,storage/*,bootstrap/*,node_modules/* --report=junit --report-file=phpcs-report.xml + artifacts: + when: on_failure + expose_as: 'phpcs' + paths: + - phpcs-report.xml + reports: + junit: phpcs-report.xml + allow_failure: false -# install-deps-composer: -# stage: install -# image: $CI_REGISTRY/ldc-web/projets/ldc-web-images-docker/uwil-qa-8.5:latest -# variables: -# COMPOSER_CACHE_DIR: ".composer-cache" -# before_script: -# - composer config gitlab-token.lab.s-web.fr $CI_DEPLOY_USER $CI_DEPLOY_PASSWORD -# script: -# - composer install --no-interaction --prefer-dist --optimize-autoloader --no-scripts -# # NOTE: Pas de serveur de cache partagé disponible -# cache: -# key: -# files: -# - composer.lock -# prefix: "composer" -# paths: -# - .composer-cache/ -# - vendor/ -# allow_failure: false -# rules: -# - if: $CI_PIPELINE_SOURCE == "merge_request_event" -# - if: $CI_COMMIT_BRANCH == "develop" || $CI_COMMIT_BRANCH == "trunk" || $CI_COMMIT_BRANCH == "master" || $CI_COMMIT_BRANCH == "main" -# - if: $CI_COMMIT_TAG != null - - -# * LINT ------------------------- +phpstan: + <<: *php-lint-base + stage: lint + variables: + PHP_MEMORY_LIMIT: "512M" + COMPOSER_CACHE_DIR: ".composer-cache" + script: + - php -d memory_limit=512M vendor/bin/phpstan --error-format=junit > phpstan-report.xml + artifacts: + when: on_failure + expose_as: 'phpstan' + paths: + - phpstan-report.xml + reports: + junit: phpstan-report.xml + allow_failure: false eslint: stage: lint image: oven/bun:1.3.11 variables: BUN_INSTALL_CACHE_DIR: ".bun-cache" - # NOTE: Pas de serveur de cache partagé disponible cache: key: files: @@ -104,20 +120,15 @@ eslint: reports: junit: eslint-junit.xml allow_failure: false - needs: - - job: install-deps-bun - optional: true # NOTE: Pas de serveur de cache partagé disponible, on skip install pour l'instant rules: - if: $CI_PIPELINE_SOURCE == "merge_request_event" - if: $CI_COMMIT_BRANCH == "develop" - stylelint: stage: lint image: oven/bun:1.3.11 variables: BUN_INSTALL_CACHE_DIR: ".bun-cache" - # NOTE: Pas de serveur de cache partagé disponible cache: key: files: @@ -142,85 +153,11 @@ stylelint: reports: junit: stylelint-junit.xml allow_failure: false - needs: - - job: install-deps-bun - optional: true # NOTE: Pas de serveur de cache partagé disponible, on skip install pour l'instant rules: - if: $CI_PIPELINE_SOURCE == "merge_request_event" - if: $CI_COMMIT_BRANCH == "develop" -phpcs: - stage: lint - image: $CI_REGISTRY/ldc-web/projets/ldc-web-images-docker/uwil-qa-8.5:latest - variables: - COMPOSER_CACHE_DIR: ".composer-cache" - # NOTE: Pas de serveur de cache partagé disponible - cache: - key: - files: - - composer.lock - prefix: "composer" - policy: pull - paths: - - .composer-cache/ - - vendor/ - before_script: - - composer config gitlab-token.lab.s-web.fr $CI_DEPLOY_USER $CI_DEPLOY_PASSWORD - - composer install --no-interaction --optimize-autoloader --no-scripts - script: - - vendor/bin/phpcs --report=junit --report-file=phpcs-report.xml - artifacts: - when: on_failure - expose_as: 'phpcs' - paths: - - phpcs-report.xml - reports: - junit: phpcs-report.xml - allow_failure: false - needs: - - job: install-deps-composer - optional: true # NOTE: Pas de serveur de cache partagé disponible, on skip install pour l'instant - rules: - - if: $CI_PIPELINE_SOURCE == "merge_request_event" - - if: $CI_COMMIT_BRANCH == "develop" - -phpstan: - stage: lint - image: $CI_REGISTRY/ldc-web/projets/ldc-web-images-docker/uwil-qa-8.5:latest - variables: - PHP_MEMORY_LIMIT: "512M" - COMPOSER_CACHE_DIR: ".composer-cache" - # NOTE: Pas de serveur de cache partagé disponible - cache: - key: - files: - - composer.lock - prefix: "composer" - policy: pull - paths: - - .composer-cache/ - - vendor/ - before_script: - - composer config gitlab-token.lab.s-web.fr $CI_DEPLOY_USER $CI_DEPLOY_PASSWORD - - composer install --no-interaction --optimize-autoloader --no-scripts - script: - - php -d memory_limit=512M vendor/bin/phpstan --error-format=junit > phpstan-report.xml - artifacts: - when: on_failure - expose_as: 'phpstan' - paths: - - phpstan-report.xml - reports: - junit: phpstan-report.xml - allow_failure: true - needs: - - job: install-deps-composer - optional: true # NOTE: Pas de serveur de cache partagé disponible, on skip install pour l'instant - rules: - - if: $CI_PIPELINE_SOURCE == "merge_request_event" - - -# * TESTS ------------------------- +# * TESTS ------------------------------------------------------------------- bun-build-test: stage: test @@ -248,9 +185,6 @@ bun-build-test: paths: - public/build/manifest.json allow_failure: false - needs: - - job: install-deps-bun - optional: true # NOTE: Pas de serveur de cache partagé disponible, on skip install pour l'instant rules: - if: $CI_PIPELINE_SOURCE == "merge_request_event" - if: $CI_COMMIT_BRANCH == "trunk" || $CI_COMMIT_BRANCH == "master" || $CI_COMMIT_BRANCH == "main" @@ -285,9 +219,6 @@ tests_front: reports: junit: coverage/junit-vitest.xml allow_failure: false - needs: - - job: install-deps-bun - optional: true rules: - if: $CI_PIPELINE_SOURCE == "merge_request_event" - if: $CI_COMMIT_BRANCH == "trunk" || $CI_COMMIT_BRANCH == "master" || $CI_COMMIT_BRANCH == "main" @@ -295,10 +226,9 @@ tests_front: tests_laravel: stage: test - image: $CI_REGISTRY/ldc-web/projets/ldc-web-images-docker/uwil-qa-8.5:latest + image: composer:2.10 allow_failure: false variables: - XDEBUG_MODE: coverage COMPOSER_CACHE_DIR: ".composer-cache" # MYSQL SERVICE VARS MYSQL_DATABASE: testing_db @@ -324,14 +254,14 @@ tests_laravel: - name: mysql:8.0 alias: mysql before_script: - - composer config gitlab-token.lab.s-web.fr $CI_DEPLOY_USER $CI_DEPLOY_PASSWORD + - apk add --no-cache $PHPIZE_DEPS linux-headers icu-dev && docker-php-ext-install bcmath intl pdo_mysql && pecl install pcov && docker-php-ext-enable pcov + - composer config gitlab-token.lab.s-web.fr "${CI_DEPLOY_USER}" "${CI_DEPLOY_PASSWORD}" - composer install --no-interaction --prefer-dist --optimize-autoloader --no-scripts script: - cp .env.example .env - php artisan key:generate - php -r "while(true){try{new PDO('mysql:host=mysql;dbname=testing_db','root','password');break;}catch(Exception){sleep(1);}}" - php artisan config:clear - - php artisan migrate --seed - php artisan test --coverage --colors=never --log-junit=coverage/junit.xml --coverage-cobertura=coverage/cobertura.xml --coverage-html=coverage/html after_script: - if [ "$CI_JOB_STATUS" == "failed" ]; then cat storage/logs/laravel.log; fi @@ -345,12 +275,8 @@ tests_laravel: coverage_report: coverage_format: cobertura path: coverage/cobertura.xml - coverage: '/Statement coverage[A-Za-z\.*]\s*:\s*([^%]+)/' + coverage: '/^\s*Total:\s*([\d\.]+)%/' needs: - - job: install-deps-composer # NOTE: Pas de serveur de cache partagé disponible, on skip install pour l'instant - optional: true - - job: install-deps-bun - optional: true # NOTE: Pas de serveur de cache partagé disponible, on skip install pour l'instant - job: bun-build-test optional: false artifacts: true @@ -359,6 +285,7 @@ tests_laravel: - if: $CI_COMMIT_BRANCH == "trunk" || $CI_COMMIT_BRANCH == "master" || $CI_COMMIT_BRANCH == "main" - if: $CI_COMMIT_TAG != null +# * SECURITY ---------------------------------------------------------------- bun-security: stage: security @@ -380,12 +307,3 @@ bun-security: - if: $CI_PIPELINE_SOURCE == "merge_request_event" - if: $CI_COMMIT_BRANCH == "trunk" || $CI_COMMIT_BRANCH == "master" || $CI_COMMIT_BRANCH == "main" - if: $CI_COMMIT_TAG != null - - -stages: -- install -- lint -- test -- security -- build -- deploy