定制 xip-solid-foundation/pre-commit 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

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

  1. Docker Compose, install Docker Compose
  2. 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 我们能提供哪些服务?
定制开发 / 二次开发

基于 xip-solid-foundation/pre-commit 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 55
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 6
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 2
  • Forks: 0
  • 开发语言: Shell

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-01-19