Skip to content

update rule

update rule #2215

# https://help.github.com/en/categories/automating-your-workflow-with-github-actions
# file-version: 1.0
name: "Continuous Integration"
on:
- pull_request
- push
permissions:
contents: read
concurrency:
group: "${{ github.event_name }}-${{ github.workflow }}-${{ github.head_ref || github.run_id }}-${{ github.ref }}"
cancel-in-progress: true
jobs:
validate:
name: "Validate Project"
uses: "mimmi20/ci/.github/workflows/validate.yml@8.3"
with:
extensions: "ctype, curl, iconv, mbstring, ctype, dom, intl, simplexml, tokenizer, xml, xmlwriter, pdo"
ini-values: "opcache.enable=1, opcache.fast_shutdown=0, zend.assertions=1, assert.exception=On, intl.default_locale=de, intl.use_exceptions=1, zend.exception_ignore_args=0"
composer-options: "--optimize-autoloader --prefer-dist --prefer-stable -v"
skip-validate-composer: false
skip-validate-yaml: false
skip-validate-md: false
skip-phplint: false
skip-check-composer: true
skip-ec-checker: false
dependency-analyser-options: "--ignore-unknown-classes"
install:
name: "Install Project"
needs: "validate"
uses: "mimmi20/ci/.github/workflows/install.yml@8.3"
with:
extensions: "ctype, curl, iconv, mbstring, ctype, dom, intl, simplexml, tokenizer, xml, xmlwriter, pdo"
ini-values: "opcache.enable=1, opcache.fast_shutdown=0, zend.assertions=1, assert.exception=On, intl.default_locale=de, intl.use_exceptions=1, zend.exception_ignore_args=0"
composer-options: "--optimize-autoloader --prefer-dist --prefer-stable -v"
skip-php-install: false
skip-npm-install: true
php-cs-fixer:
name: "Check Coding Standards with PHP-CS-Fixer"
needs: "install"
runs-on: "${{ matrix.operating-system }}"
timeout-minutes: 10
continue-on-error: false
strategy:
fail-fast: false
matrix:
operating-system:
- "ubuntu-24.04"
php-version:
# Should use the lowest supported version
- "8.3"
steps:
- name: "Checkout"
uses: "actions/checkout@v4"
with:
# Disabling shallow clone is recommended for improving relevancy of reporting
fetch-depth: 0
lfs: false
persist-credentials: false
- name: "Install PHP"
uses: "shivammathur/setup-php@2.31.1"
with:
php-version: "${{ matrix.php-version }}"
extensions: "json, opcache"
ini-values: "opcache.enable=1, opcache.fast_shutdown=0, zend.assertions=1, assert.exception=On, intl.default_locale=de, intl.use_exceptions=1, zend.exception_ignore_args=0"
coverage: "none"
tools: "composer:v2, cs2pr"
env:
fail-fast: true
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
phpts: "nts"
- name: "Update dependencies with composer"
uses: "ramsey/composer-install@3.0.0"
with:
dependency-versions: "lowest"
composer-options: "--optimize-autoloader --prefer-dist --prefer-stable -v"
- name: "Run friendsofphp/php-cs-fixer"
run: "vendor/bin/php-cs-fixer fix --dry-run -vv --diff"
continue-on-error: true
- name: "Run friendsofphp/php-cs-fixer"
run: "vendor/bin/php-cs-fixer fix --dry-run --format=checkstyle | cs2pr"
phpcs:
name: "Check Coding Standards with PHPCS"
needs: "install"
runs-on: "${{ matrix.operating-system }}"
timeout-minutes: 30
continue-on-error: false
strategy:
fail-fast: false
matrix:
operating-system:
- "ubuntu-24.04"
php-version:
# Should use the lowest supported version
- "8.3"
steps:
- name: "Checkout"
uses: "actions/checkout@v4"
with:
# Disabling shallow clone is recommended for improving relevancy of reporting
fetch-depth: 0
lfs: false
persist-credentials: false
- name: "Install PHP"
uses: "shivammathur/setup-php@2.31.1"
with:
php-version: "${{ matrix.php-version }}"
extensions: "json, opcache"
ini-values: "opcache.enable=1, opcache.fast_shutdown=0, zend.assertions=1, assert.exception=On, intl.default_locale=de, intl.use_exceptions=1, zend.exception_ignore_args=0"
coverage: "none"
tools: "composer:v2, cs2pr"
env:
fail-fast: true
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
phpts: "nts"
- name: "Update dependencies with composer"
uses: "ramsey/composer-install@3.0.0"
with:
dependency-versions: "lowest"
composer-options: "--optimize-autoloader --prefer-dist --prefer-stable -v"
- name: "Run squizlabs/php_codesniffer"
id: "phpcs"
run: "vendor/bin/phpcs -wps --colors --standard=src/Mimmi20CodingStandard/ruleset.xml --extensions=php --report-full --report-performance --report-checkstyle=./phpcs-report.xml -v src .php-cs-fixer.php rector.php"
- name: "Show PHPCS results in PR"
if: ${{ always() && steps.phpcs.outcome == 'failure' }}
run: "cs2pr ./phpcs-report.xml"
static-code-analysis:
name: "Static Code Analysis with PHPStan"
needs: "install"
runs-on: "${{ matrix.operating-system }}"
timeout-minutes: 10
continue-on-error: false
strategy:
fail-fast: false
matrix:
operating-system:
- "ubuntu-24.04"
php-version:
# Should use the lowest supported version
- "8.3"
steps:
- name: "Checkout"
uses: "actions/checkout@v4"
with:
# Disabling shallow clone is recommended for improving relevancy of reporting
fetch-depth: 0
lfs: false
persist-credentials: false
- name: "Install PHP"
uses: "shivammathur/setup-php@2.31.1"
with:
php-version: "${{ matrix.php-version }}"
extensions: "json, opcache"
ini-values: "opcache.enable=1, opcache.fast_shutdown=0, zend.assertions=1, assert.exception=On, intl.default_locale=de, intl.use_exceptions=1, zend.exception_ignore_args=0"
coverage: "none"
tools: "composer:v2"
env:
fail-fast: true
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
phpts: "nts"
- name: "Update dependencies with composer"
uses: "ramsey/composer-install@3.0.0"
with:
dependency-versions: "lowest"
composer-options: "${{ inputs.composer-options }}"
- name: "Run phpstan/phpstan"
run: "vendor/bin/phpstan analyse -c phpstan.neon --memory-limit=768M --no-progress"
rector:
name: "Checks with Rector"
needs: "install"
runs-on: "${{ matrix.operating-system }}"
timeout-minutes: 10
continue-on-error: false
strategy:
fail-fast: false
matrix:
operating-system:
- "ubuntu-24.04"
php-version:
# Should use the lowest supported version
- "8.3"
steps:
- name: "Checkout"
uses: "actions/checkout@v4"
with:
# Disabling shallow clone is recommended for improving relevancy of reporting
fetch-depth: 0
lfs: false
persist-credentials: false
- name: "Install PHP"
uses: "shivammathur/setup-php@2.31.1"
with:
php-version: "${{ matrix.php-version }}"
extensions: "json, opcache"
ini-values: "opcache.enable=1, opcache.fast_shutdown=0, zend.assertions=1, assert.exception=On, intl.default_locale=de, intl.use_exceptions=1, zend.exception_ignore_args=0"
coverage: "none"
tools: "composer:v2"
env:
fail-fast: true
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
phpts: "nts"
- name: "Update dependencies with composer"
uses: "ramsey/composer-install@3.0.0"
with:
dependency-versions: "lowest"
composer-options: "${{ inputs.composer-options }}"
- name: "Run checks with rector/rector"
run: "vendor/bin/rector process --ansi --dry-run"
continue-on-error: true
- name: "Run checks with rector/rector"
run: "vendor/bin/rector process --ansi --dry-run --no-diffs"
# This is a meta job to avoid to have to constantly change the protection rules
# whenever we touch the matrix.
tests-status:
name: "Validate & Lint Status"
runs-on: "ubuntu-24.04"
if: always()
needs:
- "php-cs-fixer"
- "phpcs"
- "static-code-analysis"
- "rector"
steps:
- name: Failing run
if: ${{ contains(needs.*.result, 'failure') }}
run: exit 1
- name: Successful run
if: ${{ !(contains(needs.*.result, 'failure')) }}
run: exit 0