Skip to content

one workflow to rule check them all #1

one workflow to rule check them all

one workflow to rule check them all #1

Workflow file for this run

name: CI Workflow
on: [push, pull_request]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
tools: cs2pr, phpcbf, phpcs, phpmd, phpunit
- name: Run phpcbf
run: phpcbf .
continue-on-error: ${{ github.ref != 'refs/heads/main' }}
- name: Commit code formatting changes
if: success() && github.ref != 'refs/heads/main'
run: |
git config user.name "GitHub Actions"
git config user.email "[email protected]"
git add src
git commit -m "Update src from PHP Codesniffer" || echo "No changes to commit"
git pull origin $(git rev-parse --abbrev-ref HEAD) --rebase --autostash
git push
- name: Run phpcs
run: phpcs -q --report=checkstyle src | cs2pr
continue-on-error: ${{ github.ref != 'refs/heads/main' }}
- name: Run phpmd
run: phpmd src github phpmd.xml --not-strict
continue-on-error: ${{ github.ref != 'refs/heads/main' }}
- name: Install Composer dependencies
uses: php-actions/composer@v6
with:
php_version: "8.2"
php_extensions: redis exif mongodb intl pdo_pgsql zip mysqli pdo_mysql pcntl gd gmp
command: install
- name: Run PHPUnit tests
env:
XDEBUG_MODE: coverage
run: |
phpunit --bootstrap ./tests/bootstrap.php --configuration phpunit.xml --coverage-html ./coverage --coverage-text | tee coverage.txt
continue-on-error: ${{ github.ref != 'refs/heads/main' }}
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install remark presets
run: npm install remark-cli remark-preset-lint-consistent remark-preset-lint-recommended remark-lint-list-item-indent
- name: Run remark
run: npx remark . --output --use remark-preset-lint-consistent --use remark-preset-lint-recommended --use remark-lint-list-item-indent
- name: Check for linting errors
run: |
npx remark . --use remark-preset-lint-consistent --use remark-preset-lint-recommended --use remark-lint-list-item-indent
continue-on-error: ${{ github.ref != 'refs/heads/main' }}
- name: Git commit
if: success() && github.ref != 'refs/heads/main'
run: |
git config user.name "GitHub Actions"
git config user.email "[email protected]"
git add .
git reset package.json
git reset package-lock.json
git reset node_modules
git commit -m "Update src from remark-lint" || echo "No changes to commit"
git pull origin $(git rev-parse --abbrev-ref HEAD) --rebase --autostash
git push
checks:
needs: [build, lint]
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Run Checks
run: |
if grep -q "ERROR" <(phpcs -q --report=checkstyle src); then
echo "PHP CodeSniffer found issues. Please fix them before merging."
exit 1
fi
if grep -q "ERROR" <(phpmd src text phpmd.xml --strict); then
echo "PHP Mess Detector found issues. Please fix them before merging."
exit 1
fi
if ! phpunit --configuration phpunit.xml; then
echo "PHPUnit tests failed. Please fix them before merging."
exit 1
fi
if npx remark . --use remark-preset-lint-consistent --use remark-preset-lint-recommended --use remark-lint-list-item-indent; then
echo "Markdown linting failed. Please fix them before merging."
exit 1
fi
continue-on-error: false