Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • Comptoir/comptoir-du-libre
  • fgangler/comptoir
2 results
Show changes
Showing
with 1939 additions and 0 deletions
../lib/symlink_source/60_build_image_without-cache.sh
\ No newline at end of file
../lib/symlink_source/70_push_image.sh
\ No newline at end of file
../lib/symlink_source/80_builld_and_push_image.sh
\ No newline at end of file
FROM ubuntu:24.04
# System prerequisites
RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive \
apt-get -y --no-install-recommends \
install git \
make \
gpg-agent \
software-properties-common \
ca-certificates \
curl \
zip \
unzip \
gpg && \
rm -rf /var/lib/apt/lists/*
# Allow to use another version of PHP than Ubuntu PHP version
RUN add-apt-repository ppa:ondrej/php
# Webapp prerequisites - Install PHP and PHP extensions
RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive \
apt-get -y --no-install-recommends \
install php8.4 \
php8.4-bcmath \
php8.4-curl \
php8.4-intl \
php8.4-mbstring \
php8.4-pgsql \
php8.4-sqlite3 \
php8.4-xdebug \
php8.4-xml \
php8.4-zip && \
rm -rf /var/lib/apt/lists/*
# PHP Xdebug extension is mandatory to use Infection tool
# Webapp prerequisites - Install COMPOSER
RUN curl -sSL https://getcomposer.org/installer --output composer-setup.php && \
php -r "if (hash_file('sha384', 'composer-setup.php') === 'dac665fdc30fdd8ec78b38b9800061b4150413ff2e3b6f88543c636f7cd84f6db9189d43a81e5503cda447da73c7e5b6') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" && \
php composer-setup.php && \
rm -v composer-setup.php && \
chmod +x composer.phar && \
mv -v composer.phar /usr/local/bin/composer && \
composer -V
# QA prerequisites - Install Symfony CLI
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
RUN curl -sS https://get.symfony.com/cli/installer | /bin/bash && \
mv /root/.symfony5/bin/symfony /usr/local/bin/symfony && \
symfony -V
# Caching of all PHP dependencies declared in composer.json files
WORKDIR "/php/"
RUN REPO=https://gitlab.adullact.net/Comptoir/comptoir-du-libre.git && \
pwd && \
git clone ${REPO} source-code && \
cd /php/source-code/webapp/ && \
composer install --no-progress \
--no-interaction \
--no-scripts && \
cd /php/source-code/bin/tools_via_composer/ && \
composer install --no-progress \
--no-interaction \
--no-scripts && \
mkdir -p /php/composer-cache/tools/ && \
mkdir -p /php/composer-cache/webapp/ && \
cp /php/source-code/bin/tools_via_composer/composer.json /php/composer-cache/tools/ && \
cp /php/source-code/bin/tools_via_composer/composer.lock /php/composer-cache/tools/ && \
cp -r /php/source-code/bin/tools_via_composer/vendor /php/composer-cache/tools/ && \
cd /php/composer-cache/tools/ && \
tar -czf vendor.tar.gz vendor/ && \
cp -r /php/source-code/webapp/composer.json /php/composer-cache/webapp/ && \
cp -r /php/source-code/webapp/composer.lock /php/composer-cache/webapp/ && \
cp -r /php/source-code/webapp/vendor /php/composer-cache/webapp/ && \
cd /php/composer-cache/webapp/ && \
tar -czf vendor.tar.gz vendor/ && \
rm -rf /php/composer-cache/webapp/vendor/ && \
rm -rf /php/composer-cache/tools/vendor/ && \
rm -rf /php/source-code/
# Display software versions
RUN echo "-------------------" >> /php/software-infos.txt && \
cat /etc/os-release >> /php/software-infos.txt && \
echo "-------------------" >> /php/software-infos.txt && \
php --version >> /php/software-infos.txt && \
echo "-------------------" >> /php/software-infos.txt && \
php -m >> /php/software-infos.txt && \
echo "-------------------" >> /php/software-infos.txt && \
composer -V >> /php/software-infos.txt && \
echo "-------------------" >> /php/software-infos.txt && \
symfony -V >> /php/software-infos.txt && \
echo "-------------------" >> /php/software-infos.txt && \
cat /php/software-infos.txt
# # DEBUG
# RUN ls -l /php/ && \
# ls -l /php/composer-cache/ && \
# ls -l /php/composer-cache/webapp && \
# cd /php/composer-cache/webapp && tar -xzf vendor.tar.gz && \
# ls -l /php/composer-cache/webapp && \
# ls -l /php/composer-cache/webapp/vendor && \
# ls -l /php/composer-cache/tools && \
# cd /php/composer-cache/tools && tar -xzf vendor.tar.gz && \
# ls -l /php/composer-cache/tools && \
# ls -l /php/composer-cache/tools/vendor
#
# # DEBUG Check cache
# RUN du -hs /root/.cache/composer/ && \
# du -hs /php/composer-cache/*
# Set Docker LABEL
LABEL version="1.0.0" \
description="CI Prerequisites : Ubuntu 24.04, PHP 8.4 (ppa:ondrej/php), Composer, Symfony-CLI, Xdebug and Make"
# CI Prerequisites : Ubuntu 24.04, PHP 8.4 (ppa:ondrej/php), Composer, Symfony-CLI, Xdebug and Make
**Table of contents**
[Toc]
-------------------------------------------------------
## CI Prerequisites
Docker image of CI Prerequisites :
- Ubuntu 24.04
- PHP **8.4** (`ppa:ondrej/php`)
- Composer
- Symfony-CLI
- Xdebug
- Make
-------------------------------------------------------
## To update Docker image
### Edit Dockerfile
Edit [Dockerfile](Dockerfile) according to your needs
and in addition you must to change in this file `LABEL version="1.0.0"`
following [semantic versioning](http://semver.org/) recommendations:
```shell script
MAJOR.MINOR.PATCH
# MAJOR ---> a breaking change (incompatible API changes)
# MINOR ---> add a new feature
# PATCH ---> fix a bug
```
```dockerfile
# Set Docker LABEL and display software versions
LABEL version="1.0.0" \
description="CI Prerequisites : Ubuntu 24.04, PHP 8.4 (ppa:ondrej/php), Composer, Symfony-CLI, Xdebug and Make"
```
### Build Docker image and push to container registry
Build new Docker image and push to [Gitlab container registry](https://gitlab.adullact.net/Comptoir/comptoir-du-libre/container_registry)
#### Configure variables in particular DOCKER_IMAGE_VERSION
```bash
# Configure variables
# in particular DOCKER_IMAGE_VERSION
# which must be identical to LABEL.version in Dockerfile
GITLAB_URI="gitlab.adullact.net:4567"
GITLAB_REPOSITORY="comptoir/comptoir-du-libre"
DOCKER_IMAGE_NAME="php-8.4_composer"
DOCKER_IMAGE_VERSION="v1.0.0" # must be identical to LABEL.version in Dockerfile
```
#### Build new Docker image (option 1: without docker cache)
Must be used to push a new Docker image (without Docker cache):
```bash
# Build new Docker image
docker images | grep "${DOCKER_IMAGE_NAME}"
docker build --no-cache --progress plain -t "${GITLAB_URI}/${GITLAB_REPOSITORY}/${DOCKER_IMAGE_NAME}:${DOCKER_IMAGE_VERSION}" .
docker images | grep "${DOCKER_IMAGE_NAME}"
```
#### Build new Docker image (option 2: with docker cache)
Useful for debugging (with Docker cache):
```bash
# Build new Docker image
docker build --progress plain -t "${GITLAB_URI}/${GITLAB_REPOSITORY}/${DOCKER_IMAGE_NAME}:${DOCKER_IMAGE_VERSION}" .
docker images | grep "${DOCKER_IMAGE_NAME}"
```
#### Push to Gitlab container registry
```bash
# Login to Gitlab
docker login "${GITLAB_URI}"
# Push to Gitlab container registry
docker push "${GITLAB_URI}/${GITLAB_REPOSITORY}/${DOCKER_IMAGE_NAME}:${DOCKER_IMAGE_VERSION}"
# Logout to remove Gitlab credentials from $HOME/.docker/config.json file
docker logout "${GITLAB_URI}"
```
#!/usr/bin/env bash
# shellcheck disable=SC2034 # Don't warn about unused variables in this file
##############################################################################################
DOCKER_IMAGE_FROM="ubuntu:24.04"
DOCKER_IMAGE_NAME="php-8.4_composer"
DOCKER_IMAGE_VERSION="1.0.0" # must be identical to LABEL.version in Dockerfile
##############################################################################################
---
###############################################################
# HADOLINT configuration (a Dockerfile linter)
###############################################################
# source : https://github.com/hadolint/hadolint
# online validator : https://hadolint.github.io/hadolint/
# docker image : https://hub.docker.com/r/hadolint/hadolint
###############################################################
trustedRegistries:
- docker.io
ignored:
- DL3003
- DL3008
########################################################################################################################
# Rules currently not applied:
# DL3003 Use WORKDIR to switch to a directory
# DL3008 Pin versions in apt install.
# Instead of `apt-get install <package>` use `apt-get install <package>=<version>`
########################################################################################################################
---
default: true
# MD007 - Unordered list indentation
# https://github.com/DavidAnson/markdownlint/blob/main/doc/Rules.md#md007---unordered-list-indentation
MD007:
indent: 2
# MD012 - Multiple consecutive blank lines (expected: 1)
# see: https://github.com/DavidAnson/markdownlint/blob/main/doc/Rules.md#md012---multiple-consecutive-blank-lines
MD012:
maximum: 3
# MD013 - Line length (expected: 80)
# see: https://github.com/DavidAnson/markdownlint/blob/main/doc/Rules.md#md013---line-length
MD013:
stern: false
strict: false
tables: false
code_blocks: false
line_length: 125
# heading_line_length: 120
# code_block_line_length: 120
# MD024 - Multiple headings with the same content
# https://github.com/DavidAnson/markdownlint/blob/main/doc/Rules.md#md024---multiple-headings-with-the-same-content
MD024:
siblings_only: true
# MD032 - Lists should be surrounded by blank lines
# https://github.com/DavidAnson/markdownlint/blob/main/doc/Rules.md#md032---lists-should-be-surrounded-by-blank-lines
MD032: false
# MD033 - Inline HTML / no-inline-html
# https://github.com/DavidAnson/markdownlint/blob/main/doc/Rules.md#md033---inline-html
MD033:
allowed_elements:
- summary
- details
- abbr
- span
- strong
- em
- br
# MD034 - Bare URL used
# https://github.com/DavidAnson/markdownlint/blob/main/doc/Rules.md#md034---bare-url-used
MD034: false
# MD009 - Trailing spaces
# https://github.com/DavidAnson/markdownlint/blob/main/doc/Rules.md#md009---trailing-spaces
MD009: false
documentation/auto-generated-documentation/
---
###################################################
# Config for yamllint
# https://yamllint.readthedocs.io
# https://github.com/adrienverge/yamllint
###################################################
extends: default
rules:
brackets:
max-spaces-inside: -1
min-spaces-inside-empty: 1
comments-indentation: disable
comments:
require-starting-space: false
# ignore-shebangs: true
# min-spaces-from-content: 2
document-start:
present: false
line-length:
max: 120
level: warning
empty-lines:
max: 2
level: warning
---
#### DOCUMENTATION ###############################################################################################
# markdownlint ---> Markdown files linter
# remark-validate-links ---> check that Markdown links and images reference existing local files and headings.
# remark-lint-no-dead-urls ---> check that external URLs in Markdown files are alive.
##################################################################################################################
###############################################################
# markdownlint https://github.com/DavidAnson/markdownlint
# https://github.com/igorshubovych/markdownlint-cli
# https://gitlab.com/06kellyjac/docker_markdownlint-cli
# --> a CI job that will lint all markdown files
###############################################################
markdown_linter:
stage: documentation
needs:
- php8.1_linter
rules:
- if: $CI_PIPELINE_SOURCE == "push"
# when: manual
# allow_failure: true
image:
name: registry.gitlab.com/06kellyjac/docker_markdownlint-cli:0.27.1
entrypoint:
- "/usr/bin/env"
- "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
before_script:
- markdownlint --version
- cat .gitlab/ci/config/markdownlint.yml
- cat .gitlab/ci/config/markdownlintignore.txt
script:
- markdownlint '**/*.md' --config .gitlab/ci/config/markdownlint.yml -p .gitlab/ci/config/markdownlintignore.txt
- markdownlint --version
###############################################################
# remark-validate-links https://github.com/remarkjs/remark-validate-links
# remark-lint-no-dead-urls https://github.com/davidtheclark/remark-lint-no-dead-urls
# --> a CI job that will:
# - check that Markdown links and images reference existing local files and headings.
# - check that external URLs in Markdown files are alive.
###############################################################
doc_check-links:
stage: documentation
needs: []
rules:
- if: $CI_PIPELINE_SOURCE == "push"
when: manual
allow_failure: true
image: node:14.15.0
# @TODO find a dedicated image or build it
cache:
paths:
- node_modules/
script:
- npm -v
- node -v
- npm install remark-cli remark-validate-links remark-lint-no-dead-urls remark-preset-lint-recommended
- node node_modules/remark-cli/cli.js -u lint-no-dead-urls . 2> links-external.txt
- cat links-external.txt
- node node_modules/remark-cli/cli.js -u validate-links . 2> links-relative.txt
- cat links-relative.txt
- cat links-relative.txt | grep warning && exit 404 || echo "no error"
- cat links-external.txt | grep warning && exit 404 || echo "no error"
###############################################################
# auto-generated_routes
# --> a CI job that will ... @@@TODO
###############################################################
auto-generated_doc_routes:
extends:
- .php8.1_template
stage: documentation
needs:
- php8.1_linter
rules:
- if: $CI_PIPELINE_SOURCE == "push"
# when: manual
# allow_failure: true
script:
- cd "${PHP_WEBAPP_DIR}"
- composer install --no-dev --no-progress --no-suggest --no-interaction --no-scripts
- cd "${CI_PROJECT_DIR}"
- make verif_autodoc_routes
---
#### LINTER ######################################################################################################
# Docker-Compose ---> docker-compose.yml files linter
# Dotenv ---> .env files linter ---> TODO fixme
# Yamllint ---> Yaml files linter
# JsonLint ---> JSON files linter
# ShellCheck ---> shell scripts linter
##################################################################################################################
###############################################################
# Hadolint https://github.com/hadolint/hadolint
# https://hadolint.github.io/hadolint/
# https://hub.docker.com/r/hadolint/hadolint
# --> a CI job that will lint all Dockerfile files
###############################################################
DockerFile_linter:
stage: linter
needs:
- php8.1_linter
rules:
- if: $CI_PIPELINE_SOURCE == "push"
# when: manual
# allow_failure: true
image: hadolint/hadolint:latest-alpine
script:
- find . -type f -name Dockerfile | xargs -I % ls -l %
- cat .gitlab/ci/config/hadolint.yml
- find . -type f -name Dockerfile | xargs -I % hadolint --config .gitlab/ci/config/hadolint.yml %
##############################################################################################
# Rules currently not applied: ---> see: .gitlab/ci/config/hadolint.yml
# DL3008 Instead of `apt-get install <package>` use `apt-get install <package>=<version>`
##############################################################################################
###############################################################
# Docker-Compose config https://docs.docker.com/compose/reference/config/
# --> a CI job that will lint all docker-compose.yml files
###############################################################
docker-compose_linter:
stage: linter
needs:
- php8.1_linter
rules:
- if: $CI_PIPELINE_SOURCE == "push"
# when: manual
# allow_failure: true
image: docker/compose:1.27.4
script:
- docker -v
- docker-compose -v
- find . -name docker-compose.yml
- find . -name docker-compose.yml | xargs -I % docker-compose -f % config
# - find . -name docker-compose.override.yml
# - find . -name docker-compose.override.yml | xargs -I % docker-compose -f % config
###############################################################
# Dotenv-Linter https://dotenv-linter.github.io
# https://github.com/dotenv-linter/dotenv-linter
# --> a CI job that will lint all .env files (.env, .env.dist)
# TODO fixme : "wget: can't connect to remote host: Host is unreachable"
###############################################################
#dotenv_linter:
# stage: linter
# needs: []
# rules:
# - if: $CI_PIPELINE_SOURCE == "push"
# when: manual
# allow_failure: true
# image: alpine:latest
# script:
# - wget -q -O - https://raw.githubusercontent.com/dotenv-linter/dotenv-linter/master/install.sh | sh -s
# - bin/dotenv-linter --recursive --no-color --exclude src/
# - bin/dotenv-linter --recursive --no-color --skip QuoteCharacter UnorderedKey src/
###############################################################
# Yamllint https://yamllint.readthedocs.io
# https://github.com/adrienverge/yamllint
# https://github.com/sdesbure/docker_yamllint
# https://manpages.debian.org/buster/yamllint/yamllint.1.en.html
# --> a CI job that will lint all YAML files (docker-compose.yml, .gitlab/ci/*.yml)
###############################################################
YAML_linter:
stage: linter
needs:
- php8.1_linter
rules:
- if: $CI_PIPELINE_SOURCE == "push"
# when: manual
# allow_failure: true
image: sdesbure/yamllint:latest
script:
- find . -name '*.yaml' -type f
- find . -name '*.yml' -type f
- find . -name '*.yml' -type f | xargs -I % yamllint -d relaxed %
# - find . -name '*.yaml' -type f | xargs -I % yamllint -c .gitlab/ci/config/yamllint.yaml %
# - find . -name '*.yml' -type f | xargs -I % yamllint -c .gitlab/ci/config/yamllint.yaml %
###############################################################
# JsonLint hhttps://github.com/zaach/jsonlint
# https://github.com/PeterDaveHello/docker-jsonlint
# https://hub.docker.com/r/peterdavehello/jsonlint/
# --> a CI job that will lint all JSON files
###############################################################
JSON_linter:
stage: linter
needs: []
rules:
- if: $CI_PIPELINE_SOURCE == "push"
when: manual
allow_failure: true
variables:
jsonlint_version: "1.6.3"
image: peterdavehello/jsonlint:$jsonlint_version
script:
# - find . -name '*.json' -type f -not -path "./ignored/Directory/*"
# - find . -name '*.json' -type f -not -path "./ignored/Directory/*" | xargs -n 1 jsonlint -q
- find . -path ./webapp/data/cfssl -prune -o -name '*.json' -type f
- find . -path ./webapp/data/cfssl -prune -o -name '*.json' -type f | xargs -n 1 jsonlint -q
###############################################################
# Alternative: https://gitlab.com/pipeline-components/jsonlint
###############################################################
# json_linter:
# stage: linter
# when: manual
# image: registry.gitlab.com/pipeline-components/jsonlint:latest
# script:
# - |
# find . -not -path './.git/*' -name '*.json' -type f -print0 |
# parallel --will-cite -k -0 -n1 jsonlint -q
###############################################################
###############################################################
# ShellCheck https://github.com/koalaman/shellcheck/wiki/GitLab-CI
# https://git-scm.com/docs/git-ls-files
# --> a CI job that will lint all shell scripts (fail when no .sh files)
###############################################################
ShellCheck_linter:
stage: linter
needs:
- php8.1_linter
rules:
- if: $CI_PIPELINE_SOURCE == "push"
# when: manual
# allow_failure: true
image: koalaman/shellcheck-alpine:latest
script:
- find . -name '*.sh' -type f
- find . -name '*.sh' -type f | xargs -I % shellcheck %
# - find . -name '*.sh' -type f | xargs -I % shellcheck --exclude=SC2001 %
---
#### PHP ######################################################################################################
# PHP-Linter ---> PHP linter
# composer_validate ---> check if your composer.json is valid, composer.lock exists and is up to date.
# release-build ---> download PHP dependencies for production and creates an archive of PHP webapp ready to run
# release-publish ---> push archive of PHP webapp to Gitlab packages
##################################################################################################################
variables:
PHP_WEBAPP_DIR: "${CI_PROJECT_DIR}/webapp"
BUILD_NAME: "comptoir"
##################################################################################
# PHP versions ---> TEMPLATE
##################################################################################
.php8.1_template:
stage: php8.1
image: gitlab.adullact.net:4567/comptoir/comptoir-du-libre/php-8.1_composer:1.0.0
.php8.2_template:
stage: php8.2
image: gitlab.adullact.net:4567/comptoir/comptoir-du-libre/php-8.2_composer:1.0.0
when: manual
allow_failure: true
.php8.3_template:
stage: php8.3
image: gitlab.adullact.net:4567/comptoir/comptoir-du-libre/php-8.3_composer:1.0.0
.php8.4_template:
stage: php8.4
image: gitlab.adullact.net:4567/comptoir/comptoir-du-libre/php-8.4_composer:1.0.0
##################################################################################
# Install CI tools ---> TEMPLATE
##################################################################################
.install_ci_tools_via_composer:
cache:
paths:
- ${CI_PROJECT_DIR}/bin/tools_via_composer/vendor
before_script:
- cd "${CI_PROJECT_DIR}/bin/tools_via_composer"
- composer install --no-progress --no-suggest --no-interaction --no-scripts
##################################################################################
# PHP package outdated ---> composer update
# https://getcomposer.org/doc/03-cli.md#update-u-upgrade
# --> a CI job that will check for outdated packages
##################################################################################
php_package-outdated:
extends: ['.php_package-outdated_template', '.php8.1_template']
needs:
- php8.1_composer_validate
rules:
- if: $CI_PIPELINE_SOURCE == "push"
# when: manual
# allow_failure: true
# PHP package security vulnerabilities ---> Scheduled
php_package-outdated_schedules:
extends: ['.php_package-outdated_template', '.php8.1_template']
rules:
- if: $CI_PIPELINE_SOURCE == "schedule"
# PHP package security vulnerabilities ---> TEMPLATE
.php_package-outdated_template:
needs: []
before_script:
- echo "-------------------" && php --version
- echo "-------------------" && composer -V
- echo "-------------------" && symfony -V
- echo "-------------------"
script:
- make ci_outdated_php_packages
#################################################################################################
# PHP package security vulnerabilities
# - checks for security vulnerability advisories
# - based only on the composer.lock file (including dev packages)
# - use : GitHub Advisory Database https://github.com/advisories
# PHP Security Advisories Database https://github.com/FriendsOfPHP/security-advisories
#
# --> a CI job that will check whether project's dependencies
# contain any known security vulnerability
#################################################################################################
php_package-security-vulnerabilities:
extends: ['.php_package-security-vulnerabilities_template', '.php8.1_template']
needs:
- php8.1_linter
rules:
- if: $CI_PIPELINE_SOURCE == "push"
# when: manual
# allow_failure: true
# PHP package security vulnerabilities ---> Scheduled
php_package-security-vulnerabilities_schedules:
extends: ['.php_package-security-vulnerabilities_template', '.php8.1_template']
rules:
- if: $CI_PIPELINE_SOURCE == "schedule"
# PHP package security vulnerabilities ---> TEMPLATE
.php_package-security-vulnerabilities_template:
needs: []
script:
# - cd "${PHP_WEBAPP_DIR}" && composer audit --locked --no-dev --format=json
- cd "${PHP_WEBAPP_DIR}" && composer audit --locked --no-dev --format=table
# - symfony local:check:security --dir="${PHP_WEBAPP_DIR}" --format=ansi
#######################################################################
# PHPUnit https://phpunit.de
# --> a CI job that will run PHPUnit (testing framework for PHP)
#######################################################################
php8.1_tests:
extends:
- .tests_template
- .php8.1_template
needs:
- php8.1_linter
# - php8.1_composer_validate
# rules:
# - if: $CI_PIPELINE_SOURCE == "push"
# when: manual
# allow_failure: true
php8.2_tests:
needs:
- php8.2_linter
# - php8.2_composer_validate
extends:
- .tests_template
- .php8.2_template
php8.3_tests:
needs:
- php8.3_linter
# - php8.3_composer_validate
extends:
- .tests_template
- .php8.3_template
php8.4_tests:
needs:
- php8.4_linter
# - php8.4_composer_validate
extends:
- .tests_template
- .php8.4_template
.tests_template:
rules:
- if: $CI_PIPELINE_SOURCE == "push"
# when: manual
# allow_failure: true
artifacts:
when: always
reports:
junit: "${PHP_WEBAPP_DIR}/report.xml"
services:
- postgres:14
variables:
POSTGRES_DB: "ci_pg_database"
POSTGRES_USER: "ci_pg_user"
POSTGRES_PASSWORD: "ci_pg_password"
POSTGRES_HOST_AUTH_METHOD: trust
DATABASE_HOST: postgres
DATABASE_PORT: "5432"
DATABASE_URL: 'postgresql://ci_pg_user:ci_pg_password@postgres:5432/ci_pg_database?serverVersion=14&charset=utf8'
# https://docs.gitlab.com/ee/ci/services/postgres.html
before_script:
- cd "${PHP_WEBAPP_DIR}"
- composer install --no-progress --no-suggest --no-interaction --no-scripts
- touch .env.local
- echo "DATABASE_URL=${DATABASE_URL}" >> .env.local
- echo "APP_ENV=test" >> .env.local
- cat .env.local
- php bin/console doctrine:database:drop --force --env=test || true
- php bin/console doctrine:database:create --env=test
- php bin/console doctrine:migration:migrate --env=test --no-interaction
- php bin/console doctrine:migrations:up-to-date --env=test --no-ansi --fail-on-unregistered
# - php bin/console doctrine:migration:status --env=test
- php bin/console doctrine:fixtures:load --env=test --no-interaction
script:
- cd "${PHP_WEBAPP_DIR}"
- XDEBUG_MODE=coverage bin/phpunit --testdox --coverage-text --log-junit report.xml --configuration phpunit.xml.dist
# - bin/phpunit --no-coverage --configuration phpunit.xml.dist
- php --version
#######################################################################
# Infection https://infection.github.io
# https://github.com/infection/infection
# https://infection.github.io/guide/using-with-ci.html
# https://infection.github.io/guide/index.html#Mutation-Score-Indicator-MSI
# https://infection.github.io/guide/index.html#Covered-Code-Mutation-Score-Indicator
# --> a CI job that will run Infection (PHP Mutation Testing Framework)
#######################################################################
php8.1_tests_mutation:
extends:
- .php8.1_template
- .install_ci_tools_via_composer
needs:
- php8.1_linter
# - php8.1_tests
rules:
- if: $CI_PIPELINE_SOURCE == "push"
when: manual
allow_failure: true
before_script:
- cd "${PHP_WEBAPP_DIR}"
- composer install --no-progress --no-suggest --no-interaction --no-scripts
script:
- cd "${CI_PROJECT_DIR}"
- make tests_mutation
# - ../../bin/infection --show-mutations --min-covered-msi=20 --min-msi=65
#######################################################################
# TWIG Linter https://symfony.com/doc/current/templates.html#linting-twig-templates
# --> a CI job that will lint all .twig files
#######################################################################
twig_linter:
extends:
- .php8.1_template
needs: []
rules:
- if: $CI_PIPELINE_SOURCE == "push"
# when: manual
# allow_failure: true
before_script:
- cd "${PHP_WEBAPP_DIR}"
- composer install --no-progress --no-suggest --no-interaction --no-scripts
script:
- cd "${CI_PROJECT_DIR}"
- make twig_linter
#######################################################################
# PHP-Linter https://github.com/php-parallel-lint/PHP-Parallel-Lint
# --> a CI job that will lint all .php files
#######################################################################
php8.1_linter:
extends:
- .php_linter_template
- .php8.1_template
php8.2_linter:
extends:
- .php_linter_template
- .php8.2_template
php8.3_linter:
extends:
- .php_linter_template
- .php8.3_template
php8.4_linter:
extends:
- .php_linter_template
- .php8.4_template
.php_linter_template:
needs: []
extends:
- .install_ci_tools_via_composer
rules:
- if: $CI_PIPELINE_SOURCE == "push"
# when: manual
# allow_failure: true
script:
- cd "${CI_PROJECT_DIR}"
- make php_linter
#######################################################################
# PHPCS (Coding Standard) https://github.com/squizlabs/PHP_CodeSniffer
# --> a CI job that will detect violations of a defined coding standard
#######################################################################
php8.1_coding-standard:
extends:
- .php8.1_template
- .install_ci_tools_via_composer
needs:
- php8.1_linter
rules:
- if: $CI_PIPELINE_SOURCE == "push"
# when: manual
# allow_failure: true
script:
- cd "${CI_PROJECT_DIR}"
- make php_coding-standard
#######################################################################
# composer_validate --> a CI task that:
# - checks that PHP and extensions versions match the platform requirements of the installed packages.
# - check if your composer.json is valid
# - check if composer.lock exists and is up to date.
#
# Composer https://getcomposer.org/doc/03-cli.md#validate
# https://getcomposer.org/doc/03-cli.md#check-platform-reqs
#######################################################################
php8.1_composer_validate:
needs:
- php8.1_linter
extends:
- .composer_validate_template
- .php8.1_template
php8.2_composer_validate:
needs:
- php8.2_linter
extends:
- .composer_validate_template
- .php8.2_template
php8.3_composer_validate:
needs:
- php8.3_linter
extends:
- .composer_validate_template
- .php8.3_template
php8.4_composer_validate:
needs:
- php8.4_linter
extends:
- .composer_validate_template
- .php8.4_template
.composer_validate_template:
needs: []
rules:
- if: $CI_PIPELINE_SOURCE == "push"
# when: manual
# allow_failure: true
cache:
paths:
- /root/.composer
- ${PHP_WEBAPP_DIR}/vendor
# before_script:
# - cd ${PHP_WEBAPP_DIR}/
# - composer install --no-dev
script:
- cd ${PHP_WEBAPP_DIR}/
- composer check-platform-reqs
- composer validate --no-check-publish
- php --version
#######################################################################
# release-build --> a CI task that:
# - download PHP dependencies for production
# - create an archive of PHP webapp ready to run
#######################################################################
php8.1_release-build:
extends: ['.php8.1_template']
stage: release
needs:
# - php8.1_tests
- php8.1_linter
- php8.1_coding-standard
- php8.1_composer_validate
- php_package-security-vulnerabilities
# - php_package-outdated
rules:
- if: $CI_PIPELINE_SOURCE == "push"
# when: manual
# allow_failure: true
artifacts:
paths:
- "${CI_PROJECT_DIR}/build-result/*"
expire_in: '30 days'
name: "comptoir-$CI_COMMIT_REF_SLUG"
cache:
paths:
- /root/.composer
- ${PHP_WEBAPP_DIR}/vendor
variables:
DOC_URL: "${CI_PROJECT_URL}/-/blob/main/documentation/"
# DOC_URL: "https://gitlab.adullact.net/${CI_PROJECT_PATH}/-/blob/main/documentation/"
ARCHIVE_FILES: >-
LICENSE
CHANGELOG.md
README.txt
.env
.env.prod
.env.local
composer.json
composer.lock
config/
migrations/
public/
src/
templates/
translations/
vendor/
script:
- cd "${PHP_WEBAPP_DIR}/"
- composer install --no-dev --no-progress --no-suggest --no-interaction --no-scripts --optimize-autoloader
- composer audit
- APP_ENV=prod php bin/console importmap:install --no-interaction
- APP_ENV=prod php bin/console asset-map:compile --no-interaction
- cp "${CI_PROJECT_DIR}/CHANGELOG.md" "${PHP_WEBAPP_DIR}/"
- cp "${CI_PROJECT_DIR}/LICENSE" "${PHP_WEBAPP_DIR}/"
- echo "${CI_PROJECT_TITLE}" >> "${PHP_WEBAPP_DIR}/README.txt"
- echo "${DOC_URL}" >> "${PHP_WEBAPP_DIR}/README.txt"
- echo "APP_ENV=prod" > "${PHP_WEBAPP_DIR}/.env.local"
- sed -i "s/version_major.minor.patch/${CI_COMMIT_TAG}/" "${PHP_WEBAPP_DIR}/.env"
- cat "${PHP_WEBAPP_DIR}/config/services.yaml"
- mkdir -p "${CI_PROJECT_DIR}/build-result/${BUILD_NAME}"
- mkdir -p "${CI_PROJECT_DIR}/build-result/${BUILD_NAME}/bin"
- cp -r $ARCHIVE_FILES "${CI_PROJECT_DIR}/build-result/${BUILD_NAME}"
- cp -r bin/console "${CI_PROJECT_DIR}/build-result/${BUILD_NAME}/bin/console"
# - ls -la "${CI_PROJECT_DIR}/build-result/${BUILD_NAME}"
# - ls -la "${CI_PROJECT_DIR}/build-result/${BUILD_NAME}/bin"
- cd "${CI_PROJECT_DIR}/build-result/${BUILD_NAME}"
- find . -type f -exec sha256sum {} ';' > ../Checksum_Comptoir-${CI_COMMIT_TAG}_files.sha256
- cp ../Checksum_Comptoir-${CI_COMMIT_TAG}_files.sha256 ./
- chmod -R g-w,o-rwx "${CI_PROJECT_DIR}/build-result/"
- cd "${CI_PROJECT_DIR}/build-result/"
- tar cvzf php-webapp.tgz ${BUILD_NAME} --preserve-permissions > php-webapp.tgz_files.txt
- echo "$(cat php-webapp.tgz_files.txt | wc -l) files added"
##################################################################################
# release-publish --> a CI task that push archive of PHP webapp to Gitlab packages
##################################################################################
release-publish:
stage: release
needs: ['php8.1_release-build']
image: curlimages/curl:latest
script:
- 'curl --header "JOB-TOKEN: $CI_JOB_TOKEN" --upload-file build-result/php-webapp.tgz "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/comptoir/${CI_COMMIT_TAG}/comptoir-${CI_COMMIT_TAG}.tgz"'
only:
- tags
except:
- branches
## Summary
<!-- Briefly summarize the bug -->
## Steps to reproduce
<!-- What do you need to do to reproduce the bug? -->
## Actual behavior
<!-- What actually happens -->
## Expected behavior
<!-- What you should see instead -->
## Relevant logs and/or screenshots
<!-- Paste the logs inside of the code blocks (```)
below so it would be easier to read. -->
<details>
<summary> Log </summary>
```sh
Add the log here
```
</details>
## Possible fixes
<!-- If you can, link to the line of code
that might be responsible for the problem -->
/label ~Bug
## Description
<!-- Include problem, use cases, benefits, and/or goals -->
## Proposal
## Links to related issues and merge requests / references
<!-- Please paste a link of the related issues or/and merge requests -->
/label ~Feature
<!-- Mention "documentation" or "docs" in the MR title -->
## What does this MR do?
<!-- Briefly describe what this MR is about. -->
## Related issues
<!-- Link related issues below.
Insert the issue link or reference after the word "Closes"
if merging this should automatically close it. -->
/label ~documentation
# CHANGELOG
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
--------------------------------
## 3.0.0-alpha.0.1.0 (unreleased)
### Added
### Changed
#### Breaking change
### Fixed
### Dependancies
### Security
--------------------------------
## Template
```markdown
## <major>.<minor>.patch_DEV (unreleased)
### Added
### Changed
#### Breaking change
### Fixed
### Dependancies
### Security
<details>
<summary>
Update `symfony/*` (v6.x.x => v6.x.x) : 0 installs, xx updates, 0 removals
see: https://symfony.com/blog/
</summary>
Lock file operations: 0 installs, xx updates, 0 removals
- Upgrading ...
</details>
--------------------------------
```
# Contributor Covenant Code of Conduct
## Our Pledge
We as members, contributors, and leaders pledge to make participation in our community
a harassment-free experience for everyone, regardless of age, body size, visible or invisible
disability, ethnicity, sex characteristics, gender identity and expression, level of experience,
education, socio-economic status, nationality, personal appearance, race, religion,
or sexual identity and orientation.
We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
## Our Standards
Examples of behavior that contributes to a positive environment for our community include:
* Demonstrating empathy and kindness toward other people
* Being respectful of differing opinions, viewpoints, and experiences
* Giving and gracefully accepting constructive feedback
* Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
* Focusing on what is best not just for us as individuals, but for the overall community
Examples of unacceptable behavior include:
* The use of sexualized language or imagery, and sexual attention or
advances of any kind
* Trolling, insulting or derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or email
address, without their explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting
## Enforcement Responsibilities
Community leaders are responsible for clarifying and enforcing our standards of acceptable
behavior and will take appropriate and fair corrective action in response to any behavior
that they deem inappropriate, threatening, offensive, or harmful.
Community leaders have the right and responsibility to remove, edit, or reject comments,
commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct,
and will communicate reasons for moderation decisions when appropriate.
## Scope
This Code of Conduct applies within all community spaces, and also applies when an individual
is officially representing the community in public spaces. Examples of representing our community
include using an official e-mail address, posting via an official social media account,
or acting as an appointed representative at an online or offline event.
## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community
leaders responsible for enforcement at [https://adullact.org/contact](https://adullact.org/contact).
All complaints will be reviewed and investigated promptly and fairly.
All community leaders are obligated to respect the privacy and security of the reporter of any incident.
## Enforcement Guidelines
Community leaders will follow these Community Impact Guidelines in determining the consequences
for any action they deem in violation of this Code of Conduct:
### 1. Correction
**Community Impact**: Use of inappropriate language or other behavior
deemed unprofessional or unwelcome in the community.
**Consequence**: A private, written warning from community leaders, providing clarity
around the nature of the violation and an explanation of why the behavior was inappropriate.
A public apology may be requested.
### 2. Warning
**Community Impact**: A violation through a single incident or series of actions.
**Consequence**: A warning with consequences for continued behavior. No interaction with the people involved,
including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time.
This includes avoiding interactions in community spaces as well as external channels like social media.
Violating these terms may lead to a temporary or permanent ban.
### 3. Temporary Ban
**Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
**Consequence**: A temporary ban from any sort of interaction or public communication with
the community for a specified period of time. No public or private interaction with the people involved,
including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period.
Violating these terms may lead to a permanent ban.
### 4. Permanent Ban
**Community Impact**: Demonstrating a pattern of violation of community standards, including sustained
inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
**Consequence**: A permanent ban from any sort of public interaction within the community.
## Attribution
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
available at <https://www.contributor-covenant.org/version/2/0/code_of_conduct.html>.
Community Impact Guidelines were inspired by
[Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
For answers to common questions about this code of conduct,
see the FAQ at <https://www.contributor-covenant.org/faq>.
Translations are available at <https://www.contributor-covenant.org/translations>.
[homepage]: https://www.contributor-covenant.org
# Contributing
## Versioning
- All notable changes to this project will be documented in [CHANGELOG](CHANGELOG.md) file.
- This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
```shell
MAJOR.MINOR.PATCH
# MAJOR ---> a breaking change: incompatible changes (ex: reorganization of directories)
# MINOR ---> add a new feature: a new Docker image (ex: new Asqtasun version)
# PATCH ---> fix a bug
```
## Git Commit message convention
We follow [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) :
```xml
<type>[(optional scope)]: <description>
[optional body]
[optional footer(s)]
```
> common types:
>
> - `build`: changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm).
> - `ci`: changes to the CI configuration files and scripts
> - `chore`: update something without impacting the user (ex: bump a dependency in composer.json).
> - `docs`: documentation only changes
> - `feat`: add a new feature (equivalent to a `MINOR` in Semantic Versioning)
> - `fix`: fix a bug (equivalent to a `PATCH` in Semantic Versioning).
> - `perf`: a code change that improves performance.
> - `refactor`: a code change that neither fixes a bug nor adds a feature.
> - `revert`: revert a commit.
> - `style`: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc).
> - `test`: adding missing tests, refactoring tests; no production code change.
The commit message should follow this regex:
```perl
/^(revert: )?(build|ci|chore|docs|feat|fix|perf|refactor|style|refactor|revert|style|test|)(\(.+\))?: .{1,50}/
```
This diff is collapsed.