Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fea add action router #10

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

jokesterfr
Copy link

@jokesterfr jokesterfr commented Sep 30, 2022

Introduce a new agnostic way of linting php.
To test it out:

jobs:
  php-linter:
    name: PHP Syntax check
    runs-on: ubuntu-latest
    strategy:
      matrix:
        php_version: ["7.1", "7.2", "7.3", "7.4", "8.0", "8.1"]
    steps:
      - name: Checkout
        uses: actions/[email protected]
      - name: PHP syntax checker ${{ matrix.php_version }}
        uses: "jokesterfr/github-action-php-lint@fea-add-action-router"
        with:
          php-version: ${{ matrix.php_version }}

run: |
echo "Pulled docker image: $(docker pull --quiet php:${{ inputs.php-version }})"
docker run --rm --entrypoint /bin/sh php:${{ inputs.php-version }} -c "! (find . -type f -name \"*.php\" ${{ inputs.folder-to-exclude }} -exec php -l -n {} \; | grep -v \"No syntax errors detected\")"
echo "No syntax error detected"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens if a syntax error is found? will this message be displayed anyway?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think so, run will fail.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But you're right we should try this case.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

git ls-files | grep -E '.*\.(php)' | xargs -n1 php -l -n | (! grep -v "No syntax errors" )

seems to provide exactly what's needed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants