using git hooks to help your
play

Using Git Hooks to Help Your 40 40 40 Joo Santos Engineering - PowerPoint PPT Presentation

255 105 0 149 149 149 225 225 225 68 84 106 84 28 0 0 0 153 65 0 102 Using Git Hooks to Help Your 40 40 40 Joo Santos Engineering Teams Work Software Engineer joao.santos@zalando.de Autonomously @joaomcsantos Europython 2015


  1. 255 105 0 149 149 149 225 225 225 68 84 106 84 28 0 0 0 153 65 0 102 Using Git Hooks to Help Your 40 40 40 João Santos Engineering Teams Work Software Engineer joao.santos@zalando.de Autonomously @joaomcsantos Europython 2015

  2. 255 105 0 149 149 149 Quick Facts About Zalando Tech 225 225 225 68 84 106 ● Tech HQ in Berlin 84 28 0 0 0 153 ● Other tech offices in Dublin, Helsinki, Dortmund, 65 0 102 Mönchengladbach, Erfurt ● +700 technologists 40 40 40 ● Nearly everything produced in-house

  3. 255 105 0 149 149 149 225 225 225 68 84 106 84 28 0 Why? 0 0 153 65 0 102 40 40 40 Why do we need hooks and rules?

  4. 255 105 0 149 149 149 225 225 225 68 84 106 84 28 0 How? 0 0 153 65 0 102 40 40 40 How should the rules be enforced?

  5. 255 105 0 149 149 149 225 225 225 68 84 106 Dark Ages of 84 28 0 0 0 153 65 0 102 SVN 40 40 40

  6. 255 105 0 Dark Ages of SVN 149 149 149 225 225 225 68 84 106 ● Bash script 84 28 0 0 0 153 65 0 102 40 40 40

  7. 255 105 0 Dark Ages of SVN 149 149 149 225 225 225 68 84 106 ● Bash script 84 28 0 0 0 153 ● Python Hook 65 0 102 40 40 40

  8. 255 105 0 149 149 149 225 225 225 68 84 106 The Age of the 84 28 0 0 0 153 65 0 102 Git Hook 40 40 40

  9. 255 105 0 149 149 149 The Age of the Git Hook - First Plan 225 225 225 68 84 106 ● A common code base for git and svn 84 28 0 0 0 153 65 0 102 40 40 40

  10. 255 105 0 149 149 149 The Age of the Git Hook - First Plan 225 225 225 68 84 106 ● A common code base for git and svn 84 28 0 0 0 153 ● Pre-receive hook 65 0 102 40 40 40

  11. 255 105 0 149 149 149 The Age of the Git Hook - First Feedback 225 225 225 68 84 106 ● Git is not SVN 84 28 0 0 0 153 65 0 102 40 40 40

  12. 255 105 0 149 149 149 The Age of the Git Hook - First Feedback 225 225 225 68 84 106 ● Git is not SVN 84 28 0 0 0 153 ● People don't use Git the same way 65 0 102 40 40 40

  13. 255 105 0 149 149 149 The Age of the Git Hook - Plan B 225 225 225 68 84 106 ● A dedicated hook for Git 84 28 0 0 0 153 65 0 102 40 40 40

  14. 255 105 0 149 149 149 The Age of the Git Hook - Plan B 225 225 225 68 84 106 ● A dedicated hook for Git 84 28 0 0 0 153 ● Allow teams to tailor the hooks to their needs 65 0 102 40 40 40

  15. 255 105 0 149 149 149 The Age of the Git Hook - Customization 225 225 225 68 84 106 "*playground-*": 84 28 0 check_from: 9999-01-01T00:00 0 0 153 TEAM1/*: 65 0 102 check_from: 2014-01-08T00:00 allowed_projects: [PROJECT1] extra_on_push: [jira.fix_version] 40 40 40 merge_to_feature: [live, master] TEAM1/repository42: allowed_projects: [PROJECT1, PROJECT2] TEAM2/*: allowed_projects: [PROJECT3] check_from: 2014-03-31T12:30 disable_on_push: [git.is_feature_or_bugfix_branch]

  16. 255 105 0 149 149 149 The Age of the Git Hook - Problems 225 225 225 68 84 106 ● Centralized configuration 84 28 0 0 0 153 65 0 102 40 40 40

  17. 255 105 0 149 149 149 The Age of the Git Hook - Problems 225 225 225 68 84 106 ● Centralized configuration 84 28 0 0 0 153 ● Trying to check commits on a push 65 0 102 40 40 40

  18. 255 105 0 149 149 149 The Age of the Git Hook - Problems 225 225 225 68 84 106 ● Centralized configuration 84 28 0 0 0 153 ● Trying to check commits on a push 65 0 102 1. Git history is not linear 40 40 40

  19. 255 105 0 149 149 149 The Age of the Git Hook - Problems 225 225 225 68 84 106 ● Centralized configuration 84 28 0 0 0 153 ● Trying to check commits on a push 65 0 102 1. Git history is not linear 40 40 40 2. Merging to/from a long lived branch

  20. 255 105 0 149 149 149 The Age of the Git Hook - Problems 225 225 225 68 84 106 ● Centralized configuration 84 28 0 0 0 153 ● Trying to check commits on a push 65 0 102 1. Git history is not linear 40 40 40 2. Merging to/from a long lived branch ● Checking code style is slow

  21. 255 105 0 149 149 149 The Age of the Git Hook - Problems 225 225 225 68 84 106 ● Centralized configuration 84 28 0 0 0 153 ● Trying to check commits on a push 65 0 102 1. Git history is not linear 40 40 40 2. Merging to/from a long lived branch ● Checking code style is slow ● Inflexible

  22. 255 105 0 149 149 149 The Age of the Git Hook - Problems 225 225 225 68 84 106 ● Centralizing Git 84 28 0 0 0 153 65 0 102 40 40 40

  23. 255 105 0 149 149 149 225 225 225 68 84 106 The Age of 84 28 0 0 0 153 65 0 102 Autonomy 40 40 40

  24. 255 105 0 149 149 149 The Age of the Autonomy 225 225 225 68 84 106 ● Local git hooks 84 28 0 0 0 153 65 0 102 40 40 40

  25. 255 105 0 149 149 149 The Age of the Autonomy 225 225 225 68 84 106 ● Local git hooks 84 28 0 0 0 153 ● Optional, a helper not a blocker 65 0 102 40 40 40

  26. 255 105 0 149 149 149 The Age of the Autonomy 225 225 225 68 84 106 ● Local git hooks 84 28 0 0 0 153 ● Optional, a helper not a blocker 65 0 102 ● Extensible, one size doesn't fit all 40 40 40

  27. 255 105 0 149 149 149 The Age of the Autonomy 225 225 225 68 84 106 ● Local git hooks 84 28 0 0 0 153 ● Optional, a helper not a blocker 65 0 102 ● Extensible, one size doesn't fit all 40 40 40 ● Open Source

  28. 255 105 0 149 149 149 The Age of the Autonomy - Turnstile 225 225 225 68 84 106 https://github.com/zalando/turnstile 84 28 0 0 0 153 65 0 102 https://pypi.python.org/pypi/turnstile-core 40 40 40

  29. 255 105 0 149 149 149 Turnstile - How to install it 225 225 225 68 84 106 $ pip install turnstile-core 84 28 0 0 0 153 65 0 102 40 40 40

  30. 255 105 0 149 149 149 Turnstile - How to use it 225 225 225 68 84 106 ● Add a .turnstile.yml file to your repository 84 28 0 0 0 153 65 0 102 40 40 40

  31. 255 105 0 149 149 149 Turnstile - How to use it 225 225 225 68 84 106 ● Add a .turnstile.yml file to your repository 84 28 0 0 0 153 65 0 102 checks: - specification - branch-release 40 40 40 - protect-master specification: allowed_schemes: ['https'] branch-release: pattern: '^v(?:\d|\_|\.)+$'

  32. 255 105 0 149 149 149 Turnstile - How to use it 225 225 225 68 84 106 ● Add a .turnstile.yml file to your repository 84 28 0 0 0 153 ● Install the hooks on your repository: 65 0 102 $ turnstile install 40 40 40

  33. 255 105 0 149 149 149 Turnstile - More than a hook 225 225 225 68 84 106 ● Core subcommands: 84 28 0 ○ config 0 0 153 65 0 102 ○ install ○ remove 40 40 40 ○ specification ○ upgrade ○ version

  34. 255 105 0 149 149 149 Turnstile - Extending Turnstile 225 225 225 68 84 106 84 28 0 setup( 0 0 153 name='turnstile-codevalidator', 65 0 102 ... entry_points={ 40 40 40 'turnstile.commands': ['codevalidator = turnstile_cv.command'], 'turnstile.pre_commit': ['codevalidator = turnstile_cv.check']})

  35. 255 105 0 149 149 149 Turnstile - Extending Turnstile 225 225 225 68 84 106 ● Entry points 84 28 0 0 0 153 ○ turnstile.commands 65 0 102 ○ turnstile.commit_msg 40 40 40 ○ turnstile.pre_commit

  36. 255 105 0 149 149 149 What we learned 225 225 225 68 84 106 ● Don't get stuck in the past 84 28 0 0 0 153 65 0 102 40 40 40

  37. 255 105 0 149 149 149 What we learned 225 225 225 68 84 106 ● Don't get stuck in the past 84 28 0 0 0 153 ● Develop in the open 65 0 102 40 40 40

  38. 255 105 0 149 149 149 What we learned 225 225 225 68 84 106 ● Don't get stuck in the past 84 28 0 0 0 153 ● Develop in the open 65 0 102 ● Build tools not barriers 40 40 40

  39. 255 105 0 Ask Questions 149 149 149 225 225 225 68 84 106 84 28 0 https://pypi.python.org/pypi/turnstile-core 0 0 153 65 0 102 https://github.com/zalando/turnstile 40 40 40 https://turnstile.readthedocs.org @joaomcsantos

  40. 255 105 0 149 149 149 Where to Find Us: 225 225 225 68 84 106 Tech Blog: tech.zalando.com 84 28 0 0 0 153 GitHub: github.com/zalando 65 0 102 Twitter: @ZalandoTech 40 40 40 Instagram: zalandotech Jobs: http://tech.zalando.com/jobs

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend