Merge branch 'main' into phpdocMethodSniff #31
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Moodle Coding Style Tests | |
on: [push, pull_request] | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- php: 8.2 | |
- php: 8.1 | |
- php: 8.0 | |
- php: 7.4 | |
steps: | |
- name: Check out repository code | |
uses: actions/checkout@v3 | |
- name: Setup PHP ${{ matrix.php }} | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: ${{ matrix.php }} | |
extensions: ${{ matrix.extensions }} | |
ini-values: pcov.directory=moodle, error_reporting=-1, display_errors=On | |
coverage: pcov | |
tools: composer | |
- name: Install composer dependencies | |
run: | | |
composer install | |
- name: Run phplint | |
if: ${{ always() }} | |
run: | | |
./vendor/bin/phplint | |
- name: PHP Copy/Paste Detector | |
if: ${{ always() }} | |
run: ./vendor/bin/phpcpd --exclude moodle/Tests moodle | |
- name: Run phpunit | |
if: ${{ always() }} | |
run: | | |
./vendor/bin/phpunit --coverage-text | |
- name: Test coverage | |
run: ./vendor/bin/phpunit-coverage-check -t 80 clover.xml | |
- name: Integration tests | |
if: ${{ always() }} | |
run: | | |
# There is one failure (exit with error) | |
vendor/bin/phpcs --standard=moodle moodle/Tests/fixtures/integration_test_ci.php | tee output.txt || [[ $? = 1 ]] | |
grep -q "PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY" output.txt | |
# The failure is fixed (exit with error) | |
vendor/bin/phpcbf --standard=moodle moodle/Tests/fixtures/integration_test_ci.php | tee output.txt || [[ $? = 1 ]] | |
grep -q "A TOTAL OF 1 ERROR WERE FIXED IN 1 FILE" output.txt | |
# So, there isn't any failure any more (exit without error) | |
vendor/bin/phpcs --standard=moodle moodle/Tests/fixtures/integration_test_ci.php | tee output.txt && [[ $? = 0 ]] | |
coverage: | |
if: github.repository == 'moodlehq/moodle-cs' | |
name: Code coverage (codecov) | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out repository code | |
uses: actions/checkout@v3 | |
- name: Setup PHP 8.2 | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: 8.2 | |
ini-values: pcov.directory=moodle, error_reporting=-1, display_errors=On | |
coverage: pcov | |
tools: composer | |
- name: Install composer dependencies | |
run: | | |
composer install | |
- name: Run phpunit | |
if: ${{ always() }} | |
run: | | |
./vendor/bin/phpunit --coverage-clover clover.xml | |
- name: Upload coverage | |
uses: codecov/codecov-action@v3 | |
with: | |
files: clover.xml | |
verbose: true |