From 93d76b3c69433f5d12fe0bbb33382e90dc41b933 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Munsch?= Date: Wed, 12 Aug 2026 15:45:30 +0200 Subject: [PATCH] ci: add and configure GitLab CI pipeline --- .gitlab-ci.yml | 142 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 142 insertions(+) create mode 100644 .gitlab-ci.yml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..f3f5f83 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,142 @@ +stages: + - install + - lint + - test + - security + - build + - deploy + +include: + - 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" + +# * LINT -------------------------------------------------------------------- + +.php-lint-base: &php-lint-base + image: $CI_REGISTRY/ldc-web/projets/ldc-web-images-docker/uwil-qa-8.5:latest + variables: + COMPOSER_CACHE_DIR: ".composer-cache" + 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 + rules: + - if: $CI_PIPELINE_SOURCE == "merge_request_event" + - if: $CI_COMMIT_BRANCH == "develop" + +parallel-lint: + <<: *php-lint-base + stage: lint + script: + - vendor/bin/parallel-lint --exclude vendor --exclude storage --exclude bootstrap --exclude node_modules . + allow_failure: false + +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 + +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 + +# * TESTS ------------------------------------------------------------------- + +tests_laravel: + stage: test + image: $CI_REGISTRY/ldc-web/projets/ldc-web-images-docker/uwil-qa-8.5:latest + allow_failure: false + variables: + XDEBUG_MODE: coverage + COMPOSER_CACHE_DIR: ".composer-cache" + 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 --prefer-dist --optimize-autoloader --no-scripts + script: + - cp .env.testing .env + - php artisan key:generate + - php artisan config:clear + - 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 + artifacts: + when: always + expose_as: 'coverage' + paths: + - coverage/html/ + reports: + junit: coverage/junit.xml + coverage_report: + coverage_format: cobertura + path: coverage/cobertura.xml + coverage: '/Statement coverage[A-Za-z\.*]\s*:\s*([^%]+)/' + rules: + - 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 + +# * BUILD ------------------------------------------------------------------- + +npm-build: + stage: build + script: + - echo "No NPM build required for API"