rtCamp / action-phpcs-code-review

Github Action to perform automated code review on pull requests
https://github.com/rtCamp/github-actions-library
MIT License
103 stars 27 forks source link

Some help getting this set up #36

Closed NickGreen closed 4 years ago

NickGreen commented 4 years ago

Hello @mrrobot47 👋 I'm trying to get your action set up on one of our repos, and wondering if you could take a quick look to see if you can spot what I'm doing wrong.

When it runs, I get this failure:

Screenshot Screenshot: https://d.pr/i/CrPOOn

X Run PHPCS inspection
8s
                                   Default is zero
/usr/bin/docker run --name rtcampactionphpcscodereviewv202_cf6b87 --label 87c201 --workdir /github/workspace --rm -e GH_BOT_TOKEN -e SKIP_FOLDERS -e INPUT_ARGS -e HOME -e GITHUB_JOB -e GITHUB_REF -e GITHUB_SHA -e GITHUB_REPOSITORY -e GITHUB_REPOSITORY_OWNER -e GITHUB_RUN_ID -e GITHUB_RUN_NUMBER -e GITHUB_ACTOR -e GITHUB_WORKFLOW -e GITHUB_HEAD_REF -e GITHUB_BASE_REF -e GITHUB_EVENT_NAME -e GITHUB_SERVER_URL -e GITHUB_API_URL -e GITHUB_GRAPHQL_URL -e GITHUB_WORKSPACE -e GITHUB_ACTION -e GITHUB_EVENT_PATH -e RUNNER_OS -e RUNNER_TOOL_CACHE -e RUNNER_TEMP -e RUNNER_WORKSPACE -e ACTIONS_RUNTIME_URL -e ACTIONS_RUNTIME_TOKEN -e ACTIONS_CACHE_URL -e GITHUB_ACTIONS=true -e CI=true -v "/var/run/docker.sock":"/var/run/docker.sock" -v "/home/runner/work/_temp/_github_home":"/github/home" -v "/home/runner/work/_temp/_github_workflow":"/github/workflow" -v "/home/runner/work/deploytest/deploytest":"/github/workspace" rtcamp/action-phpcs-code-review:v2.0.2 WordPress-Extra
COMMIT ID: f301ead7323cbd80c2d7e4b838347ffedeb5b59a
 __________________________________
/ Running with the flag            \
\ --phpcs-standard=WordPress-Extra /
 ----------------------------------
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||
Running the following command
/home/rtbot/vip-go-ci-tools/vip-go-ci/vip-go-ci.php --repo-owner=a8cteam51 --repo-name=deploytest --commit=f301ead7323cbd80c2d7e4b838347ffedeb5b59a --token=$GH_BOT_TOKEN --phpcs-path=/home/rtbot/vip-go-ci-tools/phpcs/bin/phpcs --local-git-repo=/home/rtbot/github-workspace --phpcs=true --phpcs-standard=WordPress-Extra --skip-folders='tests,.github' --lint=true
[ 2020-07-09T22:24:23+05:30 -- 0 ]  Initializing...; {
    "debug_info": {
        "php_version": "7.2.24-0ubuntu0.18.04.4",
        "hostname": "15502e58a306",
        "php_uname": "Linux 15502e58a306 5.3.0-1031-azure #32~18.04.1-Ubuntu SMP Mon Jun 22 15:27:23 UTC 2020 x86_64"
    }
}
Usage: /home/rtbot/vip-go-ci-tools/vip-go-ci/vip-go-ci.php
    Options --repo-owner, --repo-name, --commit, --token, --local-git-repo, --phpcs-path are 

My workflow is set up like this:

on: pull_request
name: Code checks
jobs:
  runPHPCSInspection:
    name: Run PHPCS inspection
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2
      with:
        ref: ${{ github.event.pull_request.head.sha }}
    - name: Run PHPCS inspection
      uses: rtCamp/action-phpcs-code-review@v2.0.2
      env:
        GH_BOT_TOKEN: ${{ secrets.GH_BOT_TOKEN }}
        SKIP_FOLDERS: "tests,.github"
      with:
        args: "WordPress-Extra"

Is there anything that stands out to you as something that isn't set up correctly? I appreciate your time.

NickGreen commented 4 years ago

Update: I've made some progress, and got it running locally by adding a phpcs.xml file to the root folder, which includes a ruleset with no rules in it. Is that a required file?

mrrobot47 commented 4 years ago

Hey @NickGreen :wave:

The usage error you are getting would come up only if the passed input is empty, in this case --token input provided by GH_BOT_TOKEN env variable.

Now, the action already has error reporting and checks for when the input secret is not set or empty. There was only one unhandled scenario: the secret input having a leading space. (I checked that at times copying token from GitHub UI can give leading space.) So, the generated command would then look like: --token= *** which would be interpreted as no value passed to the token flag.

Thanks for reporting the issue. I have applied a patch for the same and merged it into master. So, to run your action with this patch, please use the @master tag instead of the release tag @v2.0.2:

      uses: rtCamp/action-phpcs-code-review@master

Let me know if this fixes your issue. Will do a patch release with this fix then.

adding a phpcs.xml file to the root folder, which includes a ruleset with no rules in it. Is that a required file?

No, phpcs.xml is not required. The args you pass in action are sufficient. The action will run phpcs with the passed args. For more information please refer this.

NickGreen commented 4 years ago

the secret input having a leading space.

@mrrobot47 That was the problem! I don't know how I missed that leading space when I copy/pasted my token.

To test your fix, I used master and it ran as I expected it to, so that's great. Thanks so much for looking into this, I'll close it out 🙇

mrrobot47 commented 4 years ago

The patch for this issue has been released in the latest version: v2.0.3. https://github.com/rtCamp/action-phpcs-code-review/releases/tag/v2.0.3