extdn / github-actions-m2

137 stars 46 forks source link

[Question] Static Test action support custom Path #36

Open julienanquetil opened 3 years ago

julienanquetil commented 3 years ago

Hi, I'm currently got some Magento repo with custom code on "app/code". My goal is to be able to make the Github action Static test execute only on app/code...

By default it's not supported by your nice setup. I was thinking adding a parameter like there is for the standard, but for the "path to scan" and after if not empty analyze that folder.

Do you think it's the "good way" to go ? thanks

jissereitsma commented 3 years ago

Thanks for the suggestion. Just for clearity, which GitHub action are you referring to? I guess the PHPStan version because the PHPCS action does not use composer or Magento or anything - it just installs PHPCS and runs it ... If you could share your setup it would be helpful I guess.

julienanquetil commented 3 years ago

I Mean the phpcs one for example the default one

name: ExtDN M2 Coding Standard
on: [push, pull_request]

jobs:
  static:
    name: M2 Coding Standard
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: extdn/github-actions-m2/magento-coding-standard@master

if you get a git repo for a magento project and not a module you will get some "false" report (like not what I expect) inspection on setup/ and other folder

Capture d’écran 2021-09-01 à 12 19 40

my goals is to run phpcs only on app/code/ folder by doing something like

Updating the action.yml like that

name: 'Magento 2 Coding Style'
author: 'ExtDN'
description: 'performs php static code analysis with the Magento 2 Coding Standard'
inputs:
  phpcs_standard:
    description: 'Path to your own PHPCS file or a specific standard. Leave empty to use "Magento2".'
    required: false
  folder_name:
    description: 'Path to run the PHPCS inspection if not the whole project".'
    required: false
runs:
  using: 'docker'
  image: 'docker://extdn/magento-coding-standard-action:latest'
branding:
  icon: 'code'  
  color: 'green'

and then update the entrypoint like

sh -c "/root/.composer/vendor/bin/phpcs --report=checkstyle --standard=$INPUT_PHPCS_STANDARD $GITHUB_WORKSPACE/${INPUT_FOLDER_NAME} -s $*"

and finally be able in the project repo to add the workflow like

name: PHPCS Tests dev
on: [push, pull_request]

jobs:
  static:
    name: Static Code Analysis PHPCS
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: extdn/github-actions-m2/magento-coding-standard@master
        with:
          folder_name: app/code/VENDORNAME

i hope it's more clear ?

I made a "quick & dirty" test by changing the docker image (by forking your's) and got my use case working as expected. Not sure if relevant for everyone but usefull on our case :)

Thanks