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

Add php-cs-fixer and pre-commit hook installer #4465

Merged
merged 11 commits into from
Aug 23, 2022
Merged

Conversation

nolanpro
Copy link
Collaborator

@nolanpro nolanpro commented Aug 5, 2022

Issue & Reproduction Steps

As part of the Laravel upgrade process, we will be formatting all PHP code to follow code standards rules. We need a way to enforce these standards going forward after the initial fix for all files.

Solution

  • This PR applies code standards formatting to all files.
  • This PR adds a pre-commit git hook to enforce the new rules. If a files has formatting issues, committing will be prevented.

Relevant Files:

  • ProcessMaker/Console/Commands/InstallPreCommitHooks.php
  • .pre-commit
  • .php-cs-fixer.php
  • .gitIgnore
  • composer.json

All other changes in this PR are formatting changes from php-cs-fixer

Packages should not need any updates other than .gitignore and the initial formatting.

The hooks are installed when composer dump-autoload runs in core. This happens automatically after composer install/require/update. For packages, this creates symlinks to the hook and config file in core. It works fine on my Mac but not sure how it will behave on other systems.

Eventually this should run in CI but it's important to have it here too for fast feedback.

Before final approval and merge

Run php-cs-fixer in this branch and package branches to fix any changes that have been merged since the PR was opened and commit the results.

php-cs-fixer fix

How to Test

  1. Install php-cs-fixer globally composer global require friendsofphp/php-cs-fixer
  2. In Core, checkout this branch feature/FOUR-6588 and run composer install. This should install the git pre-commit hooks.
  3. Edit a php file and add some formatting changes. For example, change the indenting somewhere
  4. Attempt to commit the changes. You should see an error.
  5. Install the feature/FOUR-6588 branch of package-webentry. This branch has the formatting changes already applied
  6. Edit a php file in the web entry package to change formatting.
  7. Attempt to commit the change. You should see an error.

Related Tickets & Packages

Helpful links

List of package PRs

https://github.com/ProcessMaker/connector-pdf-print/pull/55
ProcessMaker/nayra#218
ProcessMaker/pmql#29
https://github.com/ProcessMaker/connector-docusign/pull/27
https://github.com/ProcessMaker/connector-slack/pull/17
https://github.com/ProcessMaker/package-actions-by-email/pull/81
https://github.com/ProcessMaker/package-advanced-user-manager/pull/25
https://github.com/ProcessMaker/package-auth/pull/62
https://github.com/ProcessMaker/package-collections/pull/320
https://github.com/ProcessMaker/package-comments/pull/80
https://github.com/ProcessMaker/package-conversational-forms/pull/41
https://github.com/ProcessMaker/package-data-sources/pull/240
https://github.com/ProcessMaker/package-webentry/pull/161
https://github.com/ProcessMaker/connector-send-email/pull/212
https://github.com/ProcessMaker/package-dynamic-ui/pull/60
https://github.com/ProcessMaker/package-files/pull/85
https://github.com/ProcessMaker/package-googleplaces/pull/32
https://github.com/ProcessMaker/package-process-documenter/pull/21
https://github.com/ProcessMaker/package-process-optimization/pull/13
https://github.com/ProcessMaker/package-savedsearch/pull/324
https://github.com/ProcessMaker/package-sentry/pull/7
https://github.com/ProcessMaker/package-signature/pull/27
https://github.com/ProcessMaker/package-translations/pull/46
https://github.com/ProcessMaker/package-versions/pull/53
https://github.com/ProcessMaker/package-vocabularies/pull/63
https://github.com/ProcessMaker/packages/pull/11
https://github.com/ProcessMaker/package-ellucian-ethos/pull/68
ProcessMaker/docker-executor-php#15

https://github.com/ProcessMaker/docker-executor-node-ssr/pull/2
ProcessMaker/docker-executor-csharp#5
ProcessMaker/docker-executor-java#4
ProcessMaker/docker-executor-r#4
https://github.com/ProcessMaker/docker-executor-python-selenium/pull/1
https://github.com/ProcessMaker/docker-executor-python/pull/1
ProcessMaker/docker-executor-node#8
https://github.com/ProcessMaker/docker-executor-migration-tools/pull/37
ProcessMaker/docker-executor-lua#7

Code Review Checklist

  • I have pulled this code locally and tested it on my instance, along with any associated packages.
  • This code adheres to ProcessMaker Coding Guidelines.
  • This code includes a unit test or an E2E test that tests its functionality, or is covered by an existing test.
  • This solution fixes the bug reported in the original ticket.
  • This solution does not alter the expected output of a component in a way that would break existing Processes.
  • This solution does not implement any breaking changes that would invalidate documentation or cause existing Processes to fail.
  • This solution has been tested with enterprise packages that rely on its functionality and does not introduce bugs in those packages.
  • This code does not duplicate functionality that already exists in the framework or in ProcessMaker.
  • This ticket conforms to the PRD associated with this part of ProcessMaker.

Copy link
Contributor

@agustinbusso agustinbusso left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems to be working as expected. Working using the terminal and github desktop for mac:

Test in core

When you run php-cs-fixer fix the first time, it takes some time as you can see in the video. Maybe because is not cached at this moment.

Screen.Recording.2022-08-16.at.13.25.05.mov

Test in package

Screen.Recording.2022-08-16.at.13.23.39.mov

@ryancooley ryancooley merged commit 7a02863 into develop Aug 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants