Skip to content

Run PHPCBF before PHPCS in GitHub Actions #23

@BrianHenryIE

Description

@BrianHenryIE

Feature Request

Describe your use case and the problem you are facing

When I forget to run PHPCBF before making a pull request, errors that can be fixed automatically are flagged by PHPCS for manual review.

Describe the solution you'd like

In the code-quality.yml GitHub Action, PHPCBF should be run before PHPCS:

- name: Run PHPCBF to fix what it can
  continue-on-error: true
  run: vendor/bin/phpcbf

- name: Run PHPCS and add annotations to the code
  run: vendor/bin/phpcs -q -n --report=checkstyle | cs2pr

At some point the PHPCBF changes need to be committed. This could be immediately after PHPCBF is run but would mean contributors need to pull changes before they can push again, (I see a note in my own yml: "NB: Pull requests from forks do not have access to repository secrets so cannot commit changes.") so maybe on every commit to master PHPCBF plus a commit should be run:

on:
  push:
    branches:
      - master

...

- name: Commit PHPCBF changes
  uses: stefanzweifel/[email protected]
  with:
    commit_message: "🤖 PHPCBF"

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions