From 5be42d856211ed84a24c883801e9b1e53dc3667f Mon Sep 17 00:00:00 2001 From: inhere Date: Fri, 7 May 2021 00:30:58 +0800 Subject: [PATCH] up: add github scripts --- .github/ISSUE_TEMPLATE/config.yml | 14 +++++++ .github/PULL_REQUEST_TEMPLATE.md | 60 ++++++++++++++++++++++++++++++ .github/workflows/php.yml | 54 +++++++++++++++++++++++++++ .github/workflows/release.yml | 62 +++++++++++++++++++++++++++++++ 4 files changed, 190 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/config.yml create mode 100644 .github/PULL_REQUEST_TEMPLATE.md create mode 100644 .github/workflows/php.yml create mode 100644 .github/workflows/release.yml diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 0000000..3f0435a --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1,14 @@ +blank_issues_enabled: false +contact_links: + - name: Swoft Issues + url: https://github.com/swoft-cloud/swoft/issues + about: Please report security vulnerabilities here. 请打开此页面报告bug或改进问题! + - name: Swoft Development + url: https://github.com/swoft-cloud/swoft-component + about: Participate in contributing swoft code, please jump to this project. 参与贡献swoft代码,请跳转到这个项目 + - name: Swoft 中文文档 + url: https://swoft.org + about: Please ask and answer questions here. swoft 2.0新版风格中文文档请访问此网站。 + - name: Swoft English Documents + url: http://swoft.io + about: Please report security vulnerabilities here. swoft英文文档或者旧版风格文档请访问此网站。 diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000..8b742aa --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,60 @@ +# PR + +- 请不要提交PR到各个组件仓库,它们都是 **只读的** +- 核心组件的 **开发仓库** 是 **[swoft/swoft-component][core]** +- 扩展组件的 **开发仓库** 是 **[swoft/swoft-ext][ext]** +- 请 `fork` 对应的 **开发仓库**,修改后,请把你的PR提交到对应的开发仓库 + +> 发布版本时官方会将代码同步到各个子仓库。因此,切记不要往子仓库发PR。 + +## 发起PR时的注意事项 + +开发组非常欢迎各位向我们提交PR(_Pull Request_),但是为了保证代码质量和统一的风格, +向官方的主仓库 [swoft/swoft][main] 和 **开发仓库** 贡献代码时需要注意代码和commit格式 + +### Commit Message + +- commit message 只能是英文信息 +- 请尽量保证commit message是有意义的说明 +- 最好以 `add:` `update:` `fix:` 等关键字开头 + +### 代码风格 + +- 提交的PHP代码 **必须** 遵循 PSR-2 代码风格 +- 合理且有意义的类、方法、变量命名 +- 适当的注释,合理的使用空行保持代码的简洁,易于阅读 +- 不要包含一些无意义的信息 例如 `@author` 等(_提交者是能够从commit log里看到的_) + +------------------ + +> English Version (_translate by Google_) + +The development team welcomes you to submit PR (_Pull Request_) to us, but to ensure code quality and uniform style, +go to the official main repository [swoft/swoft][main] and Development repository, Note the code and commit format when contributing code + +## Precautions when initiating PR + +- Please do not submit PR to each sub-repository, they are all read-only +- The _development repository_ for the core components is **[swoft/swoft-component][core]** +- The _development repository_ for extension components is **[swoft/swoft-ext][ext]** +- Please `fork` the corresponding development warehouse. After modification, please submit your PR to the corresponding development warehouse. + +> Officially syncs code to individual sub-warehouses when new versions are released + +### Commit Message + +- the commit message can only be in English +- Please try to ensure that the commit message is meaningful +- it is best to start with the keyword `add:` `update:` `fix:` + +### Code Style + +- Submitted PHP code **Must** Follow PSR-2 code style +- Reasonable and meaningful class, method, variable naming +- Appropriate comments, reasonable use of blank lines to keep the code simple and easy to read +- Don't include some meaningless information such as `@author`, etc. (_author is that can be seen from the commit log_) + + +[main]: https://github.com/swoft-cloud/swoft +[core]: https://github.com/swoft-cloud/swoft-component +[ext]: https://github.com/swoft-cloud/swoft-ext diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml new file mode 100644 index 0000000..9bf9c91 --- /dev/null +++ b/.github/workflows/php.yml @@ -0,0 +1,54 @@ +# +# Github actions for swoft component tests +# https://github.com/marketplace?type=actions +# +name: Unit-tests + +on: [push, pull_request] + +# usage refer https://github.com/shivammathur/setup-php +jobs: + test: + name: Test on php ${{ matrix.php}} and ${{ matrix.os }} OS + runs-on: ${{ matrix.os }} + timeout-minutes: 20 + env: + SWOFT_DEBUG: 0 + strategy: + fail-fast: true # fast fail + matrix: + php: [7.2, 7.3, 7.4, 8.0] + os: [ubuntu-latest] # , macOS-latest, windows-latest + swoole-versions: [''] # latest + include: + - os: 'ubuntu-latest' + php: '7.1' + swoole-versions: '-4.5.11' + + steps: + - uses: actions/checkout@v2 + # usage refer https://github.com/shivammathur/setup-php + - name: Setup PHP + timeout-minutes: 5 + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php}} + extensions: mbstring, dom, fileinfo, mysql, openssl, redis, swoole${{ matrix.swoole-versions }} #optional, setup extensions + ini-values: post_max_size=56M, short_open_tag=On #optional, setup php.ini configuration + coverage: none #optional, setup coverage driver: xdebug, none + + - name: Display swoole extensions + timeout-minutes: 1 + run: php --ri swoole + # sudo pecl install -f swoole + # echo 'no' | pecl install -f redis + # sudo pecl update-channels && pecl install -f msgpack && pecl install -f igbinary && php -m + + - name: Install dependencies + run: composer install --no-progress --no-suggest + + # Add a test script to composer.json, for instance: "test": "vendor/bin/phpunit" + # Docs: https://getcomposer.org/doc/articles/scripts.md + + - name: Run test suite + run: composer run test diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..a33279f --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,62 @@ +name: Tag-release + +on: + push: + tags: + - v* + +jobs: + release: + name: Test on php ${{ matrix.php}} + runs-on: ubuntu-latest + timeout-minutes: 10 + strategy: + fail-fast: true + matrix: + php: [7.3] + + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Set ENV for github-release + # https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-commands-for-github-actions#setting-an-environment-variable + run: | + echo "RELEASE_TAG=${GITHUB_REF:10}" >> $GITHUB_ENV + echo "RELEASE_NAME=$GITHUB_WORKFLOW" >> $GITHUB_ENV + + # usage refer https://github.com/shivammathur/setup-php + - name: Setup PHP + timeout-minutes: 5 + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php}} + tools: pecl, php-cs-fixer, phpunit + extensions: mbstring, dom, fileinfo, mysql, openssl # , swoole-4.4.19 #optional, setup extensions + ini-values: post_max_size=56M, short_open_tag=On #optional, setup php.ini configuration + coverage: none #optional, setup coverage driver: xdebug, none + + - name: Install dependencies # eg: v1.0.3 + run: | + tag1=${GITHUB_REF#refs/*/} + echo "release tag: ${tag1}" + composer install --no-progress --no-suggest + + # Add a test script to composer.json, for instance: "test": "vendor/bin/phpunit" + # Docs: https://getcomposer.org/doc/articles/scripts.md + +# - name: Build phar and send to github assets +# run: | +# echo $RELEASE_TAG +# echo $RELEASE_NAME +# php -d phar.readonly=0 bin/kite phar:pack -o kite-${RELEASE_TAG}.phar --no-progress +# php kite-${RELEASE_TAG}.phar -V + + # https://github.com/actions/create-release + - uses: meeDamian/github-release@2.0 + with: + gzip: false + token: ${{ secrets.GITHUB_TOKEN }} + tag: ${{ env.RELEASE_TAG }} + name: ${{ env.RELEASE_TAG }} +# files: kite-${{ env.RELEASE_TAG }}.phar