Files
chill-bundles/.gitlab-ci.yml

213 lines
6.2 KiB
YAML

---
# Select what we should cache between builds
cache:
paths:
- /vendor/
- .cache
- node_modules/
# Bring in any services we need http://docs.gitlab.com/ee/ci/docker/using_docker_images.html#what-is-a-service
# See http://docs.gitlab.com/ee/ci/services/README.html for examples.
services:
- name: postgis/postgis:17-3.5-alpine
alias: db
command:
- postgres
- "-c"
- max_connections=1000
- name: redis
alias: redis
# Set any variables we need
variables:
APP_ENV: test
GIT_DEPTH: 1
# Configure postgres environment variables (https://hub.docker.com/r/_/postgres/)
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
# configure database access
DATABASE_URL: postgresql://postgres:postgres@db:5432/postgres?serverVersion=17&charset=utf8
# fetch the chill-app using git submodules
# GIT_SUBMODULE_STRATEGY: recursive
REDIS_HOST: redis
REDIS_PORT: 6379
REDIS_URL: redis://redis:6379
DEFAULT_CARRIER_CODE: BE
# force a timezone
TZ: Europe/Brussels
# avoid direct deprecations (using symfony phpunit bridge: https://symfony.com/doc/4.x/components/phpunit_bridge.html#internal-deprecations
SYMFONY_DEPRECATIONS_HELPER: max[total]=99999999&max[self]=0&max[direct]=45&verbose=0
# consider the root package at the dev-master version
# this is required to work with packages
# see https://getcomposer.org/doc/articles/troubleshooting.md#dependencies-on-the-root-package
COMPOSER_ROOT_VERSION: dev-master
stages:
- mirror
- Composer install
- Tests
- Deploy
mirror_chill_zimbra_bundle:
stage: mirror
image: alpine:latest
variables:
GIT_DEPTH: 0 # <-- access to the full git history
rules:
# 1) Allow manual run from GitLab UI, whatever the branch
- if: '$CI_PIPELINE_SOURCE == "web"'
# 2) Auto-run on commits to master or 472-zimbra-connector
# but only if relevant files changed
- if: '$CI_COMMIT_BRANCH == "master" || $CI_COMMIT_BRANCH == "472-zimbra-connector"'
changes:
- packages/ChillZimbraBundle/**/*
- .gitlab-ci.yml
# 3) Otherwise: never run
- when: never
before_script:
- apk add --no-cache git git-subtree openssh
# Config git
- git config --global user.email "ci@gitlab.com"
- git config --global user.name "GitLab CI"
# Préparation SSH
- mkdir -p ~/.ssh
- cp "$DEPLOY_KEY" ~/.ssh/id_ed25519
- printf '\n' >> ~/.ssh/id_ed25519
- chmod 600 ~/.ssh/id_ed25519
- ssh-keyscan gitlab.com >> ~/.ssh/known_hosts
# Ajout du remote vers le repo dédié
- git remote add chill-zimbra-connector git@gitlab.com:Chill-Projet/chill-zimbra-connector.git || true
script:
# On s'assure d'être sur la bonne branche (celle qui a déclenché le job, master)
- git checkout "$CI_COMMIT_REF_NAME"
# Crée une branche temporaire qui contient uniquement l'historique de packages/ChillZimbraBundle
- git subtree split --prefix=packages/ChillZimbraBundle -b chill_zimbra_temp
# Push vers le repo cible, branche master du repo chill-zimbra-connector
- git push chill-zimbra-connector chill_zimbra_temp:main
build:
stage: Composer install
image: chill/base-image:8.3-edge
variables:
before_script:
- composer config -g cache-dir "$(pwd)/.cache"
script:
- composer install --optimize-autoloader --no-ansi --no-interaction --no-progress
cache:
paths:
- .cache/
artifacts:
expire_in: 1 day
paths:
- vendor/
code_style:
stage: Tests
image: chill/base-image:8.3-edge
script:
- php-cs-fixer fix --dry-run -v --show-progress=none
cache:
paths:
- .cache/
artifacts:
expire_in: 1 day
paths:
- vendor/
phpstan_tests:
stage: Tests
image: chill/base-image:8.3-edge
variables:
COMPOSER_MEMORY_LIMIT: 3G
before_script:
- bin/console cache:clear --env=dev
script:
- composer exec phpstan -- analyze --memory-limit=3G
cache:
paths:
- .cache/
artifacts:
expire_in: 1 day
paths:
- vendor/
rector_tests:
stage: Tests
image: chill/base-image:8.3-edge
before_script:
- bin/console cache:clear --env=dev
script:
- composer exec rector -- process --dry-run
cache:
paths:
- .cache/
artifacts:
expire_in: 1 day
paths:
- vendor/
lint:
stage: Tests
image: node:20-alpine
before_script:
- apk add --no-cache python3 make g++ py3-setuptools
- export PYTHON="$(which python3)"
- export PATH="./node_modules/.bin:$PATH"
script:
- yarn install --ignore-optional
- npx eslint-baseline "src/**/*.{js,ts,vue}"
cache:
paths:
- node_modules/
# psalm_tests:
# stage: Tests
# image: gitea.champs-libres.be/chill-project/chill-skeleton-basic/base-image:php82
# script:
# - bin/psalm
# allow_failure: true
# artifacts:
# expire_in: 30 min
# paths:
# - bin
# - tests/app/vendor/
unit_tests:
stage: Tests
image: chill/base-image:8.3-edge
variables:
COMPOSER_MEMORY_LIMIT: 3G
before_script:
- php bin/console doctrine:database:create -n --env=test
- php bin/console doctrine:migrations:migrate -n --env=test
- php bin/console chill:db:sync-views --env=test
- php bin/console cache:clear --env=test
- php bin/console doctrine:fixtures:load -n --env=test
script:
- composer exec phpunit -- --colors=never --exclude-group dbIntensive,openstack-integration
artifacts:
expire_in: 1 day
paths:
- vendor/
release:
stage: Deploy
image: registry.gitlab.com/gitlab-org/release-cli:latest
rules:
- if: $CI_COMMIT_TAG
script:
- echo "running release_job"
release:
tag_name: '$CI_COMMIT_TAG'
description: "./.changes/$CI_COMMIT_TAG.md"