action-phpcs-code-review icon indicating copy to clipboard operation
action-phpcs-code-review copied to clipboard

Retrieve ruleset.xml from private repository

Open lilithebowman opened this issue 5 years ago • 1 comments

Is it possible to have this script retrieve the ruleset from a private repository? That's what I've been trying to figure out for 2 days now.

I was able to write that script out in shell scripts. But I can't figure out how to make the PHPCS output be comments on the PR using command lines so I wanted to use your action if I could.

lilithebowman avatar Sep 11 '20 13:09 lilithebowman

# Trigger the workflow on push or pull request
on: [pull_request]

name: Inspections
jobs:
  runPHPCSInspection:
    name: Run PHPCS inspection
    runs-on: ubuntu-latest
    steps:
    - name: Checkout PR files
      uses: actions/checkout@v2
      with:
        ref: ${{ github.event.pull_request.head.sha }}
    - name: Check out Our WPCS Rule Set
      uses: actions/checkout@v2
      with: 
        repository: CompanyName/our-wp-standard
        path: wpcs
        token: ${{ secrets.GH_BOT_TOKEN }}
    - name: Copy wpcs/Our-WP-Standard/ruleset.xml to phpcs.xml
      run: |
        cp wpcs/Our-WP-Standard/ruleset.xml phpcs.xml
        pwd
        ls -alF 
    - name: Run PHPCS inspection
      uses: rtCamp/[email protected]
      env:
        GH_BOT_TOKEN: ${{ secrets.GH_BOT_TOKEN }}
        SKIP_FOLDERS: "tests,.github,Our-WP-Standard,wordpress/wp-admin, wordpress/wp-includes"
      with:
        args: "wpcs/Our-WP-Standard/ruleset.xml"

This is what I've tried so far.

It even appears to pick up on the phpcs.xml file.

It is ignoring most of the rules however. We added in the PR an array with inline syntax and array with terse syntax. Usually it should report that as an error for our rules, but it does not.

ruleset.xml

<?xml version="1.0"?>
<ruleset name="Our-Standard">
	<description>Our WordPress Coding Standards</description>

	<config name="installed_paths" value="vendor/wp-coding-standards/wpcs/" />

	<!-- Remove yoda condition from WordPress-Core ruleset -->
	<rule ref="vendor/wp-coding-standards/wpcs/WordPress-Core/ruleset.xml">
		<exclude name="WordPress.PHP.YodaConditions" />
	</rule>

	<!-- Excluding vendor directories -->
	<exclude-pattern>vendor/*</exclude-pattern>
	<!-- Excluding WordPress admin directories -->
	<exclude-pattern>wp-admin/*</exclude-pattern>
	<exclude-pattern>wp-includes/*</exclude-pattern>

	<!-- Tell code sniffer which rules to follow -->
	<rule ref="WordPress-Extra"/>

</ruleset>

lilithebowman avatar Sep 11 '20 14:09 lilithebowman