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

Paths excluded in custom phpcs.xml file aren't ignored #29

Closed
andrewandante opened this issue May 1, 2020 · 3 comments
Closed

Paths excluded in custom phpcs.xml file aren't ignored #29

andrewandante opened this issue May 1, 2020 · 3 comments

Comments

@andrewandante
Copy link

We are using a custom phpcs.xml file, which contains the line:

<ruleset name="Test">
	<exclude-pattern>*/storage/*</exclude-pattern>
</ruleset>

To avoid scanning some Laravel stuff. On our test repo, we have the file tests/storage/IgnoreThisTest.php which, when running locally, is properly ignored. However, when the action runs it seems to copy the file over into a flat directory so it's not properly ignored and has our runs fail.

I'd think this could be remedied by duplicating the folder structure when creating temp files, but also if something is being excluded based on name, it should have the name the same - is there any particular reason the tmp files have random names?

Thanks!

@mrrobot47
Copy link
Member

mrrobot47 commented May 5, 2020

This action uses vip-go-ci internally for phpcs runs which has the logic of creating temp file. The reason behind it being that only the changes that are there in PR or the changes that have been updated in the files, they should only be scanned. Not the entire file. Those changes are then put in the temp file for scanning.
The logic behind temp files being named randomly is setup in the vip-go-ci repo.

Addressing your query about skipping certain folders, please refer this: https://github.com/rtCamp/action-phpcs-code-review#environment-variables

For your case in particular, it will look like this:

name: Run PHPCS on pull requests

on: pull_request

jobs:
  phpcs:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2
      with:
        ref: ${{ github.event.pull_request.head.sha }}
    - uses: docker://rtcamp/action-phpcs-code-review:v2.0.1
      env:
        GH_BOT_TOKEN: ${{ secrets.GH_BOT_TOKEN }}
        SKIP_FOLDERS: "tests/storage,some-other-folder/storage" 
      with:
        args: "WordPress,WordPress-Core,WordPress-Docs"

Make sure to use: docker://rtcamp/action-phpcs-code-review:v2.0.1 or rtCamp/action-phpcs-code-review@master for this feature.

@andrewandante
Copy link
Author

Thanks for the response - the problem is that with my use-case, this is being run on our own PHPCS ruleset, and I'm using it to test that the rules are applied properly. You can see how adding it explicitly to the yaml means that it isn't really testing that aspect of the ruleset.

I think this probably means I need to do it with a different action. Appreciate your response though

@mrrobot47
Copy link
Member

The phpcs rulesets of the yaml file phpcs.yml will be followed in the checks. See this.

Just that the exclude patterns will not be followed because of the temp file renaming for checking just the diff in PR. And for that reason only there is the SKIP_FOLDERS option.

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

No branches or pull requests

2 participants