xip-solid-foundation/pre-commit
Composer 安装命令:
composer require xip-solid-foundation/pre-commit
包简介
Package for pre-commit hook and basic testing
README 文档
README
A pre-commit hook installer with basic testing
Pre-requisite
- Docker Compose, install Docker Compose
- PHP docker image
You may use Symfony-Docker to download and install Docker for Symfony.
Installation
Applications that use Symfony Flex Installation
$ composer require xip-solid-foundation/pre-commit
Applications that don't use Symfony Flex
Step 1: Install the Bundle
Open a command console, enter your project directory and execute the following command to install the latest stable version of this bundle:
$ composer require xip-solid-foundation/pre-commit
Step 2: Added Pre-commit file
Example:
# Automatic usage by installing symbolic link:
# ln -sf ../../bin/pre-commit .git/hooks/pre-commit
# Enable TTY, so fastest runs on a single line and looks cooler
exec < /dev/tty
if [[ -z `docker ps -q --no-trunc | grep $(docker-compose ps -q apache2)` ]]; then
echo -e "\e[41m COMMIT FAILED: Docker-compose is not running! \e[0m";
exit 1
fi
# Install phpunit synchronously to avoid problems.
docker-compose exec php bin/phpunit install
docker-compose exec -T php bin/console cache:warmup --env=prod
if [[ $? != "0" ]]
then
echo -e "\e[41m COMMIT FAILED: Cannot warm cache for env=prod! \e[0m":
exit 1
fi
# see which files you wanted to commit, fix code style and re-add
FILES=` git status --porcelain | grep -e '^[AM]\(.*\).php$' | cut -c 3- | tr '\n' ' '`
if [[ $FILES ]]
then
FILES_NO_APPLICATION=`echo ${FILES} | sed "s/api\///g"`
docker-compose exec -T php vendor/bin/php-cs-fixer fix
git add ${FILES}
fi
# remove outdated code coverage files
rm -rf var/coverage.txt public/test.html
# warmup test cache to speed up tests
docker-compose exec php bin/console cache:warmup --env=test
# Run Tests and generate code coverage
docker-compose exec php bash -c "XDEBUG_MODE=coverage vendor/bin/paratest --coverage-html=public/test.html --coverage-text=var/coverage.txt tests"
if [[ $? != "0" ]]
then
echo -e "\e[41m COMMIT FAILED: You have test errors! \e[0m":
exit 1
fi
# merge code coverage
echo "Full HTML coverage at http://0.0.0.0/test.html/index.html"
OK=`docker-compose exec -T php head -n10 var/coverage.txt | grep Lines | grep "100.00%"`
if [[ ${OK} = "" ]]
then
echo -e "\e[41m COMMIT FAILED: Code coverage not 100%! \e[0m":
exit 1
fi
echo ""
Usage
Now you can run the pre-commit by using
$ bin/pre-commit
xip-solid-foundation/pre-commit 适用场景与选型建议
xip-solid-foundation/pre-commit 是一款 基于 Shell 开发的 Composer 扩展包,目前已累计 55 次下载、GitHub Stars 达 0, 最近一次更新时间为 2022 年 01 月 19 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 xip-solid-foundation/pre-commit 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 xip-solid-foundation/pre-commit 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 55
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 6
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-01-19