Skip to content
Snippets Groups Projects
Commit 7d185cce authored by Fabrice Gangler's avatar Fabrice Gangler :art:
Browse files

ci: enabled GiltabCI

parent c7b12a57
No related branches found
No related tags found
No related merge requests found
Pipeline #75169 failed
Showing
with 1581 additions and 0 deletions
---
stages:
- php8.1
- linter
- release
- documentation
- php8.2
- php8.3
include:
- local: /.gitlab/ci/job.documentation.gitlab-ci.yml
- local: /.gitlab/ci/job.linters.gitlab-ci.yml
- local: /.gitlab/ci/job.php.gitlab-ci.yml
# CI ~ Docker images of prerequisites
Docker images of prerequisites usign by **Gitlab CI**:
- [PHP 8.1, Composer and Phive](./php.8.1_composer_phive/)
- [PHP 8.2, Composer and Phive](./php.8.2_composer_phive/)
- [PHP 8.3, Composer and Phive](./php.8.2_composer_phive/)
FROM ubuntu:22.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.1 \
php8.1-bcmath \
php8.1-curl \
php8.1-intl \
php8.1-mbstring \
php8.1-pgsql \
php8.1-xml \
php8.1-zip && \
rm -rf /var/lib/apt/lists/*
# QA prerequisites - Install PHIVE
RUN curl -sSL https://phar.io/releases/phive.phar --output phive.phar && \
chmod +x phive.phar && \
mv -v phive.phar /usr/local/bin/phive && \
phive --version
# 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
# Install all phar files declared in phive.xml
WORKDIR "/php/"
RUN REPO=https://gitlab.adullact.net/adullact/pki/tajine.git && \
pwd && \
git clone ${REPO} && \
cd tajine/ && \
phive install --force-accept-unsigned \
--trust-gpg-keys \
661E97400F658E25,96141E4421A9B0D5,033E5F8D801A2F8D,F4D32E2C9343B2AE,B8F640134AB1782E,AA36B9960B5B823D,C5095986493B4AA0,8101FB57DD8130F0,95DE904AB800754A11D80B605E6DDE998AB73B8E,4AA394086372C20A,9093F8B32E4815AA,51C67305FFC2E5C0,E82B2FB314E9906E,12CE0F1D262429A5 && \
cd webapp/ && \
composer install --no-progress \
--no-suggest \
--no-interaction \
--no-scripts && \
rm -rf /php/tajine/
# 661E97400F658E25 ---> captainhook
# 96141E4421A9B0D5 ---> churn
# 033E5F8D801A2F8D ---> composer-require-checker
# F4D32E2C9343B2AE ---> composer-unused
# B8F640134AB1782E ---> deptrac
# AA36B9960B5B823D ---> grumphp
# C5095986493B4AA0 ---> infection
# 8101FB57DD8130F0 ---> phan
# 95DE904AB800754A11D80B605E6DDE998AB73B8E ---> phpcbf, phpcs
# 4AA394086372C20A ---> phpcpd, phploc, phpunit
# 9093F8B32E4815AA ---> phpmd
# 51C67305FFC2E5C0 ---> phpstan
# E82B2FB314E9906E ---> php-cs-fixer
# ---> php-parallel-lint ---> TODO use --force-accept-unsigned option
# 12CE0F1D262429A5 ---> psalm
# CI prerequisites - Install PHP extensions mandatory to use Infection tool
RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive \
apt-get -y --no-install-recommends \
install php8.1-xdebug && \
rm -rf /var/lib/apt/lists/*
# Check cache
RUN ls -l /root/.phive/phars/ && \
du -hs /root/.phive/phars/ && \
du -hs /root/.cache/composer/
# Display software versions
RUN echo "-------------------" && php --version && \
echo "-------------------" && composer -V && \
echo "-------------------" && phive --version && \
echo "-------------------" && symfony -V && \
echo "-------------------"
# Set Docker LABEL
LABEL version="1.0.0" \
description="Prerequisites for PHP 8.1, Composer, Phive, Symfony-CLI, Xdebug and Make"
# CI ~ Prerequisites for PHP 8.1, Composer, Phive, ...
Docker image of prerequisites for PHP **8.1**, Composer, Phive, Symfony-CLI, Xdebug and 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="Checksum_Comptoir1.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="Checksum_Comptoir1.0.0" \
description="Prerequisites for PHP 8.1, Composer, Phive, 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/adullact/pki/tajine/container_registry)
```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="adullact/pki/tajine"
DOCKER_IMAGE_NAME="php-8.1_composer_phive"
DOCKER_IMAGE_VERSION="vChecksum_Comptoir1.0.0" # must be identical to LABEL.version in Dockerfile
# Login to Gitlab
docker login "${GITLAB_URI}"
# 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
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}"
```
FROM ubuntu:22.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.2 \
php8.2-bcmath \
php8.2-curl \
php8.2-intl \
php8.2-mbstring \
php8.2-pgsql \
php8.2-xml \
php8.2-zip && \
rm -rf /var/lib/apt/lists/*
# QA prerequisites - Install PHIVE
RUN curl -sSL https://phar.io/releases/phive.phar --output phive.phar && \
chmod +x phive.phar && \
mv -v phive.phar /usr/local/bin/phive && \
phive --version
# 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
# Install all phar files declared in phive.xml
WORKDIR "/php/"
RUN REPO=https://gitlab.adullact.net/adullact/pki/tajine.git && \
pwd && \
git clone ${REPO} && \
cd tajine/ && \
phive install --force-accept-unsigned \
--trust-gpg-keys \
661E97400F658E25,96141E4421A9B0D5,033E5F8D801A2F8D,F4D32E2C9343B2AE,B8F640134AB1782E,AA36B9960B5B823D,C5095986493B4AA0,8101FB57DD8130F0,95DE904AB800754A11D80B605E6DDE998AB73B8E,4AA394086372C20A,9093F8B32E4815AA,51C67305FFC2E5C0,E82B2FB314E9906E,12CE0F1D262429A5 && \
cd webapp/ && \
composer install --no-progress \
--no-suggest \
--no-interaction \
--no-scripts && \
rm -rf /php/tajine/
# 661E97400F658E25 ---> captainhook
# 96141E4421A9B0D5 ---> churn
# 033E5F8D801A2F8D ---> composer-require-checker
# F4D32E2C9343B2AE ---> composer-unused
# B8F640134AB1782E ---> deptrac
# AA36B9960B5B823D ---> grumphp
# C5095986493B4AA0 ---> infection
# 8101FB57DD8130F0 ---> phan
# 95DE904AB800754A11D80B605E6DDE998AB73B8E ---> phpcbf, phpcs
# 4AA394086372C20A ---> phpcpd, phploc, phpunit
# 9093F8B32E4815AA ---> phpmd
# 51C67305FFC2E5C0 ---> phpstan
# E82B2FB314E9906E ---> php-cs-fixer
# ---> php-parallel-lint ---> TODO use --force-accept-unsigned option
# 12CE0F1D262429A5 ---> psalm
# CI prerequisites - Install PHP extensions mandatory to use Infection tool
RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive \
apt-get -y --no-install-recommends \
install php8.2-xdebug && \
rm -rf /var/lib/apt/lists/*
# Check cache
RUN ls -l /root/.phive/phars/ && \
du -hs /root/.phive/phars/ && \
du -hs /root/.cache/composer/
# Display software versions
RUN echo "-------------------" && php --version && \
echo "-------------------" && composer -V && \
echo "-------------------" && phive --version && \
echo "-------------------" && symfony -V && \
echo "-------------------"
# Set Docker LABEL
LABEL version="1.0.0" \
description="Prerequisites for PHP 8.2, Composer, Phive, Symfony-CLI, Xdebug and Make"
# CI ~ Prerequisites for PHP 8.2, Composer and Phive
Docker image of prerequisites for PHP **8.2**, Composer and Phive.
## 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="Prerequisites for PHP 8.2, Composer and Phive"
```
### Build Docker image and push to container registry
Build new Docker image and push to [Gitlab container registry](https://gitlab.adullact.net/adullact/pki/tajine/container_registry)
```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="adullact/pki/tajine"
DOCKER_IMAGE_NAME="php-8.2_composer_phive"
DOCKER_IMAGE_VERSION="v1.0.0" # must be identical to LABEL.version in Dockerfile
# Login to Gitlab
docker login "${GITLAB_URI}"
# 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
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}"
```
FROM ubuntu:22.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.3 \
php8.3-bcmath \
php8.3-curl \
php8.3-intl \
php8.3-mbstring \
php8.3-pgsql \
php8.3-xml \
php8.3-zip && \
rm -rf /var/lib/apt/lists/*
# QA prerequisites - Install PHIVE
RUN curl -sSL https://phar.io/releases/phive.phar --output phive.phar && \
chmod +x phive.phar && \
mv -v phive.phar /usr/local/bin/phive && \
phive --version
# 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
# Install all phar files declared in phive.xml
WORKDIR "/php/"
RUN REPO=https://gitlab.adullact.net/adullact/pki/tajine.git && \
pwd && \
git clone ${REPO} && \
cd tajine/ && \
phive install --force-accept-unsigned \
--trust-gpg-keys \
661E97400F658E25,96141E4421A9B0D5,033E5F8D801A2F8D,F4D32E2C9343B2AE,B8F640134AB1782E,AA36B9960B5B823D,C5095986493B4AA0,8101FB57DD8130F0,95DE904AB800754A11D80B605E6DDE998AB73B8E,4AA394086372C20A,9093F8B32E4815AA,51C67305FFC2E5C0,E82B2FB314E9906E,12CE0F1D262429A5 && \
cd webapp/ && \
composer install --no-progress \
--no-suggest \
--no-interaction \
--no-scripts && \
rm -rf /php/tajine/
# 661E97400F658E25 ---> captainhook
# 96141E4421A9B0D5 ---> churn
# 033E5F8D801A2F8D ---> composer-require-checker
# F4D32E2C9343B2AE ---> composer-unused
# B8F640134AB1782E ---> deptrac
# AA36B9960B5B823D ---> grumphp
# C5095986493B4AA0 ---> infection
# 8101FB57DD8130F0 ---> phan
# 95DE904AB800754A11D80B605E6DDE998AB73B8E ---> phpcbf, phpcs
# 4AA394086372C20A ---> phpcpd, phploc, phpunit
# 9093F8B32E4815AA ---> phpmd
# 51C67305FFC2E5C0 ---> phpstan
# E82B2FB314E9906E ---> php-cs-fixer
# ---> php-parallel-lint ---> TODO use --force-accept-unsigned option
# 12CE0F1D262429A5 ---> psalm
# CI prerequisites - Install PHP extensions mandatory to use Infection tool
RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive \
apt-get -y --no-install-recommends \
install php8.3-xdebug && \
rm -rf /var/lib/apt/lists/*
# Check cache
RUN ls -l /root/.phive/phars/ && \
du -hs /root/.phive/phars/ && \
du -hs /root/.cache/composer/
# Display software versions
RUN echo "-------------------" && php --version && \
echo "-------------------" && composer -V && \
echo "-------------------" && phive --version && \
echo "-------------------" && symfony -V && \
echo "-------------------"
# Set Docker LABEL
LABEL version="1.0.0" \
description="Prerequisites for PHP 8.3, Composer, Phive, Symfony-CLI, Xdebug and Make"
# CI ~ Prerequisites for PHP 8.3, Composer and Phive
Docker image of prerequisites for PHP **8.3**, Composer and Phive.
## 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="Prerequisites for PHP 8.3, Composer and Phive"
```
### Build Docker image and push to container registry
Build new Docker image and push to [Gitlab container registry](https://gitlab.adullact.net/adullact/pki/tajine/container_registry)
```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="adullact/pki/tajine"
DOCKER_IMAGE_NAME="php-8.3_composer_phive"
DOCKER_IMAGE_VERSION="v1.0.0" # must be identical to LABEL.version in Dockerfile
# Login to Gitlab
docker login "${GITLAB_URI}"
# 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
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}"
```
---
###############################################################
# 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
# MD034 - Bare URL used
# https://github.com/DavidAnson/markdownlint/blob/main/doc/Rules.md#md034---bare-url-used
MD034: 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 ######################################################################################################
# Vagrant-Validate ---> Vagrantfile 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
##################################################################################################################
###############################################################
# Vagrant https://www.vagrantup.com/docs/cli/validate
# --> a CI job that will validate Vagrantfile
###############################################################
Vagrantfile_linter:
stage: linter
needs:
- php8.1_linter
rules:
- if: $CI_PIPELINE_SOURCE == "push"
# when: manual
# allow_failure: true
image: debian:buster-slim
variables:
vagrant_version: "2.2.19"
before_script:
- apt-get update
- apt-get -y --no-install-recommends install wget ca-certificates
- wget --quiet "https://releases.hashicorp.com/vagrant/${vagrant_version}/vagrant_${vagrant_version}_x86_64.deb"
- dpkg -i "vagrant_${vagrant_version}_x86_64.deb"
- vagrant --version
script:
- cd "${CI_PROJECT_DIR}/documentation/developer/vagrant_prototype/vagrant_tajine_ubuntu-22.04"
- vagrant validate --ignore-provider
# - VAGRANT_LOG=info vagrant validate --ignore-provider
###############################################################
# 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/adullact/pki/tajine/php-8.1_composer_phive:v1.3.4
.php8.2_template:
stage: php8.2
image: gitlab.adullact.net:4567/adullact/pki/tajine/php-8.2_composer_phive:v1.2.1
.php8.3_template:
stage: php8.3
image: gitlab.adullact.net:4567/adullact/pki/tajine/php-8.3_composer_phive:v1.0.1
##################################################################################
# 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 "-------------------" && phive --version
- 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
.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
needs:
- php8.1_linter
# - php8.1_tests
rules:
- if: $CI_PIPELINE_SOURCE == "push"
# when: manual
# allow_failure: true
before_script:
- make phive_install_auto-trust-of-predefined-gpg-keys
- 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
#######################################################################
# 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
.php_linter_template:
needs: []
rules:
- if: $CI_PIPELINE_SOURCE == "push"
# when: manual
# allow_failure: true
cache:
paths:
- /root/.phive
- ${CI_PROJECT_DIR}/bin/.phive
before_script:
- phive --version
- du -hs bin/
- ls -la bin/
- make phive_install_auto-trust-of-predefined-gpg-keys
- ls -l bin/.phive
- du -hs bin/
script:
# - cd "${PHP_WEBAPP_DIR}"
# - composer install --no-dev --no-progress --no-suggest --no-interaction --no-scripts
- 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']
needs:
- php8.1_linter
rules:
- if: $CI_PIPELINE_SOURCE == "push"
# when: manual
# allow_failure: true
cache:
paths:
- /root/.phive
- ${CI_PROJECT_DIR}/bin/.phive
before_script:
- phive --version
- du -hs bin/
- ls -la bin/
- make phive_install_auto-trust-of-predefined-gpg-keys
- ls -l bin/.phive
- du -hs bin/
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
.composer_validate_template:
needs: []
rules:
- if: $CI_PIPELINE_SOURCE == "push"
# when: manual
# allow_failure: true
cache:
paths:
- /root/.phive
- /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/.phive
- /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 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/major.minor.patch/${CI_COMMIT_TAG}/" "${PHP_WEBAPP_DIR}/config/services.yaml"
- 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
Makefile 0 → 100644
WEBAPP_DIR = "./webapp"
AUTO_DOC_DIR = "documentation/auto-generated-documentation"
AUTO_DOC_ROUTES_DIR = "./$(AUTO_DOC_DIR)/webapp_routes"
AUTO_DOC_PHPUNIT_DIR = "../../$(AUTO_DOC_DIR)/tests_phpunit"
AUTO_DOC_PSALM_DIR = "../../$(AUTO_DOC_DIR)/php_static-analysis_psalm"
AUTO_DOC_PHPMD_DIR = "./$(AUTO_DOC_DIR)/php_static-analysis_phpmd"
INFECTION_PHPUNIT_OPTION = "--group=allow_mutation_testing_by_infection"
DOCKER_COMPOSE = $(WEBAPP_DIR)/docker-compose
CONSOLE = $(WEBAPP_DIR)/bin/console
PHPUNIT = $(WEBAPP_DIR)/bin/phpunit
## === SYMFONY Routes ================================================
verif_autodoc_routes: ## Check that Symfony route auto-documentation files are up to date
$(CONSOLE) debug:route --env=prod --format=json --show-controllers > $(AUTO_DOC_ROUTES_DIR)/webapp_routes_prod.json
$(CONSOLE) debug:route --env=prod --format=md --show-controllers > $(AUTO_DOC_ROUTES_DIR)/webapp_routes_prod.md
$(CONSOLE) debug:route --env=prod --format=txt --show-controllers --no-ansi > $(AUTO_DOC_ROUTES_DIR)/webapp_routes_prod.txt
git diff --name-only
cat $(AUTO_DOC_ROUTES_DIR)/webapp_routes_prod.txt;
@if [ `git diff --name-only | grep "webapp_routes_prod." | wc -l` -gt 0 ]; then \
echo ""; \
git diff --no-color $(AUTO_DOC_ROUTES_DIR)/webapp_routes_prod.txt ; \
echo "----> ERROR: auto-generated documentation is not up-to-date ---> webapp_routes"; \
echo " fix it with folling command line: "; \
echo " make autodoc_routes"; \
echo ""; \
exit 1; \
fi;
# fi; > /dev/null 2>&1
.PHONY: verif_autodoc_routes
autodoc_routes: ## Generating Symfony route auto-documentation files
# $(CONSOLE) debug:route --env=dev --format=json --show-controllers > webapp_routes_dev.json
# $(CONSOLE) debug:route --env=dev --format=md --show-controllers > webapp_routes_dev.md
# $(CONSOLE) debug:route --env=dev --format=txt --show-controllers > webapp_routes_dev.txt
$(CONSOLE) debug:route --env=prod --format=json --show-controllers > $(AUTO_DOC_ROUTES_DIR)/webapp_routes_prod.json
$(CONSOLE) debug:route --env=prod --format=md --show-controllers > $(AUTO_DOC_ROUTES_DIR)/webapp_routes_prod.md
$(CONSOLE) debug:route --env=prod --format=txt --show-controllers --no-ansi > $(AUTO_DOC_ROUTES_DIR)/webapp_routes_prod.txt
$(CONSOLE) debug:route --env=prod --format=txt --show-controllers
.PHONY: autodoc_routes
routes: ## Display Symfony routes
$(CONSOLE) debug:route --env=prod --format=txt --show-controllers
.PHONY: routes
## === SYMFONY database ================================================
migration_database: ## Apply Doctrine migrations
cd "${WEBAPP_DIR}" && bin/console doctrine:migrations:migrate -n --env=dev
cd "${WEBAPP_DIR}" && bin/console doctrine:migrations:list --env=dev
.PHONY: migration_database
## === DOCKER ================================================
cfssl_run_fake_server: ## Run fake CFSSL server
cd "${WEBAPP_DIR}/data/cfssl_fake-server" && php -S 127.0.0.1:9999
.PHONY: cfssl_run_fake_server
docker: ## Run Docker containers (database, mailcatcher)
cd "${WEBAPP_DIR}/docker" && docker-compose up
.PHONY: docker
docker_clean_database: ## Clean up Docker containers (database, mailcatcher)
cd "${WEBAPP_DIR}/docker" && docker compose down --volumes
cd "${WEBAPP_DIR}/docker" && docker compose rm --force --stop --volumes
.PHONY: docker_clean_database
docker_with_empty-database: ## Run Docker containers (database, mailcatcher) with empty database
cd "${WEBAPP_DIR}/docker" && docker compose down --volumes
cd "${WEBAPP_DIR}/docker" && docker compose rm --force --stop --volumes
cd "${WEBAPP_DIR}/docker" && docker-compose up
.PHONY: docker_with_empty-database
## === TESTS ================================================
tests: ## Run all tests (PhpUnit)
rm -rvf "${WEBAPP_DIR}/var/tmp/" || true
cd "${WEBAPP_DIR}" && bin/console doctrine:database:drop --force --env=test || true
cd "${WEBAPP_DIR}" && bin/console doctrine:database:create --env=test
cd "${WEBAPP_DIR}" && bin/console doctrine:migrations:migrate -n --env=test
cd "${WEBAPP_DIR}" && bin/console doctrine:fixtures:load -n --env=dev
cd "${WEBAPP_DIR}" && bin/console doctrine:fixtures:load -n --env=test
cd "${WEBAPP_DIR}" && bin/console doctrine:fixtures:load -n
cd "${WEBAPP_DIR}" && XDEBUG_MODE=coverage bin/phpunit --testdox --strict-coverage --configuration phpunit.xml.dist
# cd "${WEBAPP_DIR}" && bin/phpunit --no-coverage --configuration phpunit.xml.dist
# cd "${WEBAPP_DIR}" && bin/phpunit --coverage-text --configuration phpunit.xml
.PHONY: tests
tests_gogogo: ## Run "gogogo" group tests (PhpUnit)
rm -rvf "${WEBAPP_DIR}/var/tmp/" || true
cd "${WEBAPP_DIR}" && bin/console doctrine:database:drop --force --env=test || true
cd "${WEBAPP_DIR}" && bin/console doctrine:database:create --env=test
cd "${WEBAPP_DIR}" && bin/console doctrine:migrations:migrate -n --env=test
cd "${WEBAPP_DIR}" && bin/console doctrine:fixtures:load -n --env=dev
cd "${WEBAPP_DIR}" && bin/console doctrine:fixtures:load -n --env=test
cd "${WEBAPP_DIR}" && bin/console doctrine:fixtures:load -n
cd "${WEBAPP_DIR}" && bin/phpunit --testdox --group gogogo --configuration phpunit.xml.dist
# cd "${WEBAPP_DIR}" && bin/phpunit --no-coverage --configuration phpunit.xml.dist
# cd "${WEBAPP_DIR}" && bin/phpunit --coverage-text --configuration phpunit.xml
.PHONY: tests_gogogo
tests_coverage: ## Run all tests (PhpUnit) and save coverage in an HTML file
rm -rvf "${WEBAPP_DIR}/var/tmp/" || true
cd "${WEBAPP_DIR}" && \
XDEBUG_MODE=coverage \
bin/phpunit --configuration phpunit.xml.dist --testdox --strict-coverage --coverage-text --coverage-html "${AUTO_DOC_PHPUNIT_DIR}"
.PHONY: tests_coverage
tests_mutation: ## Run mutation tests (Infection)
rm -rf "${WEBAPP_DIR}/var/tmp/" || true
cd "${WEBAPP_DIR}" && ../../bin/infection --min-covered-msi=70 --min-msi=20 --test-framework-options="${INFECTION_PHPUNIT_OPTION}"
# cd "${WEBAPP_DIR}" && ../../bin/infection --logger-html="${AUTO_DOC_INFECTION_FILE}" --test-framework-options="${INFECTION_PHPUNIT_OPTION}"
.PHONY: tests_mutation
tests_repeat: ## Run all tests (PhpUnit) multiple times
rm -rvf "${WEBAPP_DIR}/var/tmp/" || true
cd "${WEBAPP_DIR}" && bin/phpunit --testdox --no-coverage --configuration phpunit.xml.dist --repeat 10
.PHONY: tests_repeat
## === CODING STANDART ================================================
sf_coding-standard: ## ...
bin/php-cs-fixer fix -vvv --diff --dry-run webapp/src/
bin/php-cs-fixer fix -vvv --diff --dry-run webapp/tests/
.PHONY: sf_coding-standard
sf_fix-coding-standard: ## ...
bin/php-cs-fixer fix -vvv --diff webapp/src/
bin/php-cs-fixer fix -vvv --diff webapp/tests/
.PHONY: sf_fix-coding-standard
php_coding-standard: ## ...
bin/phpcs --standard=PSR12 --colors webapp/src/ webapp/tests/ -s
.PHONY: php_coding-standard
php_coding-standard_diff: ## ...
bin/phpcs --standard=PSR12 --colors webapp/src/ webapp/tests/ --report=diff
.PHONY: php_coding-standard_diff
php_coding-standard_summary: ## ...
bin/phpcs --standard=PSR12 --colors webapp/src/ webapp/tests/ --report=summary
.PHONY: php_coding-standard_summary
php_fix-coding-standard: ## ...
bin/phpcbf --standard=PSR12 --colors webapp/src/ webapp/tests/
.PHONY: php_fix-coding-standard
## === OTHER ================================================
php_linter: ## ...
bin/parallel-lint --colors webapp/ --exclude webapp/vendor/ --exclude webapp/var/
.PHONY: php_linter
analyse_php_psalm: ## ...
bin/psalm --root webapp/ --report="${AUTO_DOC_PSALM_DIR}/Psalm_report.console" \
--report="${AUTO_DOC_PSALM_DIR}/Psalm_report.txt"
.PHONY: analyse_php_psalm
analyse_php_psalm_show-info: ## ...
bin/psalm --root webapp/ --show-info=true --report="${AUTO_DOC_PSALM_DIR}/Psalm_report.console" \
--report="${AUTO_DOC_PSALM_DIR}/Psalm_report.txt"
.PHONY: analyse_php_psalm_show-info
analyse_php_stan: ## ...
bin/phpstan analyse --level=0 webapp/src/
bin/phpstan analyse --level=0 webapp/tests/
.PHONY: analyse_php_stan
analyse_php_stan_max: ## ...
bin/phpstan analyse --level=9 webapp/src/
bin/phpstan analyse --level=9 webapp/tests/
.PHONY: analyse_php_stan_max
analyse_php_md: ## ...
bin/phpmd webapp/src/ ansi cleancode,codesize,controversial,design,unusedcode --baseline-file "${WEBAPP_DIR}/phpmd.baseline.xml"
# bin/phpmd webapp/src/ ansi cleancode,codesize,controversial,design,unusedcode,naming --baseline-file "${WEBAPP_DIR}/phpmd.baseline.xml"
.PHONY: analyse_php_md
analyse_php_md_create-violation-baseline: ## ...
bin/phpmd webapp/src/ ansi cleancode,codesize,controversial,design,unusedcode,naming --generate-baseline --baseline-file "${WEBAPP_DIR}/phpmd.baseline.xml"
# bin/phpmd webapp/src/ ansi cleancode,codesize,controversial,design,unusedcode,naming --generate-baseline --baseline-file "${WEBAPP_DIR}/phpmd.baseline.xml"
.PHONY: analyse_php_md_create-violation-baseline
analyse_php_md_report_html: ## ...
bin/phpmd webapp/src/ html cleancode,codesize,controversial,design,unusedcode > "${AUTO_DOC_PHPMD_DIR}/PhpMD_report.html"
# bin/phpmd webapp/src/ html cleancode,codesize,controversial,design,unusedcode,naming > "${AUTO_DOC_PHPMD_DIR}/PhpMD_report.html"
.PHONY: analyse_php_md_report_html
analyse_php_md_report_gitlab: ## ...
bin/phpmd webapp/src/ gitlab cleancode,codesize,controversial,design,unusedcode > "${AUTO_DOC_PHPMD_DIR}/PhpMD_gitlab-report.json"
# bin/phpmd webapp/src/ gitlab cleancode,codesize,controversial,design,unusedcode,naming > "${AUTO_DOC_PHPMD_DIR}/PhpMD_gitlab-report.json"
.PHONY: analyse_php_md_report_gitlab
composer_install: ## ...
cd webapp/ && composer install
.PHONY: composer_install
# Checks for outdated packages
# ####################################################################
ci_outdated_php_packages: ## ...
cd "${WEBAPP_DIR}" && composer update --no-install --no-interaction --no-progress --no-scripts --no-audit
@if [ `git diff --name-only | grep "composer.lock" | wc -l` -gt 0 ]; then \
echo ""; \
echo "----> ERROR: Some PHP packages are outdated"; \
echo " fix it with folling command line: "; \
echo " composer update"; \
echo ""; \
exit 1; \
fi;
.PHONY: ci_outdated_php_packages
outdated_php_packages: ## ...
composer update --working-dir=${WEBAPP_DIR} --no-install --no-audit --dry-run --no-interaction --no-progress --no-scripts
# composer update --working-dir=${WEBAPP_DIR} --no-install --no-audit --dry-run --no-interaction --no-progress --no-scripts 2>&1 | grep "Nothing to modify in lock file"
.PHONY: outdated_php_packages
# Checks for security vulnerability
# ####################################################################
# Check WEBAPP security with `composer audit` command line
# - checks for security vulnerability advisories
# - based only on the installed packages [ vendor/ ]
# - use : GitHub Advisory Database https://github.com/advisories
# PHP Security Advisories Database https://github.com/FriendsOfPHP/security-advisories
security_vendor: ## ...
cd webapp/ && composer audit
.PHONY: security_vendor
# Check WEBAPP security with `composer audit --locked` command line
# - 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
security_composer.lock: ## ...
cd webapp/ && composer audit --locked
.PHONY: security_composer.lock
# Check WEBAPP security with Symfony-CLI
# - checks for security vulnerability advisories
# - based only on the composer.lock file (including dev packages)
# - use : PHP Security Advisories Database https://github.com/FriendsOfPHP/security-advisories
security_composer.lock_via-symfony-cli: ## ...
symfony check:security --dir=webapp/ --format=ansi
.PHONY: security_composer.lock_via-symfony-cli
# Check WEBAPP security with TRIVY
# - checks webapp for security vulnerability advisories
# - based only on the composer.lock file, (excluding dev packages)
# - use : GitHub Advisory Database https://github.com/advisories
# PHP Security Advisories Database https://github.com/FriendsOfPHP/security-advisories
security_composer.lock_via-trivy: ## ...
cd webapp/ && \
trivy fs . --dependency-tree \
--security-checks=vuln \
--skip-dirs documentation/developer/vagrant_prototype/
.PHONY: security_composer.lock_via-trivy
# Check repository security with TRIVY for security, config and secret vulnerabilities
# - checks repository for security, config and secret vulnerabilities
check-security_via-trivy: ## ...
trivy fs . --dependency-tree \
--security-checks=vuln,config,secret,license \
--skip-dirs documentation/developer/vagrant_prototype/
.PHONY: check-security_via-trivy
# ######################################################################
phive_clean: ## ...
rm -vr ~/.phive/
.PHONY: phive_clean
phive_clean_full: ## ...
rm -vr ~/.phive/
rm -vr ./bin/.phive/
.PHONY: phive_clean_full
phive_install: ## ...
phive install
# phive install --force-accept-unsigned
.PHONY: phive_install
phive_install_auto-trust-of-predefined-gpg-keys: ## ...
# phive install --force-accept-unsigned php-parallel-lint/php-parallel-lint
phive install --force-accept-unsigned --trust-gpg-keys \
661E97400F658E25,96141E4421A9B0D5,033E5F8D801A2F8D,F4D32E2C9343B2AE,\
B8F640134AB1782E,AA36B9960B5B823D,C5095986493B4AA0,8101FB57DD8130F0,95DE904AB800754A11D80B605E6DDE998AB73B8E,\
4AA394086372C20A,9093F8B32E4815AA,51C67305FFC2E5C0,E82B2FB314E9906E,12CE0F1D262429A5
# 661E97400F658E25 ---> captainhook
# 96141E4421A9B0D5 ---> churn
# 033E5F8D801A2F8D ---> composer-require-checker
# F4D32E2C9343B2AE ---> composer-unused
# B8F640134AB1782E ---> deptrac
# AA36B9960B5B823D ---> grumphp
# C5095986493B4AA0 ---> infection
# 8101FB57DD8130F0 ---> phan
# 95DE904AB800754A11D80B605E6DDE998AB73B8E ---> phpcbf, phpcs
# 4AA394086372C20A ---> phpcpd, phploc, phpunit
# 9093F8B32E4815AA ---> phpmd
# 51C67305FFC2E5C0 ---> phpstan
# E82B2FB314E9906E ---> php-cs-fixer
# ---> php-parallel-lint ---> TODO use --force-accept-unsigned option
# 12CE0F1D262429A5 ---> psalm
.PHONY: phive_install_auto-trust-of-predefined-gpg-keys
# Default goal and help
## === 🆘 HELP ==================================================
.DEFAULT_GOAL := help
help: ## Show this help.
@echo "Makefile TAJINE"
@echo ""
@echo "Usage: make [target]"
@echo "---------------------------"
@echo ""
@echo "Targets:"
@grep -E '(^[a-zA-Z0-9_-]+:.*?##.*$$)|(^##)' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}{printf "\033[32m%-30s\033[0m %s\n", $$1, $$2}' | sed -e 's/\[32m##/[33m/'
# @grep -E '(^[a-zA-Z_-]+:.*?##.*$$)|(^##)' $(MAKEFILE_LIST) | sed -e 's/^Makefile:\(.*\)/\1/' | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[32m%-30s\033[0m %s\n", $$1, $$2}' | sed -e 's/\[32m##/[33m/'
.PHONY: help
#---------------------------------------------#
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment