Skip to content
Snippets Groups Projects
Commit 80084d72 authored by Sebastien's avatar Sebastien
Browse files

Merge branch 'tuleap-33-create-a-pre-commit-hook-as-a-ci' into 'main'

Create a pre-commit hook as a CI

See merge request !13
parents 40d8b871 67adba61
No related branches found
No related tags found
1 merge request!13Create a pre-commit hook as a CI
# MemoRekallMember web app
This project has been created to help artists document their creative process with video notes and documents.
## Contributors
The Tetras Libre team follows some code quality requirements.
Indeed, to ensure the respect of the standards PHP rules, we use a pre-commit hook as a safety net before sending any contribution.
The following quality tool scripts will be triggered before reaching commit message editor.
- **PHPUnit** (functional and unit tests)
- **PHP_CodeSniffer** (for PSR standards)
- **PHPSTAN** (for static analysis)
***
### How to run the code quality scripts?
First, you need to enter the memorekall-member docker container: `docker-compose exec memorekall-member bash`
- To run the script independently of a commit: `composer {phpcs/phpstan/tests}`
- To fix PHP_CodeSniffer errors: `composer phpcbf`
- To run them all: `composer ci`
### How to contribute to the MemoRekall project?
Please configure your local git as follows:
1. From your terminal, run: `git global core.hooksPath ./tools/git-hooks/`
2. Make the pre-commit hook executable running: `sudo chmod +x ./tools/git-hooks/pre-commit`
\ No newline at end of file
......@@ -101,14 +101,14 @@
"@auto-scripts"
],
"ci": [
"@php_codesniffer",
"@phpstan",
"@unit-tests"
"@tests",
"@phpcs",
"@phpstan"
],
"php-cs-fixer": "tools/php-cs-fixer/vendor/bin/php-cs-fixer fix src/",
"php_codesniffer": "php ./vendor/bin/phpcs",
"phpstan": "vendor/bin/phpstan analyse src/",
"unit-tests": "php ./vendor/bin/phpunit"
"tests": "php ./vendor/bin/phpunit",
"phpcs": "php ./vendor/bin/phpcs src/ tests/",
"phpstan": "vendor/bin/phpstan analyse src/ tests/unit/ tests/functional/",
"php-cs-fixer": "tools/php-cs-fixer/vendor/bin/php-cs-fixer fix src/ tests/unit/ tests/functional/"
},
"conflict": {
"symfony/symfony": "*"
......
#!/bin/bash
REDBOLD='\033[0;31;1m'
GREENBOLD='\033[0;32;1m'
BOLD='\033[1m'
NORMAL='\033[0m'
echo -e "\n ${BOLD} Starting Unit and Functional Tests...\n ${NORMAL}"
composer tests
if [ $? != 0 ]; then
echo -e "\n ${REDBOLD} Unit tests failed \n ${NORMAL}"
exit 1;
else
echo -e "\n ${GREENBOLD} Unit and functional tests passed successfully! ${NORMAL} \n"
fi
echo -e "\n ${BOLD} Starting PHP_CodeSniffer... \n ${NORMAL}"
composer phpcs
if [ $? != 0 ]; then
echo -e "\n ${REDBOLD} PHPCS verification failed \n ${NORMAL}"
exit 1;
else
echo -e "\n ${GREENBOLD} Your code passed PHP_CodeSniffer successfully! ${NORMAL} \n"
fi
echo -e "\n ${BOLD} Starting PHPStan... \n ${NORMAL}"
composer phpstan
if [ $? != 0 ]; then
echo -e "\n ${REDBOLD} PHPStan verification failed \n ${NORMAL}"
exit 1;
else
echo -e "\n ${GREENBOLD} Your code passed static analysis successfully! \n
\n Committing your changes now... \n ${NORMAL}"
fi
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment