tinovyatkin / action-php-codesniffer

Github Action to check your code with PHP_CodeSniffer that can check only PR changed files or even lines
MIT License
21 stars 24 forks source link

Workflow never fails #87

Open chrisc-cy2 opened 2 years ago

chrisc-cy2 commented 2 years ago

I've tried everything I can think of, but it looks like it's impossible to get this workflow action to fail.

Here's my workflow:

name: CodingStandards
on:
  pull_request:
    paths:
      - "**.php"
      - "phpcs.xml"
      - ".github/workflows/phpcs.yml"
jobs:

  phpcs:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
        with:
          fetch-depth: 0

      - name: Install PHP_CodeSniffer
        run: |
          curl -OL https://squizlabs.github.io/PHP_CodeSniffer/phpcs.phar
          php phpcs.phar --version

      - uses: tinovyatkin/action-php-codesniffer@v1
        with:
          files: "**.php"
          phpcs_path: "php phpcs.phar --colors -v -vv"
          standard: "PSR12"
          scope: "file"

This just passes every time whether or not there's changed files with coding standards violations in them.

Here's the output:

Run tinovyatkin/action-php-codesniffer@v1
  with:
    files: **.php
    phpcs_path: php phpcs.phar --colors -v -vv
    standard: PSR12
    scope: file
Filter patterns: [ '**.php' ] true
{
  "added": [],
  "modified": [
    "app/Http/Controllers/Controller.php"
  ]
}

I've tried:

It's hard to tell what the output of the action should be. I would expect to see phpcs output but it looks like it's only printing a JSON object of changed files, so I don't know if it's actually running phpcs or not... if it's not running, that would explain why it's not failing, but I can't tell.

It's definitely recognising the modified file, and it definitely matches the glob in the filter pattern.

These are definitely coding standards violations because running phpcs manually at my end, the warnings do appear.

As mentioned, I think I've ruled out everything I can. Are there any other steps I can use to debug this?

symartensv2v commented 2 years ago

I am now having the same issue, was working fine earlier. wanted to add a new workflow for css and now it isnt working anymore.

Edit: it seems to be occuring for me when using the default scope. From my testing. If I put scope "files" it works. and it the reason seems to be that its not working otherwise because its not rescanning all commits in the pull request to detect all changes correctly.