Tools für mehr Codequalität

GrumPHP und CaptainHook

RIGHT

Andreas Mautz (@mautz_et_tong)

  • programmiere seit 1996
  • magento seit 2008
  • 3 Jahre QA
  • CTO @ webvisum
  • FireGento Board Member

Prolog: Codequalität

Prolog: Versionsverwaltung

Prolog: Hooks

  • Client-Side
  • Server-Side
Client: pre-commit, post-commit, applypatch-msg, pre-applypatch, post-applypatch, pre-rebase, post-rewrite, post-merge, pre-push Server: pre-receive, update, post-receive

Teil 1: GrumPHP

Disclaimer

  • Mag ich lieber
  • Ohne Gründe
  • Täglicher Einsatz

Was ist GrumPHP?

-> A PHP code-quality tool

Installation

phive, composer -> configure by adding grumphp.yml grumphp git:init

Benutzung

                        
parameters:
  magento_dir: ./www/html
  bin_dir: "%magento_dir%/vendor/bin"
  git_dir: "."
  hide_circumvention_tip: true
  process_timeout: 120
  stop_on_failure: false
  ignore_unstaged_changes: false
  tasks:
    # run PHP_CodeSniffer
    phpcs:
      standard: "Magento2"
      whitelist_patterns: ["^www/html/app/code/(.*)"]
      ignore_patterns: ["^www/html/app/code/Magento/(.*)"]
      tab_width: 4
      metadata:
        priority: 70
                        
                    
configure git:init git:deinit git:pre-commit git:commit-msg run

Demo!

Teil 2: CaptainHook

Disclaimer

  • Nicht so bewandert
  • Nicht im regelmässigen Einsatz

Was ist CaptainHook

-> CaptainHook is an easy to use and very flexible git hook library for php developers. It enables you to configure your git hook actions in a simple json file.

Installation

phive, composer -> configure install

Benutzung

                        
{
    "pre-commit": {
        "enabled": true,
        "actions": [
          {
            "action": "phpunit"
          },
          {
            "action": "phpcs --standard=psr2 src/sample"
          }
        ]
    }
}

                        
                    
add Add an action to a hook configuration configure Configure your hooks disable Disable a hook execution enable Enable a hook execution help Displays help for a command install Install git hooks list Lists commands hook hook:commit-msg Run git commit-msg hook. hook:post-checkout Run git post-checkout hook. hook:post-commit Run git post-commit hook. hook:post-merge Run git post-merge hook. hook:pre-commit Run git pre-commit hook. hook:pre-push Run git pre-push hook. hook:prepare-commit-msg Run git prepare-commit-msg hook.

Demo!

Questions?

RIGHT
https://www.youtube.com/embed/VM-2OVNt-eQ?controls=0

SOURCES

  • Git Hooks
  • Github GrumPHP
  • AmsterdamPHP Talk GrumPHP 2016
  • Github Captainhook
  • MageUc19 Talk Stephan Hochdörfer Captain Hook
  • bitexpert Setup Captain Hook for Magento
  • Bilder von Pixabay