Slide 1

Slide 1 text

overcommit & pronto introduction Japanese: @zyunnosuke English: @morizyune

Slide 2

Slide 2 text

Today's Topic • Introducing RubyGems to improve productivity: • https://github.com/brigade/overcommit • https://github.com/mmozuras/pronto

Slide 3

Slide 3 text

When should run Rubocop / Lint Tool? • CI(Jenkins) -> Too late... • Manual execution -> Sometimes forgot... • Before git commit/push(overcommit) -> Best

Slide 4

Slide 4 text

Introducing overcommit • A fully configurable and extendable Git hook manager • Run automatically Rubocop, Brakeman, etc when you execute "Git commands"

Slide 5

Slide 5 text

Profits of overcommit? • Readability • You can get some suggestions to adjust coding rule in only changed files by Rubocop, EsLint(JS), etc • Vulnerability Scan • You can scan vulnerability in your project by Brakeman, bundle-audit, etc. • Share "Git Best Practice” • Check for illegal pushes to protected branches, commit message matches expected pattern, etc

Slide 6

Slide 6 text

Installation (1) • overcommit is installed by bundler: gem 'overcommit' gem 'rubocop', require: false

Slide 7

Slide 7 text

Installation (2) • Generate git hook in each machine: # generate git hook $ overcommit --install #=> .git/hooks/pre-rebase #=> .git/hooks/pre-push #=> .git/hooks/pre-commit #=> .git/hooks/post-rewrite #=> .git/hooks/post-merge #=> .git/hooks/post-commit #=> .git/hooks/post-checkout #=> .git/hooks/overcommit-hook #=> .git/hooks/commit-msg

Slide 8

Slide 8 text

Rubocop Configuration • The configuration is stored in .overcommit.yml: gemfile: 'Gemfile' # load Gemfile in git hook PreCommit: RuboCop: enabled: true

Slide 9

Slide 9 text

Activate Configuration • After the change, you should activate the configuration: $ bundle exec overcommit --sign

Slide 10

Slide 10 text

Usage # Run pre-commit hook (Automatically run) $ git commit # Run pre-commit hook against all tracked files $ bundle exec overcommit --run

Slide 11

Slide 11 text

Built-In Hooks • overcommit supports 105 tools • Not only Ruby, but also JS, Scala, Java, Python!

Slide 12

Slide 12 text

overcommit tips • If you want to disable overcommit, you can use the follows: $ OVERCOMMIT_DISABLE=1 git commit $ export GIT_TEMPLATE_DIR=`overcommit --template-dir` • If you want to install automatically Overcommit Hooks, please run:

Slide 13

Slide 13 text

pronto • Runs analysis Rubocop, etc by checking only the relevant changes • Created to be used on PR(GitHub), message on GitLab commits

Slide 14

Slide 14 text

Installation • You can install Pronto using bundler: gem 'pronto' gem 'pronto-rubocop', require: false

Slide 15

Slide 15 text

Usage for Local/GitHub # Analyze *all* changes since the *initial* commit (may take some time): $ pronto run --commit=$(git log -- pretty=format:%H | head -1) # if you want comments to appear on pull request diff: $ GITHUB_ACCESS_TOKEN=token pronto run -f github_pr -c origin/master

Slide 16

Slide 16 text

Configuration for GitLab • The behavior of Pronto can be controlled via the .pronto.yml: all: exclude: - 'spec**/*' gitlab: slug: 445 # Project id api_private_token: 46751 # Get by Profile Seeting api_endpoint: https://gitlabcomapiv3 max_warnings: 150 verbose: false

Slide 17

Slide 17 text

Usage for GitLab # Get the results as comments on GitLab commits $ GITLAB_API_ENDPOINT="https://gitlab.com/api/v3" GITLAB_API_PRIVATE_TOKEN=token pronto run -f gitlab -c origin/master

Slide 18

Slide 18 text

Pronto Runners • Currently available: