test autoformatting

This commit is contained in:
Dennis Eichhorn 2020-01-26 13:54:48 +01:00
parent 2bf5a69f23
commit a60e22d419

View File

@ -3,185 +3,219 @@ name: CI/CD
on: [push] on: [push]
jobs: jobs:
code-tests: autoformat:
runs-on: ubuntu-latest runs-on: ubuntu-latest
services: strategy:
mysql: fail-fast: false
image: mysql:5.7 max-parallel: 3
env: steps:
MYSQL_ALLOW_EMPTY_PASSWORD: false - name: Checkout Repository
MYSQL_ROOT_PASSWORD: root uses: actions/checkout@master
MYSQL_DATABASE: oms with:
ports: fetch-depth: 1
- 3306 - name: Get Composer Cache Directory
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 id: composer-cache
postgres: run: echo "::set-output name=dir::$(composer config cache-files-dir)"
image: postgres:10.8 - name: Cache dependencies
env: uses: actions/cache@v1
POSTGRES_USER: postgres with:
POSTGRES_PASSWORD: root path: ${{ steps.composer-cache.outputs.dir }}
POSTGRES_DB: oms key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
ports: restore-keys: ${{ runner.os }}-composer-
- 5432:5432 - name: Setup Composer
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 3 run: composer install
redis: - name: Autoformat
image: redis run: vendor/bin/php-cs-fixer fix ./ --rules='{"array_syntax": {"syntax": "short"}, "blank_line_after_namespace": true, "cast_spaces": {"space": "single"}, "combine_consecutive_issets": true, "compact_nullable_typehint": true, "declare_strict_types": true, "elseif": true, "encoding": true, "explicit_indirect_variable": true, "explicit_string_variable": true, "function_to_constant": true, "implode_call": true, "increment_style": {"style": "pre"}, "is_null": {"use_yoda_style": false}, "line_ending": true, "logical_operators": true, "lowercase_cast": true, "lowercase_constants": true, "lowercase_keywords": true, "modernize_types_casting": true, "native_constant_invocation": true, "native_function_casing": true, "native_function_invocation": true, "new_with_braces": true, "no_alias_functions": true, "no_closing_tag": true, "no_empty_comment": true, "no_empty_phpdoc": true, "no_empty_statement": true, "no_homoglyph_names": true, "no_mixed_echo_print": {"use": "echo"}, "no_php4_constructor": true, "no_singleline_whitespace_before_semicolons": true, "no_spaces_inside_parenthesis": true, "no_trailing_whitespace": true, "no_unneeded_final_method": true, "no_unused_imports": true, "no_useless_return": true, "no_whitespace_before_comma_in_array": true, "no_whitespace_in_blank_line": true, "non_printable_character": true, "ordered_imports": {"sort_algorithm": "alpha"}, "php_unit_construct": true, "php_unit_internal_class": true, "php_unit_ordered_covers": true, "php_unit_set_up_tear_down_visibility": true, "phpdoc_align": {"align": "vertical"}, "phpdoc_annotation_without_dot": true, "phpdoc_scalar": true, "phpdoc_trim_consecutive_blank_line_separation": true, "random_api_migration": true, "self_accessor": true, "set_type_to_cast": true, "short_scalar_cast": true, "single_blank_line_at_eof": true, "single_line_after_imports": true, "standardize_increment": true, "trailing_comma_in_multiline_array": true, "trim_array_spaces": true, "visibility_required": true, "void_return": true}' --allow-risky=yes
ports: - name: Check for modified files
- 6379:6379 id: git-check
options: --entrypoint redis-server run: echo ::set-output name=modified::$(if git diff-index --quiet HEAD --; then echo "false"; else echo "true"; fi)
memcached: - name: Push changes
image: memcached if: steps.git-check.outputs.modified == 'true'
ports: run: |
- 11211:11211 git config --global user.name 'Formatter Bot'
strategy: git config --global user.email 'formatter.bot@orange-management.email'
fail-fast: false git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}
max-parallel: 3 git commit -am "Automated formatting changes"
matrix: git push
php-versions: ['7.4'] code-tests:
steps: runs-on: ubuntu-latest
- name: Checkout Repository services:
uses: actions/checkout@master mysql:
with: image: mysql:5.7
fetch-depth: 1 env:
- name: Checkout Build Repository MYSQL_ALLOW_EMPTY_PASSWORD: false
uses: actions/checkout@master MYSQL_ROOT_PASSWORD: root
with: MYSQL_DATABASE: oms
fetch-depth: 1 ports:
ref: develop - 3306
repository: Orange-Management/Build options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
path: Build postgres:
- name: Checkout Resource Repository image: postgres:10.8
uses: actions/checkout@master env:
with: POSTGRES_USER: postgres
fetch-depth: 1 POSTGRES_PASSWORD: root
ref: develop POSTGRES_DB: oms
repository: Orange-Management/Resources ports:
path: Resources - 5432:5432
- name: Setup PHP, with composer and extensions options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 3
uses: shivammathur/setup-php@master redis:
with: image: redis
php-version: ${{ matrix.php-versions }} ports:
extensions: mbstring, gd, zip, dom, mysql, pgsql, sqlite, imap, bcmath, redis, memcached - 6379:6379
ini-values: opcache.jit_buffer_size=256M, opcache.jit=1235, pcre.jit=1 options: --entrypoint redis-server
coverage: pcov memcached:
- name: Get Composer Cache Directory image: memcached
id: composer-cache ports:
run: echo "::set-output name=dir::$(composer config cache-files-dir)" - 11211:11211
- name: Cache dependencies strategy:
uses: actions/cache@v1 fail-fast: false
with: max-parallel: 3
path: ${{ steps.composer-cache.outputs.dir }} matrix:
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} php-versions: ['7.4']
restore-keys: ${{ runner.os }}-composer- steps:
- name: Setup Composer - name: Checkout Repository
run: composer install uses: actions/checkout@master
- name: phpunit with:
run: vendor/bin/phpunit --coverage-text -v --configuration tests/phpunit_no_coverage.xml fetch-depth: 1
static-tests: - name: Checkout Build Repository
runs-on: ubuntu-latest uses: actions/checkout@master
strategy: with:
fail-fast: false fetch-depth: 1
max-parallel: 3 ref: develop
matrix: repository: Orange-Management/Build
php-versions: ['7.4'] path: Build
steps: - name: Checkout Resource Repository
- name: Checkout Repository uses: actions/checkout@master
uses: actions/checkout@master with:
with: fetch-depth: 1
fetch-depth: 1 ref: develop
- name: Checkout Build Repository repository: Orange-Management/Resources
uses: actions/checkout@master path: Resources
with: - name: Setup PHP, with composer and extensions
fetch-depth: 1 uses: shivammathur/setup-php@master
ref: develop with:
repository: Orange-Management/Build php-version: ${{ matrix.php-versions }}
path: Build extensions: mbstring, gd, zip, dom, mysql, pgsql, sqlite, imap, bcmath, redis, memcached
- name: Setup PHP, with composer and extensions ini-values: opcache.jit_buffer_size=256M, opcache.jit=1235, pcre.jit=1
uses: shivammathur/setup-php@master coverage: pcov
with: - name: Get Composer Cache Directory
php-version: ${{ matrix.php-versions }} id: composer-cache
extensions: mbstring, gd, zip, dom, mysql, pgsql, sqlite, imap, bcmath, redis, memcached run: echo "::set-output name=dir::$(composer config cache-files-dir)"
ini-values: opcache.jit_buffer_size=256M, opcache.jit=1235, pcre.jit=1 - name: Cache dependencies
- name: Get Composer Cache Directory uses: actions/cache@v1
id: composer-cache with:
run: echo "::set-output name=dir::$(composer config cache-files-dir)" path: ${{ steps.composer-cache.outputs.dir }}
- name: Cache dependencies key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
uses: actions/cache@v1 restore-keys: ${{ runner.os }}-composer-
with: - name: Setup Composer
path: ${{ steps.composer-cache.outputs.dir }} run: composer install
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} - name: phpunit
restore-keys: ${{ runner.os }}-composer- run: vendor/bin/phpunit --coverage-text -v --configuration tests/phpunit_no_coverage.xml
- name: Setup Composer static-tests:
run: composer install runs-on: ubuntu-latest
- name: Prepare phpstan strategy:
run: | fail-fast: false
sed -i 's/path: phpOMS\//path: /g' Build/Config/phpstan-baseline.neon max-parallel: 3
- name: phpstan matrix:
run: vendor/bin/phpstan analyse -a Autoloader.php --no-progress -l 7 -c Build/Config/phpstan.neon ./ php-versions: ['7.4']
codestyle-tests: steps:
runs-on: ubuntu-latest - name: Checkout Repository
strategy: uses: actions/checkout@master
fail-fast: false with:
max-parallel: 3 fetch-depth: 1
matrix: - name: Checkout Build Repository
php-versions: ['7.4'] uses: actions/checkout@master
steps: with:
- name: Checkout Repository fetch-depth: 1
uses: actions/checkout@master ref: develop
with: repository: Orange-Management/Build
fetch-depth: 1 path: Build
- name: Checkout Build Repository - name: Setup PHP, with composer and extensions
uses: actions/checkout@master uses: shivammathur/setup-php@master
with: with:
fetch-depth: 1 php-version: ${{ matrix.php-versions }}
ref: develop extensions: mbstring, gd, zip, dom, mysql, pgsql, sqlite, imap, bcmath, redis, memcached
repository: Orange-Management/Build ini-values: opcache.jit_buffer_size=256M, opcache.jit=1235, pcre.jit=1
path: Build - name: Get Composer Cache Directory
- name: Setup PHP, with composer and extensions id: composer-cache
uses: shivammathur/setup-php@master run: echo "::set-output name=dir::$(composer config cache-files-dir)"
with: - name: Cache dependencies
php-version: ${{ matrix.php-versions }} uses: actions/cache@v1
extensions: mbstring, gd, zip, dom, mysql, pgsql, sqlite, imap, bcmath, redis, memcached with:
ini-values: opcache.jit_buffer_size=256M, opcache.jit=1235, pcre.jit=1 path: ${{ steps.composer-cache.outputs.dir }}
- name: Get Composer Cache Directory key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
id: composer-cache restore-keys: ${{ runner.os }}-composer-
run: echo "::set-output name=dir::$(composer config cache-files-dir)" - name: Setup Composer
- name: Cache dependencies run: composer install
uses: actions/cache@v1 - name: Prepare phpstan
with: run: |
path: ${{ steps.composer-cache.outputs.dir }} sed -i 's/path: phpOMS\//path: /g' Build/Config/phpstan-baseline.neon
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} - name: phpstan
restore-keys: ${{ runner.os }}-composer- run: vendor/bin/phpstan analyse -a Autoloader.php --no-progress -l 7 -c Build/Config/phpstan.neon ./
- name: Setup Composer codestyle-tests:
run: composer install runs-on: ubuntu-latest
- name: phpcs strategy:
run: vendor/bin/phpcs ./ --standard="Build/Config/phpcs.xml" -s --report=full fail-fast: false
custom: max-parallel: 3
runs-on: ubuntu-latest matrix:
strategy: php-versions: ['7.4']
fail-fast: false steps:
max-parallel: 3 - name: Checkout Repository
matrix: uses: actions/checkout@master
php-versions: ['7.4', '8.0'] with:
steps: fetch-depth: 1
- name: Checkout Repository - name: Checkout Build Repository
uses: actions/checkout@master uses: actions/checkout@master
with: with:
fetch-depth: 1 fetch-depth: 1
- name: Checkout Build Repository ref: develop
uses: actions/checkout@master repository: Orange-Management/Build
with: path: Build
fetch-depth: 1 - name: Setup PHP, with composer and extensions
ref: develop uses: shivammathur/setup-php@master
repository: Orange-Management/Build with:
path: Build php-version: ${{ matrix.php-versions }}
- name: Setup PHP, with composer and extensions extensions: mbstring, gd, zip, dom, mysql, pgsql, sqlite, imap, bcmath, redis, memcached
uses: shivammathur/setup-php@master ini-values: opcache.jit_buffer_size=256M, opcache.jit=1235, pcre.jit=1
with: - name: Get Composer Cache Directory
php-version: ${{ matrix.php-versions }} id: composer-cache
extensions: mbstring, gd, zip, dom, mysql, pgsql, sqlite, imap, bcmath, redis, memcached run: echo "::set-output name=dir::$(composer config cache-files-dir)"
ini-values: opcache.jit_buffer_size=256M, opcache.jit=1235, pcre.jit=1 - name: Cache dependencies
- name: PHP linting uses: actions/cache@v1
run: find ./ -type f -name '*.php' -print0 | xargs -0 -n1 -P4 php -l -n | (! grep -v "No syntax errors detected" ) with:
- name: Php strict path: ${{ steps.composer-cache.outputs.dir }}
run: if [[ $(grep -r -L "declare(strict_types=1);" --include=*.php --exclude={*.tpl.php,*Hooks.php,*Routes.php,*SearchCommands.php} ./) -ne "" ]]; then exit 1; fi key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-
- name: Setup Composer
run: composer install
- name: phpcs
run: vendor/bin/phpcs ./ --standard="Build/Config/phpcs.xml" -s --report=full
custom:
runs-on: ubuntu-latest
strategy:
fail-fast: false
max-parallel: 3
matrix:
php-versions: ['7.4', '8.0']
steps:
- name: Checkout Repository
uses: actions/checkout@master
with:
fetch-depth: 1
- name: Checkout Build Repository
uses: actions/checkout@master
with:
fetch-depth: 1
ref: develop
repository: Orange-Management/Build
path: Build
- name: Setup PHP, with composer and extensions
uses: shivammathur/setup-php@master
with:
php-version: ${{ matrix.php-versions }}
extensions: mbstring, gd, zip, dom, mysql, pgsql, sqlite, imap, bcmath, redis, memcached
ini-values: opcache.jit_buffer_size=256M, opcache.jit=1235, pcre.jit=1
- name: PHP linting
run: find ./ -type f -name '*.php' -print0 | xargs -0 -n1 -P4 php -l -n | (! grep -v "No syntax errors detected" )
- name: Php strict
run: if [[ $(grep -r -L "declare(strict_types=1);" --include=*.php --exclude={*.tpl.php,*Hooks.php,*Routes.php,*SearchCommands.php} ./) -ne "" ]]; then exit 1; fi