Skip to content

Build

Build #1802

Workflow file for this run

name: Build
on:
push:
pull_request:
workflow_dispatch:
schedule:
- cron: '0 22 * * *'
env:
extensions: mbstring, mysql, redis, pgsql, sqlite3, apcu
key: cache-v1 # can be any string, change to clear the extension cache.
jobs:
phpunit:
runs-on: ${{ matrix.operating-system }}
strategy:
fail-fast: false
matrix:
operating-system: [ ubuntu-latest ]
php-versions: [ '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3' ]
services:
mysql:
image: mysql:5.7
env:
MYSQL_ALLOW_EMPTY_PASSWORD: false
MYSQL_ROOT_PASSWORD: password
MYSQL_DATABASE: miaoxing
ports:
- 3306/tcp
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
redis:
image: redis
ports:
- 6379/tcp
options: --health-cmd="redis-cli ping" --health-interval=10s --health-timeout=5s --health-retries=3
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup cache environment
id: cache-env
uses: shivammathur/cache-extensions@v1
with:
php-version: ${{ matrix.php-versions }}
extensions: ${{ env.extensions }}
key: ${{ env.key }}
- name: Cache extensions
uses: actions/cache@v1
with:
path: ${{ steps.cache-env.outputs.dir }}
key: ${{ steps.cache-env.outputs.key }}
restore-keys: ${{ steps.cache-env.outputs.key }}
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
extensions: ${{ env.extensions }}
coverage: xdebug
- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache composer dependencies
uses: actions/cache@v1
with:
path: ${{ steps.composer-cache.outputs.dir }}
# Use composer.json for key, if composer.lock is not committed.
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: ${{ runner.os }}-composer-
- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: 20
- name: Replace package dependencies
run: npx replace-pkg-dep composer.json main
- name: Composer install
run: |
composer install --no-progress --prefer-dist --optimize-autoloader
- run: php -S 0.0.0.0:8000 -t tests/unit/Fixtures/ > /dev/null &
- name: Run
run: ./vendor/bin/miaoxing-phpunit
env:
DB_PORT: ${{ job.services.mysql.ports[3306] }}
REDIS_PORT: ${{ job.services.redis.ports[6379] }}
- name: Upload coverage results to Coveralls
continue-on-error: true
env:
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COVERALLS_PARALLEL: true
COVERALLS_FLAG_NAME: php-${{ matrix.php-versions }}
run: |
composer global require php-coveralls/php-coveralls
php-coveralls --coverage_clover=build/logs/clover.xml -vvv
coveralls-finish:
needs: [ phpunit ]
runs-on: ubuntu-latest
continue-on-error: true
steps:
- name: Coveralls Finished
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.github_token }}
parallel-finished: true
phpstan:
runs-on: ${{ matrix.operating-system }}
strategy:
fail-fast: false
matrix:
operating-system: [ ubuntu-latest ]
php-versions: [ '8.3' ]
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup cache environment
id: cache-env
uses: shivammathur/cache-extensions@v1
with:
php-version: ${{ matrix.php-versions }}
extensions: ${{ env.extensions }}
key: ${{ env.key }}
- name: Cache extensions
uses: actions/cache@v1
with:
path: ${{ steps.cache-env.outputs.dir }}
key: ${{ steps.cache-env.outputs.key }}
restore-keys: ${{ steps.cache-env.outputs.key }}
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
extensions: ${{ env.extensions }}
coverage: none
- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache composer dependencies
uses: actions/cache@v1
with:
path: ${{ steps.composer-cache.outputs.dir }}
# Use composer.json for key, if composer.lock is not committed.
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: ${{ runner.os }}-composer-
- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: 20
- name: Replace package dependencies
run: npx replace-pkg-dep composer.json main
- name: Composer install
run: |
composer install --no-progress --prefer-dist --optimize-autoloader
- name: Run
run: ./vendor/bin/miaoxing-phpstan
phpcs:
runs-on: ${{ matrix.operating-system }}
strategy:
fail-fast: false
matrix:
operating-system: [ ubuntu-latest ]
php-versions: [ '8.3' ]
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup cache environment
id: cache-env
uses: shivammathur/cache-extensions@v1
with:
php-version: ${{ matrix.php-versions }}
extensions: ${{ env.extensions }}
key: ${{ env.key }}
- name: Cache extensions
uses: actions/cache@v1
with:
path: ${{ steps.cache-env.outputs.dir }}
key: ${{ steps.cache-env.outputs.key }}
restore-keys: ${{ steps.cache-env.outputs.key }}
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
extensions: ${{ env.extensions }}
coverage: none
- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache composer dependencies
uses: actions/cache@v1
with:
path: ${{ steps.composer-cache.outputs.dir }}
# Use composer.json for key, if composer.lock is not committed.
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: ${{ runner.os }}-composer-
- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: 20
- name: Replace package dependencies
run: npx replace-pkg-dep composer.json main
- name: Composer install
run: |
composer install --no-progress --prefer-dist --optimize-autoloader
- name: Run
run: ./vendor/bin/miaoxing-phpcs
phpmd:
runs-on: ${{ matrix.operating-system }}
strategy:
fail-fast: false
matrix:
operating-system: [ ubuntu-latest ]
php-versions: [ '8.3' ]
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup cache environment
id: cache-env
uses: shivammathur/cache-extensions@v1
with:
php-version: ${{ matrix.php-versions }}
extensions: ${{ env.extensions }}
key: ${{ env.key }}
- name: Cache extensions
uses: actions/cache@v1
with:
path: ${{ steps.cache-env.outputs.dir }}
key: ${{ steps.cache-env.outputs.key }}
restore-keys: ${{ steps.cache-env.outputs.key }}
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
extensions: ${{ env.extensions }}
coverage: none
- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache composer dependencies
uses: actions/cache@v1
with:
path: ${{ steps.composer-cache.outputs.dir }}
# Use composer.json for key, if composer.lock is not committed.
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: ${{ runner.os }}-composer-
- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: 20
- name: Replace package dependencies
run: npx replace-pkg-dep composer.json main
- name: Composer install
run: |
composer install --no-progress --prefer-dist --optimize-autoloader
- name: Run
run: ./vendor/bin/miaoxing-phpmd --exclude tests/unit/RetTest.php,tests/unit/Model/CastTraitTest.php,tests/unit/Model/AttributeTest.php
phpmnd:
runs-on: ${{ matrix.operating-system }}
strategy:
fail-fast: false
matrix:
operating-system: [ ubuntu-latest ]
php-versions: [ '8.3' ]
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup cache environment
id: cache-env
uses: shivammathur/cache-extensions@v1
with:
php-version: ${{ matrix.php-versions }}
extensions: ${{ env.extensions }}
key: ${{ env.key }}
- name: Cache extensions
uses: actions/cache@v1
with:
path: ${{ steps.cache-env.outputs.dir }}
key: ${{ steps.cache-env.outputs.key }}
restore-keys: ${{ steps.cache-env.outputs.key }}
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
extensions: ${{ env.extensions }}
coverage: none
- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache composer dependencies
uses: actions/cache@v1
with:
path: ${{ steps.composer-cache.outputs.dir }}
# Use composer.json for key, if composer.lock is not committed.
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: ${{ runner.os }}-composer-
- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: 20
- name: Replace package dependencies
run: npx replace-pkg-dep composer.json main
- name: Composer install
run: |
composer install --no-progress --prefer-dist --optimize-autoloader
- name: Run
run: >
./vendor/bin/phpmnd lib tests --ignore-numbers=-1,0,1,2,3 --non-zero-exit-on-violation --progress
--exclude-path E.php --exclude-path Pinyin.php --exclude-path unit/ETest.php
--exclude-path IsIdCardHk.php --exclude-path IsIdCardTw.php --exclude-path Password.php
php-cs-fixer:
runs-on: ${{ matrix.operating-system }}
strategy:
fail-fast: false
matrix:
operating-system: [ ubuntu-latest ]
php-versions: [ '7.4' ]
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup cache environment
id: cache-env
uses: shivammathur/cache-extensions@v1
with:
php-version: ${{ matrix.php-versions }}
extensions: ${{ env.extensions }}
key: ${{ env.key }}
- name: Cache extensions
uses: actions/cache@v1
with:
path: ${{ steps.cache-env.outputs.dir }}
key: ${{ steps.cache-env.outputs.key }}
restore-keys: ${{ steps.cache-env.outputs.key }}
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
extensions: ${{ env.extensions }}
coverage: none
- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache composer dependencies
uses: actions/cache@v1
with:
path: ${{ steps.composer-cache.outputs.dir }}
# Use composer.json for key, if composer.lock is not committed.
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: ${{ runner.os }}-composer-
- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: 20
- name: Replace package dependencies
run: npx replace-pkg-dep composer.json main
- name: Composer install
run: |
composer install --no-progress --prefer-dist --optimize-autoloader
- name: Run
run: ./vendor/bin/miaoxing-php-cs-fixer