<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
<title type="text">Saddler - checkstyle to anywhere</title>
<generator uri="https://github.com/jekyll/jekyll">Jekyll</generator>
<link rel="self" type="application/atom+xml" href="https://packsaddle.org/feed.xml" />
<link rel="alternate" type="text/html" href="https://packsaddle.org" />
<updated>2022-12-09T04:01:21+00:00</updated>
<id>https://packsaddle.org/</id>
<author>
  <name>Kenichi 'Sanemat' Murahashi</name>
  <uri>https://packsaddle.org/</uri>
  <email>ogataken@gmail.com</email>
</author>


<entry>
  <title type="html"><![CDATA[restore_bundled_withを使ってBundlerのBUNDLED WITHをうまく取り扱う]]></title>
  <link rel="alternate" type="text/html" href="https://packsaddle.org/articles/restore-bundled-with-overview/" />
  <id>https://packsaddle.org/articles/restore-bundled-with-overview</id>
  <published>2015-06-21T00:00:00+00:00</published>
  <updated>2015-06-21T00:00:00+00:00</updated>
  <author>
    <name>Kenichi 'Sanemat' Murahashi</name>
    <uri>https://packsaddle.org</uri>
    <email>ogataken@gmail.com</email>
  </author>
  <content type="html">
    &lt;h2 id=&quot;tldr&quot;&gt;tl;dr&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;Bundler v1.10.0からBUNDLED WITHのsectionが導入された。&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://rubygems.org/gems/restore_bundled_with&quot;&gt;restore_bundled_with&lt;/a&gt;を使うことで、Bundler開発チームの精神を逸脱して(!)、異なるversionのBundlerとBUNDLED WITHをうまく取り扱う。&lt;/li&gt;
&lt;/ul&gt;

&lt;figure&gt;
  &lt;img src=&quot;/images/2015-06-21-bundled-with.png&quot; alt=&quot;BUNDLED WITH section&quot; /&gt;
  &lt;figcaption&gt;BUNDLED WITHのsectionで差分が出る&lt;/figcaption&gt;
&lt;/figure&gt;

&lt;h2 id=&quot;bundler-v110-とbundled-with&quot;&gt;Bundler v1.10 とBUNDLED WITH&lt;/h2&gt;

&lt;p&gt;Bundler v1.10.0から&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;BUNDLED WITH&lt;/code&gt;というsectionに&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;bundle update&lt;/code&gt;を実行したBundlerのversionを
記録するようになった。
日本語詳細はこちらが詳しい。
&lt;a href=&quot;http://qiita.com/suu_g/items/2b1630b8015d51c5292e&quot;&gt;Ruby - BUNDLED WITH で Gemfile.lock が更新されてしまう件 - Qiita&lt;/a&gt;&lt;/p&gt;

&lt;h3 id=&quot;挙動の確認&quot;&gt;挙動の確認&lt;/h3&gt;

&lt;p&gt;Bundler v1.10.2で&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;bundle update&lt;/code&gt;して、BUNDLED WITHにversionを記録しておく。&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;cat &lt;/span&gt;Gemfile.lock
GEM
  remote: https://rubygems.org/
  specs:
    actionmailer &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;4.1.11&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
      actionpack &lt;span class=&quot;o&quot;&gt;(=&lt;/span&gt; 4.1.11&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;snip&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
  unicorn-worker-killer
  webmock

BUNDLED WITH
   1.10.2&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;h4 id=&quot;bundler-v199で-bundle-update&quot;&gt;Bundler v1.9.9で bundle update&lt;/h4&gt;

&lt;p&gt;BUNDLED WITHのsectionごと消える。悲しい。&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;bundle update
&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;update&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;git diff
&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;snip&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
@@ &lt;span class=&quot;nt&quot;&gt;-289&lt;/span&gt;,6 +290,3 @@ DEPENDENCIES
   unicorn
   unicorn-worker-killer
   webmock
-
&lt;span class=&quot;nt&quot;&gt;-BUNDLED&lt;/span&gt; WITH
-   1.10.2&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;h4 id=&quot;bundler-v1104新しいで-bundle-update&quot;&gt;Bundler v1.10.4(新しい)で bundle update&lt;/h4&gt;

&lt;p&gt;BUNDLED WITHの記録を更新する。&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;bundle update
&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;update&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;git diff
&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;snip&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
@@ &lt;span class=&quot;nt&quot;&gt;-291&lt;/span&gt;,4 +292,4 @@ DEPENDENCIES
   webmock

 BUNDLED WITH
-   1.10.2
+   1.10.4&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;h4 id=&quot;bundler-v1101古いで-bundle-update&quot;&gt;Bundler v1.10.1(古い)で bundle update&lt;/h4&gt;

&lt;p&gt;Warning出しつつ、BUNDLED WITHは更新しない。&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;bundle update
Warning: the running version of Bundler is older than the version that created the lockfile.
We suggest you upgrade to the latest version of Bundler by running &lt;span class=&quot;sb&quot;&gt;`&lt;/span&gt;gem &lt;span class=&quot;nb&quot;&gt;install &lt;/span&gt;bundler&lt;span class=&quot;sb&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;.&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;snip&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;git diff
&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;no diff&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;h2 id=&quot;正しい解&quot;&gt;正しい解&lt;/h2&gt;

&lt;p&gt;まずは、Bundlerのversionをv1.10系の最新版に上げる。
そして、依存ライブラリのバージョンを上げていくと同時にBundlerも最新版が出るたびに上げていく。&lt;/p&gt;

&lt;h2 id=&quot;現実解&quot;&gt;現実解?&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;そうは言っても、localではpreとかv2とか新しすぎるものも使いたい。&lt;/li&gt;
  &lt;li&gt;実際にproductionで実行するBundlerのversionと離れてしまいかねないのはいつか問題になりそう。&lt;/li&gt;
  &lt;li&gt;Gemfileの中はBundler管轄だけど、Bundler自体はそこで管理してないわけで、lockの記述に引きずられるのはどうなんだろう(私見)&lt;/li&gt;
  &lt;li&gt;minimalなbundlerのmini_bundler(仮)が薄くいて、bundle execなどのコマンドはその内側でバージョン管理されたbundlerで実行すればいい?(私見)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;などの理由から、Bundler開発チームの精神を逸脱して(!)、&lt;a href=&quot;https://rubygems.org/gems/restore_bundled_with&quot;&gt;restore_bundled_with&lt;/a&gt;というgemの&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;restore-bundled-with&lt;/code&gt;コマンドを使う。&lt;/p&gt;

&lt;h2 id=&quot;restore_bundled_with&quot;&gt;restore_bundled_with&lt;/h2&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Gemfile.lock&lt;/code&gt;のBUNDLED WITHにリポジトリとdiffがある状態で、&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;restore-bundled-with&lt;/code&gt;コマンドを実行する。
つまり、&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;bundle update&lt;/code&gt;したあと、commitする前に、&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;restore-bundled-with&lt;/code&gt;する。
すると、リポジトリからBUNDLED WITHのsectionを取り出してきて、そこだけ元に戻る。&lt;/p&gt;

&lt;p&gt;Bundler v1.9なら、消えたsectionが戻る。
より新しいBundler v1.10なら、使った記録がそこだけ戻る。&lt;/p&gt;

&lt;h3 id=&quot;example&quot;&gt;Example&lt;/h3&gt;

&lt;h4 id=&quot;newer-bundler-case&quot;&gt;Newer Bundler Case&lt;/h4&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;cat &lt;/span&gt;Gemfile.lock
&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;snip&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
  unicorn-worker-killer
  webmock

BUNDLED WITH
   1.10.2&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Execute &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;bundle update&lt;/code&gt; by Bundler v1.10.3.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;bundle update
&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;update&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;git diff
&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;snip&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
@@ &lt;span class=&quot;nt&quot;&gt;-291&lt;/span&gt;,4 +296,4 @@ DEPENDENCIES
   webmock

 BUNDLED WITH
-   1.10.2
+   1.10.3&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Then, execute &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;restore-bundled-with&lt;/code&gt;.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;restore-bundled-with
&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;restore BUNDLED WITH section&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;git diff
&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;no diff&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;There is no diff, because this restores &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;BUNDLED WITH&lt;/code&gt; from git repository.&lt;/p&gt;

&lt;h2 id=&quot;まとめ&quot;&gt;まとめ&lt;/h2&gt;

&lt;p&gt;Bundler開発チームの精神を逸脱するので、あまり推奨はしない。
最新版を使って、もし壊れていたらみんなで直していくのが、アプリケーションを健全に保つ一番痛みが少ない方法なのです!&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://github.com/packsaddle/ruby-restore_bundled_with/issues/new&quot;&gt;詰まったら聞いて&lt;/a&gt;ください。このサイトやREADMEなどに反映します。
&lt;a href=&quot;https://github.com/packsaddle/ruby-restore_bundled_with&quot;&gt;ruby-restore_bundled_withにスター&lt;/a&gt;ください!&lt;/p&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;参照&quot;&gt;参照&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/packsaddle/ruby-restore_bundled_with&quot;&gt;ruby-restore_bundled_withにスター&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://qiita.com/suu_g/items/2b1630b8015d51c5292e&quot;&gt;Ruby - BUNDLED WITH で Gemfile.lock が更新されてしまう件 - Qiita&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/bundler/bundler/pull/3485&quot;&gt;Track Bundler version in lockfile by smlance #3485 bundler/bundler&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/bundler/bundler/issues/3697&quot;&gt;Do not update BUNDLED WITH if no other changes to the lock happened #3697 bundler/bundler&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

    &lt;p&gt;&lt;a href=&quot;https://packsaddle.org/articles/restore-bundled-with-overview/&quot;&gt;restore_bundled_withを使ってBundlerのBUNDLED WITHをうまく取り扱う&lt;/a&gt; was originally published by Kenichi 'Sanemat' Murahashi at &lt;a href=&quot;https://packsaddle.org&quot;&gt;Saddler - checkstyle to anywhere&lt;/a&gt; on June 21, 2015.&lt;/p&gt;
  </content>
</entry>


<entry>
  <title type="html"><![CDATA[Ruby version policy with Travis-CI]]></title>
  <link rel="alternate" type="text/html" href="https://packsaddle.org/articles/ruby-semver-with-travis-ci/" />
  <id>https://packsaddle.org/articles/ruby-semver-with-travis-ci</id>
  <published>2015-03-28T00:00:00+00:00</published>
  <updated>2015-03-28T00:00:00+00:00</updated>
  <author>
    <name>Kenichi 'Sanemat' Murahashi</name>
    <uri>https://packsaddle.org</uri>
    <email>ogataken@gmail.com</email>
  </author>
  <content type="html">
    &lt;p&gt;Ruby uses semver after &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;2.1.0&lt;/code&gt;.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-yaml&quot; data-lang=&quot;yaml&quot;&gt;&lt;span class=&quot;c1&quot;&gt;# .travis.yml&lt;/span&gt;
&lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;1.9.2&lt;/span&gt;
&lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;1.9.3&lt;/span&gt;
&lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;2.0.0&lt;/span&gt;
&lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;2.1&lt;/span&gt;
&lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;2.2&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;So this means &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;1.9.2-p330&lt;/code&gt;(latest), &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;1.9.3-p551&lt;/code&gt;(latest), &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;2.0.0-p643&lt;/code&gt;(latest), &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;2.1.5&lt;/code&gt;(latest), &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;2.2.1&lt;/code&gt;(latest).
But &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;2.1.0&lt;/code&gt; means &lt;em&gt;exactly&lt;/em&gt; &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;2.1.0&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;They follows Travis-CI’s latest precompiled one.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.ruby-lang.org/en/news/2013/12/21/ruby-version-policy-changes-with-2-1-0/&quot;&gt;Ruby version policy changes starting with Ruby 2.1.0&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/sstephenson/ruby-build/tree/a55247a8c5eacc485ed1ce8bc0129376d6b00298/share/ruby-build&quot;&gt;ruby-build’s targets&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://rubies.travis-ci.org/&quot;&gt;Travis CI: Precompiled Ruby Versions&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

    &lt;p&gt;&lt;a href=&quot;https://packsaddle.org/articles/ruby-semver-with-travis-ci/&quot;&gt;Ruby version policy with Travis-CI&lt;/a&gt; was originally published by Kenichi 'Sanemat' Murahashi at &lt;a href=&quot;https://packsaddle.org&quot;&gt;Saddler - checkstyle to anywhere&lt;/a&gt; on March 28, 2015.&lt;/p&gt;
  </content>
</entry>


<entry>
  <title type="html"><![CDATA[TravisCIとCircleCIでちょっとずつ違うビルド環境の考え方の違い]]></title>
  <link rel="alternate" type="text/html" href="https://packsaddle.org/articles/differences-between-travis-ci-and-circle-ci/" />
  <id>https://packsaddle.org/articles/differences-between-travis-ci-and-circle-ci</id>
  <published>2015-03-17T00:00:00+00:00</published>
  <updated>2015-03-17T00:00:00+00:00</updated>
  <author>
    <name>Kenichi 'Sanemat' Murahashi</name>
    <uri>https://packsaddle.org</uri>
    <email>ogataken@gmail.com</email>
  </author>
  <content type="html">
    &lt;h2 id=&quot;tldr&quot;&gt;tl;dr&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;TravisCIとCircleCIの根底にある違いの考え方を理解すると早い。&lt;/li&gt;
  &lt;li&gt;そして、違いを考慮しているproductを使うと便利。
    &lt;ul&gt;
      &lt;li&gt;e.g. &lt;a href=&quot;https://github.com/packsaddle/ruby-saddler&quot;&gt;checkstyle形式の結果をpull request review commentするsaddler&lt;/a&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;figure class=&quot;half&quot;&gt;
  &lt;img src=&quot;/images/2015-03-17-travis-result.png&quot; alt=&quot;TravisCI result&quot; /&gt;
  &lt;img src=&quot;/images/2015-03-17-circle-result.png&quot; alt=&quot;CircleCI result&quot; /&gt;
  &lt;figcaption&gt;CI result&lt;/figcaption&gt;
&lt;/figure&gt;

&lt;h2 id=&quot;考え方&quot;&gt;考え方&lt;/h2&gt;

&lt;h3 id=&quot;circleci&quot;&gt;CircleCI&lt;/h3&gt;

&lt;ul&gt;
  &lt;li&gt;pushされたbranchをビルドする。&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;travisci&quot;&gt;TravisCI&lt;/h3&gt;

&lt;ul&gt;
  &lt;li&gt;pushされたbranchをビルドする。&lt;/li&gt;
  &lt;li&gt;pull requestのbranchを、仮にmasterにmergeしてみて、ビルドする。&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;仮にmasterにmergeしてみて&quot;&gt;仮にmasterにmergeしてみて??&lt;/h2&gt;

&lt;p&gt;TravisCIの二つ目のがわかりにくくて、混乱する。
やっていることは正しいんだけど、挙動が直感から外れるので、
TravisCIヘビーに使っているユーザーにもわりと意味不明挙動扱いされやすい(要出典)&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;pull requestするとtravisのビルドがなぜか2個走る&lt;/li&gt;
  &lt;li&gt;(GitHub statusが最新結果しか取れなかった頃は)一度passしたはずのテストが、
なぜかあとからやってきたfailにかき消される passしたはずのテストはどこへ&lt;/li&gt;
  &lt;li&gt;.travis.yml でよく見る branches: only: - master ってなんだよ
おれはmaster以外のテストもしたいぞ
あれ、よくわからないが意図通りに動いてるぞ
何だこの設定&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;たとえばbranchを作った時のmasterと今のmasterが乖離していて、
pull requestのbranchのテストは全部通るけど、mergeしたらmasterが落ちる、
というのはよくあることだと思う。
そこを人間任せにするのか「ちゃんとmasterに追い付かせておいてね」、
仮にmergeしてみてtestするのか、は考え方による。
後者は便利に見えるが、なんで落ちたかよくわからない状況になることもありがち。&lt;/p&gt;

&lt;h3 id=&quot;branchのpushでbuildされるとジャマ&quot;&gt;branchのpushでbuildされるとジャマ&lt;/h3&gt;

&lt;p&gt;となると単にbranchをpushしただけでbuildされるとジャマなので、&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-yaml&quot; data-lang=&quot;yaml&quot;&gt;&lt;span class=&quot;c1&quot;&gt;# .travis.yml&lt;/span&gt;
&lt;span class=&quot;na&quot;&gt;branches&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;only&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
  &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;master&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;としたい。
これで、master branchへの変更、およびmasterに対してのpull requestに仮にmergeしてみて、が走る。
大きめのfeatureブランチを作っていて、
そのfeatureブランチに対するpull requestも仮にmergeしてみて、をしたい場合&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-yaml&quot; data-lang=&quot;yaml&quot;&gt;&lt;span class=&quot;c1&quot;&gt;# .travis.yml&lt;/span&gt;
&lt;span class=&quot;na&quot;&gt;branches&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;only&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
  &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;master&lt;/span&gt;
  &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;feature/your-big-change&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;とすればよい。&lt;/p&gt;

&lt;p&gt;なにかこのブランチが作られた時には、hookで何かしたい、などの場合は&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-yaml&quot; data-lang=&quot;yaml&quot;&gt;&lt;span class=&quot;c1&quot;&gt;# .travis.yml&lt;/span&gt;
&lt;span class=&quot;na&quot;&gt;branches&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;only&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
  &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;master&lt;/span&gt;
  &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;/^cron_for_tachikoma\/.*/&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;とする。正規表現が使える。&lt;/p&gt;

&lt;h2 id=&quot;pull-request時の挙動&quot;&gt;pull request時の挙動&lt;/h2&gt;

&lt;h3 id=&quot;travisci-1&quot;&gt;TravisCI&lt;/h3&gt;

&lt;p&gt;pull request作成時にhookで起動する。
条件を満たしていれば。&lt;/p&gt;

&lt;p&gt;pull request済みのbranchに追加のcommitでも起動する。&lt;/p&gt;

&lt;h3 id=&quot;circleci-1&quot;&gt;CircleCI&lt;/h3&gt;

&lt;p&gt;pull request作成時にはhookで&lt;strong&gt;起動しない&lt;/strong&gt;。
branchのpushを検知する側だけなので。&lt;/p&gt;

&lt;p&gt;だから、pull requestに対して何かをしたい、例えばlintしてコメントをつけるとか、の場合、
さっさとpull requestをつくらないと、コメントをpostする先のpull requestがない状態で、
処理が終わってしまう。
branchをpushしてしばらくしてからpull request作成、
そのpull requestに追加でcommitしてpush、
この後者のpushのタイミングで初めてコメントが付くことになる。
ちょっと注意。&lt;/p&gt;

&lt;h2 id=&quot;git操作での挙動&quot;&gt;git操作での挙動&lt;/h2&gt;

&lt;h3 id=&quot;travisci-2&quot;&gt;TravisCI&lt;/h3&gt;

&lt;p&gt;仮にmergeしてみる TravisCI式がいいことづくめか?
というとそうでもない。&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-text&quot; data-lang=&quot;text&quot;&gt;# TravisCI checkoutの挙動(logより)
$ git clone --depth=50 git://github.com/sanemat/ruby-example-rails-banana.git sanemat/ruby-example-rails-banana
$ cd sanemat/ruby-example-rails-banana
$ git fetch origin +refs/pull/2/merge:
$ git checkout -qf FETCH_HEAD

$ tig
13fac8f 2015-03-16 23:35 Murahashi Sanemat Kenichi M─┐ [HEAD] Merge c47af08fe6c62f6c95fa9dea440866d6348ac38
c47af08 2015-03-16 23:35 sanemat                   │ o Bundle update 20150316_23-34-12
37f6de7 2015-03-17 08:07 Murahashi Sanemat Kenichi o─┘ [master] {origin/HEAD} {origin/master} chore(tachiko
8b7d629 2015-03-17 07:58 Murahashi Sanemat Kenichi o chore(travis): add debug

$ git branch
* (detached from FETCH_HEAD)
  master&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;git 操作でなにかするアプリの場合、
あまりこれを想定した挙動になっていないことが多い。
それからたとえば、GitHubのapiと連携してpull requestにreview commentをつけたいので、
上のtigで言う&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;c47af08&lt;/code&gt;を取りたい場合に、うってなる。
&lt;a href=&quot;https://github.com/packsaddle/ruby-saddler-reporter-support-git/blob/cc8ce5f819e4d137b94f71b3f3ca4f3f7208ba00/lib/saddler/reporter/support/git/repository.rb#L39-L50&quot;&gt;saddler-reporter-support-gitでは結構頑張って解決&lt;/a&gt;
している。
feature branchにmasterをmergeして追い付かせた時に正しく検出しなそう、とかある。&lt;/p&gt;

&lt;p&gt;注) TravisCIに限れば、環境変数 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;TRAVIS_COMMIT&lt;/code&gt;で該当コミットが取れる。&lt;/p&gt;

&lt;p&gt;この「仮にmergeしてみる」は色々流派がありそうで、実際対TravisCIでは動いているけど、
他のパターンが有るときに全部解決してるかは自信ない。&lt;/p&gt;

&lt;h4 id=&quot;pushされたbranchのビルド&quot;&gt;pushされたbranchのビルド&lt;/h4&gt;

&lt;p&gt;Travisは必要最低限にチューンしてあるので、masterとかorigin/masterとかいない。
ちょっとだけ注意。&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;git checkout &lt;span class=&quot;nt&quot;&gt;-b&lt;/span&gt; YOU_WANT_TO_CREATE origin/master&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;と手癖で打つと&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;origin/master&lt;/code&gt;無いので落ちる。&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-text&quot; data-lang=&quot;text&quot;&gt;# TravisCI checkoutの挙動(logより)
$ git clone --depth=50 --branch=cron_for_tachikoma/56e24ecc-46bd-4d15-92fb-8d27fde41c8c git://github.com/sanemat/ruby-example-rails-banana.git sanemat/ruby-example-rails-banana
$ cd sanemat/ruby-example-rails-banana
$ git checkout -qf 8b7d6291495e947c7961e98dd9d89042eed2fd05

$ git branch
* (detached from 8b7d629)
  cron_for_tachikoma/56e24ecc-46bd-4d15-92fb-8d27fde41c8c

$ git branch -r
  origin/cron_for_tachikoma/56e24ecc-46bd-4d15-92fb-8d27fde41c8c&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;h5 id=&quot;余談&quot;&gt;余談&lt;/h5&gt;

&lt;p&gt;checkout -b したいときは&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;git checkout &lt;span class=&quot;nt&quot;&gt;-b&lt;/span&gt; YOU_WANT_TO_CREATE &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;TRAVIS_BRANCH&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;か単に&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;git checkout &lt;span class=&quot;nt&quot;&gt;-b&lt;/span&gt; YOU_WANT_TO_CREATE&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;とする。&lt;/p&gt;

&lt;h3 id=&quot;circleci-2&quot;&gt;CircleCI&lt;/h3&gt;

&lt;p&gt;CircleCIはおそらく事故防止のためにgit関連のログをwebからは表示しないので、
推測だけど&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-text&quot; data-lang=&quot;text&quot;&gt;# CircleCI checkoutの挙動(推測)
$ git clone git://github.com/sanemat/ruby-example-rails-banana.git ruby-example-rails-banana
$ cd ruby-example-rails-banana
$ git checkout YOUR_TARGET_BRANCH&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;してるだけだと思う。
オーソドックス。
そして多分cloneは初回だけで、cacheしつつあとはfetchとcheckoutっぽい。
sshで入るとこんな感じなので。&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-text&quot; data-lang=&quot;text&quot;&gt;$ git branch
  chore/use-tachikoma
  cron_for_github/530f0756-3664-4631-b5f4-eb53a842677a
* cron_for_tachikoma/bar-boo
  master
  pull/9
  tachikoma/update-20150222035312
  tachikoma/update-20150301035325&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;remote側も綺麗に全部見える(必要最低限ではなく富豪的)&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-text&quot; data-lang=&quot;text&quot;&gt;$ git branch -r
  origin/HEAD -&amp;gt; origin/master
  origin/chore/use-tachikoma
  origin/cron_for_github/0e560ce0-6ae0-49b4-a8f9-26b335a752b1
  origin/cron_for_github/44f3c4e7-af74-4e29-bbbf-6c04e1b41048
  origin/cron_for_github/530f0756-3664-4631-b5f4-eb53a842677a
  origin/cron_for_github/5b9d9688-3844-42a4-b34a-3d519177e7b3
  origin/cron_for_github/foo-bar-baz
  origin/cron_for_tachikoma/148fbb23-dc21-461b-b207-5be874ea864f
  origin/cron_for_tachikoma/2212ad06-cdd2-4e77-8071-8552f1268d9e
  origin/cron_for_tachikoma/6344f6a9-2989-4352-9e5e-78ca1f71cc41
  origin/cron_for_tachikoma/bar-boo
  origin/master
  origin/pull/9
  origin/tachikoma/update-20150215035300
  origin/tachikoma/update-20150222035312
  origin/tachikoma/update-20150301035325
  origin/tachikoma/update-20150307_13-26-17
  origin/tachikoma/update-20150307_13-34-52
  origin/tachikoma/update-20150308_15-01-02
  origin/tachikoma/update-20150315035345
  origin/tachikoma/update-20150315_15-03-42&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;h4 id=&quot;余談-1&quot;&gt;余談&lt;/h4&gt;

&lt;p&gt;これたまに &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;git fetch origin --prune&lt;/code&gt; しないと膨れ上がりそう。
ログとかの都合上あったほうがいいのかもだから詳しくは調べてない。&lt;/p&gt;

&lt;h2 id=&quot;まとめ&quot;&gt;まとめ&lt;/h2&gt;

&lt;p&gt;普通にやったらこうなる、を高速に解決しているのがCircleCI。
多分Jenkinsで自分でやったらこうなりそう、ただし低速。
ちゃんとやったらこうなる、を正しく解決しているのがTravisCI。
ただし、正しく理解しないと、適当に、じゃあこうかな? とやっても正解にたどり着けない。&lt;/p&gt;

&lt;p&gt;drone.io, wercker, teamcity, codeship, あたりのメジャーどころは、
だいたいどっちかなんじゃないかな(未調査)、
カバーできてるんじゃないかな、カバーできてるといいなあ。
詳しい人に補足おねがいしたい!!&lt;/p&gt;

&lt;p&gt;ローカルやCI上で動くはずのツールが、CIサービス上では動かないとき、
このへんの詰めが漏れてることが多いので e.g. pronto なぜか動かないときは、
ココらへんに気を配ってcontributeするとよいです。
なお、
&lt;a href=&quot;https://github.com/packsaddle/ruby-saddler&quot;&gt;checkstyle形式の結果をpull request review commentするsaddler&lt;/a&gt;
などのpacksaddleプロダクトはその辺のCI間の差異を吸収して、使うときは考えなくていいように、作ってます。&lt;/p&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;参照&quot;&gt;参照&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://circleci.com/gh/metarubygems/carrion_crow&quot;&gt;CircleCI example&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://travis-ci.org/sanemat/ruby-example-rails-banana&quot;&gt;TravisCI example&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://circleci.com/docs/configuration&quot;&gt;Configuring CircleCI - CircleCI&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://docs.travis-ci.com/user/build-configuration/&quot;&gt;Travis CI: Configuring your build&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://docs.travis-ci.com/user/ci-environment/&quot;&gt;Travis CI: The Build Environment&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://docs.travis-ci.com/user/environment-variables/&quot;&gt;Travis CI: Environment Variables&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://stackshare.io/continuous-integration&quot;&gt;Continuous Integration - StackShare&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://sideci.hatenablog.com/entry/2015/03/13/144948&quot;&gt;CI SaaS / OSSをまとめてみたら25個もあったヨ - SideCI Blog&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

    &lt;p&gt;&lt;a href=&quot;https://packsaddle.org/articles/differences-between-travis-ci-and-circle-ci/&quot;&gt;TravisCIとCircleCIでちょっとずつ違うビルド環境の考え方の違い&lt;/a&gt; was originally published by Kenichi 'Sanemat' Murahashi at &lt;a href=&quot;https://packsaddle.org&quot;&gt;Saddler - checkstyle to anywhere&lt;/a&gt; on March 17, 2015.&lt;/p&gt;
  </content>
</entry>


<entry>
  <title type="html"><![CDATA[定期的にライブラリの依存関係をアップデートしてPull Requestする]]></title>
  <link rel="alternate" type="text/html" href="https://packsaddle.org/articles/interval-pull-request-update-overview/" />
  <id>https://packsaddle.org/articles/interval-pull-request-update-overview</id>
  <published>2015-03-07T00:00:00+00:00</published>
  <updated>2015-03-07T00:00:00+00:00</updated>
  <author>
    <name>Kenichi 'Sanemat' Murahashi</name>
    <uri>https://packsaddle.org</uri>
    <email>ogataken@gmail.com</email>
  </author>
  <content type="html">
    &lt;h2 id=&quot;tldr&quot;&gt;tl;dr&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;Cron for GitHubで定期的にCIサーバーのフックを起動する&lt;/li&gt;
  &lt;li&gt;CI側では、特定のブランチの場合のみ起動するスクリプトを用意する&lt;/li&gt;
  &lt;li&gt;自分のやりたい操作をして、git_httpsable-push, pull_request_create でPull Requestを送る&lt;/li&gt;
&lt;/ul&gt;

&lt;figure&gt;
  &lt;img src=&quot;/images/2015-03-07-interval-pull-request.png&quot; alt=&quot;Interval Dependency Update&quot; /&gt;
  &lt;figcaption&gt;定期的にDependency UpdateのPull Requestを送る&lt;/figcaption&gt;
&lt;/figure&gt;

&lt;h2 id=&quot;フックの起動&quot;&gt;フックの起動&lt;/h2&gt;

&lt;p&gt;Cron for GitHubのschedulerはこのように設定した。&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;bundle &lt;span class=&quot;nb&quot;&gt;exec &lt;/span&gt;cron-for-github clear &lt;span class=&quot;nt&quot;&gt;--slug&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;metarubygems/carrion_crow &lt;span class=&quot;nt&quot;&gt;--namespace&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;cron_for_tachikoma &lt;span class=&quot;nt&quot;&gt;--verbose&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; bundle &lt;span class=&quot;nb&quot;&gt;exec &lt;/span&gt;cron-for-github ping &lt;span class=&quot;nt&quot;&gt;--slug&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;metarubygems/carrion_crow &lt;span class=&quot;nt&quot;&gt;--namespace&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;cron_for_tachikoma &lt;span class=&quot;nt&quot;&gt;--verbose&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Cron for GitHubの使い方はリンク先を参照する。&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;http://packsaddle.org/articles/cron-for-github-app-overview/&quot;&gt;GitHubとHerokuの組み合わせでCron for GitHub – Saddler - checkstyle to anywhere&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;キモはnamespaceの指定で、&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;cron_for_tachikoma/XXXXX&lt;/code&gt;というブランチを定期的に作るようにする。
CI側ではこのブランチを監視する。&lt;/p&gt;

&lt;h2 id=&quot;ci側スクリプト-circleci&quot;&gt;CI側スクリプト (CircleCI)&lt;/h2&gt;

&lt;p&gt;CI側では、テスト後にスクリプトを実行。なお、例はCircleCIの場合。&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-yaml&quot; data-lang=&quot;yaml&quot;&gt;&lt;span class=&quot;na&quot;&gt;test&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;post&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;bin/run-tachikoma.sh&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;実行するスクリプト。
特定のブランチを監視して、あとは曜日で起動するしないの頻度を決めている。
この場合、日曜のみ起動。
環境変数 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;GITHUB_ACCESS_TOKEN&lt;/code&gt;に&lt;a href=&quot;https://github.com/settings/tokens/new&quot;&gt;token&lt;/a&gt; を入れている。&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;c&quot;&gt;#!/usr/bin/env bash&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;set&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-ev&lt;/span&gt;

&lt;span class=&quot;c&quot;&gt;# only sunday&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;[[&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;CIRCLE_BRANCH&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;!=&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;master&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;CIRCLE_BRANCH&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;~ ^cron_for_tachikoma/.&lt;span class=&quot;k&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class=&quot;si&quot;&gt;$(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;date&lt;/span&gt; +%w&lt;span class=&quot;si&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-eq&lt;/span&gt; 0 &lt;span class=&quot;o&quot;&gt;]]&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;then&lt;/span&gt;
  &lt;span class=&quot;c&quot;&gt;# gem prepare&lt;/span&gt;
  gem &lt;span class=&quot;nb&quot;&gt;install&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;--no-document&lt;/span&gt; git_httpsable-push pull_request-create

  &lt;span class=&quot;c&quot;&gt;# git prepare&lt;/span&gt;
  git config user.name sanemat
  git config user.email foo@example.com
  &lt;span class=&quot;nv&quot;&gt;HEAD_DATE&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;$(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;date&lt;/span&gt; +%Y%m%d_%H-%M-%S&lt;span class=&quot;si&quot;&gt;)&lt;/span&gt;
  &lt;span class=&quot;nv&quot;&gt;HEAD&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;tachikoma/update-&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;HEAD_DATE&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;

  &lt;span class=&quot;c&quot;&gt;# checkout&lt;/span&gt;
  git checkout &lt;span class=&quot;nt&quot;&gt;-b&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;HEAD&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; origin/master

  &lt;span class=&quot;c&quot;&gt;# bundle install&lt;/span&gt;
  bundle &lt;span class=&quot;nt&quot;&gt;--no-deployment&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;--without&lt;/span&gt; nothing &lt;span class=&quot;nt&quot;&gt;--jobs&lt;/span&gt; 4

  &lt;span class=&quot;c&quot;&gt;# bundle update&lt;/span&gt;
  bundle update

  git add Gemfile.lock
  git commit &lt;span class=&quot;nt&quot;&gt;-m&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;Bundle update &lt;/span&gt;&lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;HEAD_DATE&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;

  &lt;span class=&quot;c&quot;&gt;# git push via https&lt;/span&gt;
  git httpsable-push origin &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;HEAD&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;

  &lt;span class=&quot;c&quot;&gt;# pull request&lt;/span&gt;
  pull-request-create
&lt;span class=&quot;k&quot;&gt;fi

&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;exit &lt;/span&gt;0&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Git HTTPSable Pushや PullRequest Create はリンク先を参照する。&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;http://packsaddle.org/articles/git-httpsable-push-overview/&quot;&gt;Httpsで簡単に、ログ安全に、git pushする Git HTTPSable Push – Saddler - checkstyle to anywhere&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/packsaddle/ruby-pull_request-create&quot;&gt;packsaddle/ruby-pull_request-create&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;以上により、
&lt;a href=&quot;https://github.com/metarubygems/carrion_crow/pull/18&quot;&gt;定期的にライブラリの依存関係をアップデートしてPull Request&lt;/a&gt;
出来るようになった。&lt;/p&gt;

&lt;h3 id=&quot;travisciの場合&quot;&gt;TravisCIの場合&lt;/h3&gt;

&lt;p&gt;(Edited: 2015-03-17 15:15)&lt;/p&gt;

&lt;p&gt;pull request以外はmasterのbuildしか対象にしていない場合、&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.travis.yml&lt;/code&gt;で&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;cron_for_tachikoma&lt;/code&gt;も&lt;a href=&quot;https://github.com/sanemat/ruby-example-rails-banana/blob/master/.travis.yml#L19-L22&quot;&gt;監視&lt;/a&gt;する。&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-yaml&quot; data-lang=&quot;yaml&quot;&gt;&lt;span class=&quot;na&quot;&gt;branches&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;only&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
  &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;master&lt;/span&gt;
  &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;/^cron_for_tachikoma\/.*/&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;if pull request以外&lt;/code&gt;のところを変更する。
TravisCIの&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;git checkout&lt;/code&gt;の方式により&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;origin/master&lt;/code&gt;が居ないので、&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;git checkout -b &quot;${HEAD}&quot; &quot;${TRAVIS_BRANCH}&quot;&lt;/code&gt;にする。
もしくは&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;git checkout -b &quot;${HEAD}&quot;&lt;/code&gt;にする。&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;c&quot;&gt;#!/usr/bin/env bash&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;set&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-ev&lt;/span&gt;

&lt;span class=&quot;c&quot;&gt;# only sunday&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;[[&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-n&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;TRAVIS_PULL_REQUEST&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;TRAVIS_PULL_REQUEST&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;false&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;TRAVIS_BRANCH&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;~ ^cron_for_tachikoma/.&lt;span class=&quot;k&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class=&quot;si&quot;&gt;$(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;date&lt;/span&gt; +%w&lt;span class=&quot;si&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-eq&lt;/span&gt; 0 &lt;span class=&quot;o&quot;&gt;]]&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;then&lt;/span&gt;
  &lt;span class=&quot;c&quot;&gt;# gem prepare&lt;/span&gt;
  gem &lt;span class=&quot;nb&quot;&gt;install&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;--no-document&lt;/span&gt; git_httpsable-push pull_request-create

  &lt;span class=&quot;c&quot;&gt;# git prepare&lt;/span&gt;
  git config user.name sanemat
  git config user.email foo@example.com
  &lt;span class=&quot;nv&quot;&gt;HEAD_DATE&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;$(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;date&lt;/span&gt; +%Y%m%d_%H-%M-%S&lt;span class=&quot;si&quot;&gt;)&lt;/span&gt;
  &lt;span class=&quot;nv&quot;&gt;HEAD&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;tachikoma/update-&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;HEAD_DATE&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;

  &lt;span class=&quot;c&quot;&gt;# checkout (for TravisCI)&lt;/span&gt;
  git checkout &lt;span class=&quot;nt&quot;&gt;-b&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;HEAD&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;TRAVIS_BRANCH&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;

  &lt;span class=&quot;c&quot;&gt;# bundle install&lt;/span&gt;
  bundle &lt;span class=&quot;nt&quot;&gt;--no-deployment&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;--without&lt;/span&gt; nothing &lt;span class=&quot;nt&quot;&gt;--jobs&lt;/span&gt; 4

  &lt;span class=&quot;c&quot;&gt;# bundle update&lt;/span&gt;
  bundle update

  git add Gemfile.lock
  git commit &lt;span class=&quot;nt&quot;&gt;-m&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;Bundle update &lt;/span&gt;&lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;HEAD_DATE&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;

  &lt;span class=&quot;c&quot;&gt;# git push&lt;/span&gt;
  git httpsable-push origin &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;HEAD&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;

  &lt;span class=&quot;c&quot;&gt;# pull request&lt;/span&gt;
  pull-request-create
&lt;span class=&quot;k&quot;&gt;fi

&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;exit &lt;/span&gt;0&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;h2 id=&quot;備考&quot;&gt;備考&lt;/h2&gt;

&lt;p&gt;反対に、webhook ping用のブランチである &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;cron_for_tachikoma/XXXXX&lt;/code&gt; ではテストをスキップする、というのを入れておかないと、
テストのキューが多く詰まるような環境では悪い影響出る可能性があるので注意。&lt;/p&gt;

&lt;h2 id=&quot;他言語でも&quot;&gt;他言語でも&lt;/h2&gt;

&lt;p&gt;実行するスクリプトの中身はシェルスクリプトでコマンドが並んでいるだけなので、もちろん言語非依存。
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;composer update&lt;/code&gt;でも&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;pod update&lt;/code&gt;でもOK。
どんなコマンドオプションだとCIサーバー上で動かしやすいのかは、
&lt;a href=&quot;https://github.com/sanemat/tachikoma/blob/master/lib/tachikoma/application.rb&quot;&gt;Tachikoma gem&lt;/a&gt;
見るといけそう。&lt;/p&gt;

&lt;h2 id=&quot;まとめ&quot;&gt;まとめ&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;ライブラリを組み合わせて、CIサーバーから依存関係アップデートしたPull Requestを定期的に送る事ができるようになった&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;使ってみたをブログやqiitaに書いてもらえると助かる！フィードバックください！！
他にも使い道がありそう。&lt;/p&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;参照&quot;&gt;参照&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;http://packsaddle.org/articles/cron-for-github-app-overview/&quot;&gt;GitHubとHerokuの組み合わせでCron for GitHub – Saddler - checkstyle to anywhere&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://packsaddle.org/articles/git-httpsable-push-overview/&quot;&gt;Httpsで簡単に、ログ安全に、git pushする Git HTTPSable Push – Saddler - checkstyle to anywhere&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/sanemat/tachikoma/blob/master/lib/tachikoma/application.rb&quot;&gt;Tachikoma gem&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/metarubygems/carrion_crow&quot;&gt;CircleCIでの実例 - carrion_crow&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/sanemat/ruby-example-rails-banana&quot;&gt;TravisCIでの実例 - ruby-example-rails-banana&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

    &lt;p&gt;&lt;a href=&quot;https://packsaddle.org/articles/interval-pull-request-update-overview/&quot;&gt;定期的にライブラリの依存関係をアップデートしてPull Requestする&lt;/a&gt; was originally published by Kenichi 'Sanemat' Murahashi at &lt;a href=&quot;https://packsaddle.org&quot;&gt;Saddler - checkstyle to anywhere&lt;/a&gt; on March 07, 2015.&lt;/p&gt;
  </content>
</entry>


<entry>
  <title type="html"><![CDATA[Httpsで簡単に、ログ安全に、git pushする Git HTTPSable Push]]></title>
  <link rel="alternate" type="text/html" href="https://packsaddle.org/articles/git-httpsable-push-overview/" />
  <id>https://packsaddle.org/articles/git-httpsable-push-overview</id>
  <published>2015-03-06T00:00:00+00:00</published>
  <updated>2015-03-06T00:00:00+00:00</updated>
  <author>
    <name>Kenichi 'Sanemat' Murahashi</name>
    <uri>https://packsaddle.org</uri>
    <email>ogataken@gmail.com</email>
  </author>
  <content type="html">
    &lt;h2 id=&quot;tldr&quot;&gt;tl;dr&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;Git HTTPSable Pushを使うことで、Httpsで簡単に、ログ安全に、git pushする。&lt;/li&gt;
&lt;/ul&gt;

&lt;figure&gt;
  &lt;img src=&quot;/images/2015-03-06-git-httpsable-push-overview.png&quot; alt=&quot;Git HTTPSable Push&quot; /&gt;
  &lt;figcaption&gt;git-httpsable-pushの実行結果イメージ&lt;/figcaption&gt;
&lt;/figure&gt;

&lt;h2 id=&quot;使い道&quot;&gt;使い道&lt;/h2&gt;

&lt;ol&gt;
  &lt;li&gt;TravisCIや、CircleCIからGitHubにPushしたい&lt;/li&gt;
  &lt;li&gt;Git HTTPSable Push を使い&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;git httpsable-push&lt;/code&gt; で簡単に、ログ安全に、httpsでのgit pushが出来る&lt;/li&gt;
&lt;/ol&gt;

&lt;h2 id=&quot;ログ安全とは&quot;&gt;ログ安全とは?&lt;/h2&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;git push &lt;span class=&quot;nt&quot;&gt;--quiet&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;https://&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;GITHUB_ACCESS_TOKEN&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;@github.com/&amp;lt;repos_name&amp;gt;.git&quot;&lt;/span&gt; gh-pages 2&amp;gt; /dev/null&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;と書けば、TravisCIやCircleCIから安全にpushできる。
でも、&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;--quiet&lt;/code&gt;や&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;2&amp;gt; /dev/null&lt;/code&gt;のオプションを書き忘れるまたは書き損じると、tokenがログの中に漏れてしまう。
いちいち書くの大変。
さらに、TravisCIやCircleCIはどうしてもログ経由のデバッグになるので、ログが全く出せなくなると苦しい。&lt;/p&gt;

&lt;h2 id=&quot;使い方&quot;&gt;使い方&lt;/h2&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;gem &lt;span class=&quot;nb&quot;&gt;install &lt;/span&gt;git_httpsable-push
git httpsable-push origin YOUR_BRANCH&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;gitリポジトリの設定から、&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;https://${GITHUB_ACCESS_TOKEN}@github.com/&amp;lt;repos_name&amp;gt;.git&lt;/code&gt; をコマンド内部でいい感じに作る。
このため、リポジトリが&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;git://...&lt;/code&gt;でも&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;git@...&lt;/code&gt;でも、GITHUB_ACCESS_TOKEN以外の設定は不要。
たとえば、&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;git httpsable-push origin gh-pages&lt;/code&gt;と書けばOK。&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;git config &lt;span class=&quot;nt&quot;&gt;--get&lt;/span&gt; remote.origin.url
git@github.com:packsaddle/ruby-git_httpsable-push.git
&lt;span class=&quot;c&quot;&gt;# GITHUB_ACCESS_TOKEN=__MY_TOKEN__&lt;/span&gt;

&lt;span class=&quot;c&quot;&gt;# success&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;git httpsable-push origin refactor/logger-to-class &lt;span class=&quot;nt&quot;&gt;--verbose&lt;/span&gt;
I, &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;2015-03-06T19:29:54.250481 &lt;span class=&quot;c&quot;&gt;#33391]  INFO -- GitHttpsable::Push: Starting Git&lt;/span&gt;
I, &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;2015-03-06T19:29:54.270408 &lt;span class=&quot;c&quot;&gt;#33391]  INFO -- GitHttpsable::Push: git '--git-dir=/Users/sane/work/ruby-study/git_httpsable-push/.git' '--work-tree=/Users/sane/work/ruby-study/git_httpsable-push' config '--list'  2&amp;gt;&amp;amp;1&lt;/span&gt;
I, &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;2015-03-06T19:29:54.281424 &lt;span class=&quot;c&quot;&gt;#33391]  INFO -- GitHttpsable::Push: git '--git-dir=/Users/sane/work/ruby-study/git_httpsable-push/.git' '--work-tree=/Users/sane/work/ruby-study/git_httpsable-push' config '--list'  2&amp;gt;&amp;amp;1&lt;/span&gt;
I, &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;2015-03-06T19:29:56.632766 &lt;span class=&quot;c&quot;&gt;#33391]  INFO -- GitHttpsable::Push: git '--git-dir=/Users/sane/work/ruby-study/git_httpsable-push/.git' '--work-tree=/Users/sane/work/ruby-study/git_httpsable-push' push 'https://MASKED@github.com/packsaddle/ruby-git_httpsable-push.git' 'refactor/logger-to-class'  2&amp;gt;&amp;amp;1&lt;/span&gt;
I, &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;2015-03-06T19:29:56.632944 &lt;span class=&quot;c&quot;&gt;#33391]  INFO -- GitHttpsable::Push: {:output=&amp;gt;nil}&lt;/span&gt;

&lt;span class=&quot;c&quot;&gt;# error occurs&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;git httpsable-push origin refactor/logger-to-class &lt;span class=&quot;nt&quot;&gt;--verbose&lt;/span&gt;
I, &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;2015-03-06T19:33:47.692967 &lt;span class=&quot;c&quot;&gt;#34984]  INFO -- GitHttpsable::Push: Starting Git&lt;/span&gt;
I, &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;2015-03-06T19:33:47.701617 &lt;span class=&quot;c&quot;&gt;#34984]  INFO -- GitHttpsable::Push: git '--git-dir=/Users/sane/work/ruby-study/git_httpsable-push/.git' '--work-tree=/Users/sane/work/ruby-study/git_httpsable-push' config '--list'  2&amp;gt;&amp;amp;1&lt;/span&gt;
I, &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;2015-03-06T19:33:47.711167 &lt;span class=&quot;c&quot;&gt;#34984]  INFO -- GitHttpsable::Push: git '--git-dir=/Users/sane/work/ruby-study/git_httpsable-push/.git' '--work-tree=/Users/sane/work/ruby-study/git_httpsable-push' config '--list'  2&amp;gt;&amp;amp;1&lt;/span&gt;
I, &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;2015-03-06T19:33:50.657268 &lt;span class=&quot;c&quot;&gt;#34984]  INFO -- GitHttpsable::Push: git '--git-dir=/Users/sane/work/ruby-study/git_httpsable-push/.git' '--work-tree=/Users/sane/work/ruby-study/git_httpsable-push' push 'https://MASKED@github.com/packsaddle/ruby-git_httpsable-push.git' 'refactor/logger-to-class'  2&amp;gt;&amp;amp;1&lt;/span&gt;
E, &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;2015-03-06T19:33:50.657632 &lt;span class=&quot;c&quot;&gt;#34984] ERROR -- GitHttpsable::Push: Have a question? Please ask us:&lt;/span&gt;
E, &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;2015-03-06T19:33:50.657667 &lt;span class=&quot;c&quot;&gt;#34984] ERROR -- GitHttpsable::Push: https://github.com/packsaddle/ruby-git_httpsable-push/issues/new&lt;/span&gt;
E, &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;2015-03-06T19:33:50.657711 &lt;span class=&quot;c&quot;&gt;#34984] ERROR -- GitHttpsable::Push: options:&lt;/span&gt;
E, &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;2015-03-06T19:33:50.657778 &lt;span class=&quot;c&quot;&gt;#34984] ERROR -- GitHttpsable::Push: {&quot;debug&quot;=&amp;gt;false, &quot;verbose&quot;=&amp;gt;true, &quot;force&quot;=&amp;gt;false, &quot;tags&quot;=&amp;gt;false}&lt;/span&gt;
/Users/sane/work/ruby-study/git_httpsable-push/vendor/bundle/ruby/2.2.0/gems/git-1.2.9.1/lib/git/lib.rb:917:in &lt;span class=&quot;sb&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;command&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;': (Git::GitExecuteError) git '&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;--git-dir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;/Users/sane/work/ruby-study/git_httpsable-push/.git&lt;span class=&quot;s1&quot;&gt;' '&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;--work-tree&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;/Users/sane/work/ruby-study/git_httpsable-push&lt;span class=&quot;s1&quot;&gt;' push '&lt;/span&gt;https://MASKED@github.com/packsaddle/ruby-git_httpsable-push.git&lt;span class=&quot;s1&quot;&gt;' '&lt;/span&gt;refactor/logger-to-class&lt;span class=&quot;s1&quot;&gt;'  2&amp;gt;&amp;amp;1:remote: Invalid username or password. (GitHttpsable::Push::GitHttpsablePushError)
fatal: Authentication failed for '&lt;/span&gt;https://MASKED@github.com/packsaddle/ruby-git_httpsable-push.git/&lt;span class=&quot;s1&quot;&gt;'
        from /Users/sane/work/ruby-study/git_httpsable-push/vendor/bundle/ruby/2.2.0/gems/git-1.2.9.1/lib/git/lib.rb:727:in `push'&lt;/span&gt;
        from /Users/sane/work/ruby-study/git_httpsable-push/vendor/bundle/ruby/2.2.0/gems/git-1.2.9.1/lib/git/base.rb:329:in &lt;span class=&quot;sb&quot;&gt;`&lt;/span&gt;push&lt;span class=&quot;s1&quot;&gt;'
        from /Users/sane/work/ruby-study/git_httpsable-push/lib/git_httpsable/push/repository.rb:24:in `push'&lt;/span&gt;
        from /Users/sane/work/ruby-study/git_httpsable-push/lib/git_httpsable/push/cli.rb:29:in &lt;span class=&quot;sb&quot;&gt;`&lt;/span&gt;push&lt;span class=&quot;s1&quot;&gt;'
        from /Users/sane/work/ruby-study/git_httpsable-push/vendor/bundle/ruby/2.2.0/gems/thor-0.19.1/lib/thor/command.rb:27:in `run'&lt;/span&gt;
        from /Users/sane/work/ruby-study/git_httpsable-push/vendor/bundle/ruby/2.2.0/gems/thor-0.19.1/lib/thor/invocation.rb:126:in &lt;span class=&quot;sb&quot;&gt;`&lt;/span&gt;invoke_command&lt;span class=&quot;s1&quot;&gt;'
        from /Users/sane/work/ruby-study/git_httpsable-push/vendor/bundle/ruby/2.2.0/gems/thor-0.19.1/lib/thor.rb:359:in `dispatch'&lt;/span&gt;
        from /Users/sane/work/ruby-study/git_httpsable-push/vendor/bundle/ruby/2.2.0/gems/thor-0.19.1/lib/thor/base.rb:440:in &lt;span class=&quot;sb&quot;&gt;`&lt;/span&gt;start&lt;span class=&quot;s1&quot;&gt;'
        from /Users/sane/work/ruby-study/git_httpsable-push/lib/git_httpsable/push/cli.rb:59:in `method_missing'&lt;/span&gt;
        from /Users/sane/work/ruby-study/git_httpsable-push/vendor/bundle/ruby/2.2.0/gems/thor-0.19.1/lib/thor/command.rb:29:in &lt;span class=&quot;sb&quot;&gt;`&lt;/span&gt;run&lt;span class=&quot;s1&quot;&gt;'
        from /Users/sane/work/ruby-study/git_httpsable-push/vendor/bundle/ruby/2.2.0/gems/thor-0.19.1/lib/thor/command.rb:126:in `run'&lt;/span&gt;
        from /Users/sane/work/ruby-study/git_httpsable-push/vendor/bundle/ruby/2.2.0/gems/thor-0.19.1/lib/thor/invocation.rb:126:in &lt;span class=&quot;sb&quot;&gt;`&lt;/span&gt;invoke_command&lt;span class=&quot;s1&quot;&gt;'
        from /Users/sane/work/ruby-study/git_httpsable-push/vendor/bundle/ruby/2.2.0/gems/thor-0.19.1/lib/thor.rb:359:in `dispatch'&lt;/span&gt;
        from /Users/sane/work/ruby-study/git_httpsable-push/vendor/bundle/ruby/2.2.0/gems/thor-0.19.1/lib/thor/base.rb:440:in &lt;span class=&quot;sb&quot;&gt;`&lt;/span&gt;start&lt;span class=&quot;s1&quot;&gt;'
        from exe/git-httpsable-push:5:in `&amp;lt;main&amp;gt;'&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;ログとエラーの中の該当部分をマスクしている(MASKED部分)ので、ログに出ても安全。
エラーが出てもエラーを見ながら直せる。
安心して使える。&lt;/p&gt;

&lt;h2 id=&quot;まとめ&quot;&gt;まとめ&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;Httpsで簡単に、ログ安全に、git push出来る。HTTPSable Push。&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;使ってみたをブログやqiitaに書いてもらえると助かる！フィードバックください！！
masterにmergeしたらgh-pagesに自動でpush、が典型的に使える例。
そのほか、bundle updateしてgit pushしてpull requestなど、TravisCI, CircleCIで何か処理をしたい時に便利。&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://github.com/packsaddle/ruby-git_httpsable-push/issues/new&quot;&gt;詰まったら聞いて&lt;/a&gt;ください。このサイトやREADMEなどに反映します。
&lt;a href=&quot;https://github.com/packsaddle/ruby-git_httpsable-push&quot;&gt;ruby-git_httpsable-pushにスター&lt;/a&gt;ください!&lt;/p&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;参照&quot;&gt;参照&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/packsaddle/ruby-git_httpsable-push&quot;&gt;ruby-git_httpsable-pushにスター&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://tricknotes.hateblo.jp/entry/2013/06/17/020229&quot;&gt;Middleman で作った web サイトを Travis + GitHub pages でお手軽に運用する - tricknotesのぼうけんのしょ&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://docs.ruby-lang.org/ja/2.2.0/class/Logger.html&quot;&gt;class Logger&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://docs.ruby-lang.org/ja/2.2.0/class/Exception.html&quot;&gt;class Exception&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

    &lt;p&gt;&lt;a href=&quot;https://packsaddle.org/articles/git-httpsable-push-overview/&quot;&gt;Httpsで簡単に、ログ安全に、git pushする Git HTTPSable Push&lt;/a&gt; was originally published by Kenichi 'Sanemat' Murahashi at &lt;a href=&quot;https://packsaddle.org&quot;&gt;Saddler - checkstyle to anywhere&lt;/a&gt; on March 06, 2015.&lt;/p&gt;
  </content>
</entry>


<entry>
  <title type="html"><![CDATA[GitHubとHerokuの組み合わせでCron for GitHub]]></title>
  <link rel="alternate" type="text/html" href="https://packsaddle.org/articles/cron-for-github-app-overview/" />
  <id>https://packsaddle.org/articles/cron-for-github-app-overview</id>
  <published>2015-03-03T00:00:00+00:00</published>
  <updated>2015-03-03T00:00:00+00:00</updated>
  <author>
    <name>Kenichi 'Sanemat' Murahashi</name>
    <uri>https://packsaddle.org</uri>
    <email>ogataken@gmail.com</email>
  </author>
  <content type="html">
    &lt;h2 id=&quot;tldr&quot;&gt;tl;dr&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;GitHubとHeroku Schedulerの組み合わせでCron for GitHubを実現する&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://heroku.com/deploy?template=https://github.com/packsaddle/ruby-cron_for_github-app&quot;&gt;&lt;img src=&quot;https://www.herokucdn.com/deploy/button.png&quot; alt=&quot;Deploy&quot; /&gt;&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;figure&gt;
  &lt;img src=&quot;/images/2015-03-03-cron-for-github-app-branches.png&quot; alt=&quot;GitHub branches&quot; /&gt;
  &lt;figcaption&gt;cron-for-githubの実行結果イメージ&lt;/figcaption&gt;
&lt;/figure&gt;

&lt;h2 id=&quot;使い道&quot;&gt;使い道&lt;/h2&gt;

&lt;ol&gt;
  &lt;li&gt;たとえば、毎日&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ping/&lt;/code&gt; のbranchを生成しておく。&lt;/li&gt;
  &lt;li&gt;CI用のスクリプトには、&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ping/&lt;/code&gt; 以下のbranchのビルドだったらこれこれする、と条件を書く。&lt;/li&gt;
  &lt;li&gt;完成!&lt;/li&gt;
&lt;/ol&gt;

&lt;h2 id=&quot;はじめ方&quot;&gt;はじめ方&lt;/h2&gt;

&lt;ol&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/packsaddle/ruby-cron_for_github-app&quot;&gt;cron_for_github-app&lt;/a&gt;
の&lt;a href=&quot;https://heroku.com/deploy?template=https://github.com/packsaddle/ruby-cron_for_github-app&quot;&gt;&lt;img src=&quot;https://www.herokucdn.com/deploy/button.png&quot; alt=&quot;Deploy&quot; /&gt;&lt;/a&gt;
からherokuにデプロイ。&lt;/li&gt;
  &lt;li&gt;cronを使いたいリポジトリがprivateなら&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;repo&lt;/code&gt;, publicなら&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;public_repo&lt;/code&gt;の&lt;a href=&quot;https://github.com/settings/tokens/new&quot;&gt;github access tokenを発行&lt;/a&gt;。&lt;/li&gt;
  &lt;li&gt;GITHUB_ACCESS_TOKEN にそれを設定。&lt;/li&gt;
  &lt;li&gt;このコマンドを実行できるようになる。&lt;/li&gt;
&lt;/ol&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;cron-for-github ping &lt;span class=&quot;nt&quot;&gt;--slug&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;YOU/YOUR_REPO&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;ol&gt;
  &lt;li&gt;Heroku Schedulerで定期実行。&lt;/li&gt;
&lt;/ol&gt;

&lt;figure&gt;
  &lt;img src=&quot;/images/2015-03-03-cron-for-github-app-heroku-scheduler.png&quot; alt=&quot;heroku scheduler&quot; /&gt;
  &lt;figcaption&gt;heroku schedulerの設定イメージ&lt;/figcaption&gt;
&lt;/figure&gt;

&lt;p&gt;コマンドのオプション詳細は &lt;a href=&quot;https://github.com/packsaddle/ruby-cron_for_github#command&quot;&gt;cron_for_github gemのreadme&lt;/a&gt;参照。&lt;/p&gt;

&lt;h3 id=&quot;オススメ設定&quot;&gt;オススメ設定&lt;/h3&gt;

&lt;p&gt;このままだと、いっぱいブランチが作られていくママなので、&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;bundle &lt;span class=&quot;nb&quot;&gt;exec &lt;/span&gt;cron-for-github clear &lt;span class=&quot;nt&quot;&gt;--slug&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;YOU/YOUR_REPO &lt;span class=&quot;nt&quot;&gt;--verbose&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; bundle &lt;span class=&quot;nb&quot;&gt;exec &lt;/span&gt;cron-for-github ping &lt;span class=&quot;nt&quot;&gt;--slug&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;YOU/YOUR_REPO &lt;span class=&quot;nt&quot;&gt;--verbose&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;こんな感じに実行して、pingする前にclearするとよい。
verboseオプションつけるとそれなりにログが出る。
そして、それをnewrelicやlogentriesなど、ふつうのherokuアプリのように監視する。&lt;/p&gt;

&lt;h2 id=&quot;demo&quot;&gt;demo&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;CircleCI
    &lt;ul&gt;
      &lt;li&gt;&lt;a href=&quot;https://github.com/packsaddle/example-circle_ci-pull_request/branches/all&quot;&gt;Branches packsaddle/example-circle_ci-pull_request&lt;/a&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;CircleCIで確認してます。
10分おきに起動したらたくさんbranchできたので、今は1日1回起動中。
TravisCIでも動くはず。&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.travis.yml&lt;/code&gt;で&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-yaml&quot; data-lang=&quot;yaml&quot;&gt;&lt;span class=&quot;na&quot;&gt;branches&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;only&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;master&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;している場合は&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-yaml&quot; data-lang=&quot;yaml&quot;&gt;&lt;span class=&quot;na&quot;&gt;branches&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;only&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;master&lt;/span&gt;
    &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;/^cron_for_github\/.*$/&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;など、自分の設定に合わせて要修正。&lt;/p&gt;

&lt;h2 id=&quot;まとめ&quot;&gt;まとめ&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;GitHubとHeroku Schedulerの組み合わせでCron for GitHubを実現する&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://heroku.com/deploy?template=https://github.com/packsaddle/ruby-cron_for_github-app&quot;&gt;&lt;img src=&quot;https://www.herokucdn.com/deploy/button.png&quot; alt=&quot;Deploy&quot; /&gt;&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;使ってみたをブログやqiitaに書いてもらえると助かる！フィードバックください！！
多分他にも使いみちがありそう。
&lt;a href=&quot;https://github.com/packsaddle/ruby-cron_for_github-app/issues/new&quot;&gt;詰まったら聞いて&lt;/a&gt;ください。このサイトやREADMEなどに反映します。
&lt;a href=&quot;https://github.com/packsaddle/ruby-cron_for_github-app&quot;&gt;ruby-cron_for_github-app&lt;/a&gt;と
&lt;a href=&quot;https://github.com/packsaddle/ruby-cron_for_github&quot;&gt;ruby-cron_for_githubにスター&lt;/a&gt;ください!&lt;/p&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;参照&quot;&gt;参照&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/packsaddle/ruby-cron_for_github-app&quot;&gt;ruby-cron_for_github-appにスター&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/packsaddle/ruby-cron_for_github&quot;&gt;ruby-cron_for_githubにスター&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://developer.github.com/v3/git/refs/&quot;&gt;Git Refs GitHub API&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://devcenter.heroku.com/articles/heroku-button&quot;&gt;Creating a ‘Deploy to Heroku’ Button Heroku Dev Center&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://devcenter.heroku.com/articles/app-json-schema&quot;&gt;app.json Schema Heroku Dev Center&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

    &lt;p&gt;&lt;a href=&quot;https://packsaddle.org/articles/cron-for-github-app-overview/&quot;&gt;GitHubとHerokuの組み合わせでCron for GitHub&lt;/a&gt; was originally published by Kenichi 'Sanemat' Murahashi at &lt;a href=&quot;https://packsaddle.org&quot;&gt;Saddler - checkstyle to anywhere&lt;/a&gt; on March 03, 2015.&lt;/p&gt;
  </content>
</entry>


<entry>
  <title type="html"><![CDATA[CI環境からGitHubのPull Requestのstatusを簡単に通知するコマンド]]></title>
  <link rel="alternate" type="text/html" href="https://packsaddle.org/articles/github-status-notifier-overview/" />
  <id>https://packsaddle.org/articles/github-status-notifier-overview</id>
  <published>2015-02-28T00:00:00+00:00</published>
  <updated>2015-02-28T00:00:00+00:00</updated>
  <author>
    <name>Kenichi 'Sanemat' Murahashi</name>
    <uri>https://packsaddle.org</uri>
    <email>ogataken@gmail.com</email>
  </author>
  <content type="html">
    &lt;h2 id=&quot;tldr&quot;&gt;tl;dr&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/packsaddle/ruby-github_status_notifier&quot;&gt;github_status_notifier&lt;/a&gt;コマンドでCI環境からGitHubのPull Requestのstatusを
簡単に通知する。&lt;/li&gt;
  &lt;li&gt;TravisCIがやってるみたいなテスト中は黄色、テスト終わったら緑/赤のを簡単に作れる。&lt;/li&gt;
&lt;/ul&gt;

&lt;figure class=&quot;half&quot;&gt;
  &lt;img src=&quot;/images/2015-02-28-github-status-notifier-pending.png&quot; alt=&quot;github status pending&quot; /&gt;
  &lt;img src=&quot;/images/2015-02-28-github-status-notifier.png&quot; alt=&quot;github status success&quot; /&gt;
  &lt;figcaption&gt;github-status-notifierの実行結果イメージ&lt;/figcaption&gt;
&lt;/figure&gt;

&lt;h2 id=&quot;使い方&quot;&gt;使い方&lt;/h2&gt;

&lt;p&gt;単体で使ってもよし、典型的には、他のコマンドの前後を &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;state pending&lt;/code&gt;と &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;exit-status $?&lt;/code&gt;で囲んで使う。
こうするとこのスクリプトが始まったところでpending の黄色が始まり、成功/失敗で success/failureのstatusが表示できる。&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;gem &lt;span class=&quot;nb&quot;&gt;install &lt;/span&gt;github_status_notifier

github-status-notifier notify &lt;span class=&quot;nt&quot;&gt;--state&lt;/span&gt; pending &lt;span class=&quot;nt&quot;&gt;--context&lt;/span&gt; saddler/rubocop

SOME_YOUR_COMMAND

github-status-notifier notify &lt;span class=&quot;nt&quot;&gt;--exit-status&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$?&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;--context&lt;/span&gt; saddler/rubocop&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;h2 id=&quot;使い道&quot;&gt;使い道&lt;/h2&gt;

&lt;p&gt;GitHub関連サービス作るような人には便利に使えそう。Saddlerとの連携などに便利。&lt;/p&gt;

&lt;p&gt;チェックがまだ始まってないのか、チェック中なのか、チェックが終わって何も問題がないから無言なのか、途中で終わってるのか、
Pull Requestの画面上から把握できるようになる。&lt;/p&gt;

&lt;p&gt;これから用にJenkinsなりで自前CIを作ってて、status通知連携だけで来てない人(いるのか?)は多少便利になるかも。
でもその場合はこっち見てその通りに作るほうがよい。 &lt;a href=&quot;https://developer.github.com/guides/building-a-ci-server/&quot;&gt;Building a CI server | GitHub API&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://github.com/packsaddle/ruby-github_status_notifier&quot;&gt;ruby-github_status_notifierにスター&lt;/a&gt;ください!&lt;/p&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;参照&quot;&gt;参照&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/packsaddle/ruby-github_status_notifier&quot;&gt;ruby-github_status_notifierにスター&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/blog/1935-see-results-from-all-pull-request-status-checks&quot;&gt;See results from all pull request status checks&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://developer.github.com/v3/repos/statuses/&quot;&gt;Statuses GitHub API&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://developer.github.com/guides/building-a-ci-server/&quot;&gt;Building a CI server GitHub API&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/blog/1227-commit-status-api&quot;&gt;Commit Status API&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

    &lt;p&gt;&lt;a href=&quot;https://packsaddle.org/articles/github-status-notifier-overview/&quot;&gt;CI環境からGitHubのPull Requestのstatusを簡単に通知するコマンド&lt;/a&gt; was originally published by Kenichi 'Sanemat' Murahashi at &lt;a href=&quot;https://packsaddle.org&quot;&gt;Saddler - checkstyle to anywhere&lt;/a&gt; on February 28, 2015.&lt;/p&gt;
  </content>
</entry>


<entry>
  <title type="html"><![CDATA[変更したファイルにrubocopやjscsを実行して pull requestに自動でコメントする]]></title>
  <link rel="alternate" type="text/html" href="https://packsaddle.org/articles/saddler-overview/" />
  <id>https://packsaddle.org/articles/saddler-overview</id>
  <published>2015-02-27T00:00:00+00:00</published>
  <updated>2015-02-27T00:00:00+00:00</updated>
  <author>
    <name>Kenichi 'Sanemat' Murahashi</name>
    <uri>https://packsaddle.org</uri>
    <email>ogataken@gmail.com</email>
  </author>
  <content type="html">
    &lt;h2 id=&quot;tldr&quot;&gt;tl;dr&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;変更したファイルにrubocopやjscsを実行して、pull requestに自動でコメントさせる方法。&lt;/li&gt;
  &lt;li&gt;コマンドをパイプでつないで、CIからsaddlerコマンドで書き込みする。&lt;/li&gt;
  &lt;li&gt;デモリポジトリに
&lt;a href=&quot;https://github.com/packsaddle/example-travis_ci-pull_request_review&quot;&gt;rubocop, travis ci&lt;/a&gt;,
&lt;a href=&quot;https://github.com/packsaddle/example-travis_ci-pull_request_review-jscs&quot;&gt;jscs, travis ci&lt;/a&gt;
エラーになるpull requestしてみてね!&lt;/li&gt;
&lt;/ul&gt;

&lt;figure class=&quot;half&quot;&gt;
  &lt;img src=&quot;/images/2015-02-27-jscs-comment.png&quot; alt=&quot;jscs comment&quot; /&gt;
  &lt;img src=&quot;/images/2015-02-27-rubocop-comment.png&quot; alt=&quot;rubocop comment&quot; /&gt;
  &lt;figcaption&gt;saddlerの実行結果イメージ&lt;/figcaption&gt;
&lt;/figure&gt;

&lt;p&gt;一番目がjscs, 二番目がrubocop。&lt;/p&gt;

&lt;h2 id=&quot;流れ&quot;&gt;流れ&lt;/h2&gt;

&lt;h3 id=&quot;diffのあるファイル名を取り出す&quot;&gt;diffのあるファイル名を取り出す&lt;/h3&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;git diff &lt;span class=&quot;nt&quot;&gt;--name-only&lt;/span&gt; origin/master
README.md
bin/run-tests.sh
lib/example/travis_ci.rb&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;こんなdiffにrubocop や jscsを実行したい。
diffのあるファイル名を取り出す。&lt;/p&gt;

&lt;h3 id=&quot;lint実行したいファイルだけに絞り込む&quot;&gt;lint実行したいファイルだけに絞り込む&lt;/h3&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;git diff &lt;span class=&quot;nt&quot;&gt;--name-only&lt;/span&gt; origin/master &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
 | xargs rubocop-select
/Users/sane/work/tmp/packsaddle/example-ruby-travis-ci/lib/example/travis_ci.rb&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;lint実行したいファイルだけに絞り込む。
rubocopはrubocop-select という対象絞り込みのコマンドを使う。&lt;/p&gt;

&lt;p&gt;ちなみに、jscsの場合はgrepにした。ここ以外は一緒なので割愛。&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;git diff &lt;span class=&quot;nt&quot;&gt;--name-only&lt;/span&gt; origin/master &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
 | &lt;span class=&quot;nb&quot;&gt;grep&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-e&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'.js$'&lt;/span&gt;
/Users/sane/work/tmp/packsaddle/example-ruby-travis-ci/lib/example/some_your.js&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;h3 id=&quot;lint実行して結果をcheckstyle-formatで出力する&quot;&gt;lint実行して結果をcheckstyle formatで出力する&lt;/h3&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;git diff &lt;span class=&quot;nt&quot;&gt;-z&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;--name-only&lt;/span&gt; origin/master &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
  | xargs &lt;span class=&quot;nt&quot;&gt;-0&lt;/span&gt; rubocop-select &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
  | xargs rubocop &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
      &lt;span class=&quot;nt&quot;&gt;--require&lt;/span&gt; rubocop/formatter/checkstyle_formatter &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
      &lt;span class=&quot;nt&quot;&gt;--format&lt;/span&gt; RuboCop::Formatter::CheckstyleFormatter
&amp;lt;?xml &lt;span class=&quot;nv&quot;&gt;version&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'1.0'&lt;/span&gt;?&amp;gt;
&amp;lt;checkstyle&amp;gt;
  &amp;lt;file &lt;span class=&quot;nv&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'/Users/sane/work/tmp/packsaddle/example-ruby-travis-ci/lib/example/travis_ci.rb'&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;
    &amp;lt;error &lt;span class=&quot;nv&quot;&gt;line&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'7'&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;column&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'120'&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;severity&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'info'&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;message&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'Line is too long. [163/120]'&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;source&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'com.puppycrawl.tools.checkstyle.Metrics/LineLength'&lt;/span&gt;/&amp;gt;
  &amp;lt;/file&amp;gt;
  &amp;lt;file &lt;span class=&quot;nv&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'/Users/sane/work/tmp/packsaddle/example-ruby-travis-ci/lib/example/travis_ci.rb'&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;
    &amp;lt;error &lt;span class=&quot;nv&quot;&gt;line&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'16'&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;column&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'120'&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;severity&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'info'&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;message&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'Line is too long. [163/120]'&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;source&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'com.puppycrawl.tools.checkstyle.Metrics/LineLength'&lt;/span&gt;/&amp;gt;
  &amp;lt;/file&amp;gt;
&amp;lt;/checkstyle&amp;gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;実行して、結果をcheckstyle formatで出力。
rubocopの場合はcheckstyle formatterをgemで入れる。
jscsの場合はcheckstyle reporterがある。exampleで用意したものはgulp-jscsなので、中から無理やり。
npm runでxargs渡せるんだろうか。&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;git diff &lt;span class=&quot;nt&quot;&gt;--name-only&lt;/span&gt; origin/master &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
  | &lt;span class=&quot;nb&quot;&gt;grep&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-e&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'\.js$'&lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
  | xargs ./node_modules/gulp-jscs/node_modules/.bin/jscs &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
      &lt;span class=&quot;nt&quot;&gt;--reporter&lt;/span&gt; checkstyle&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;このステップは、checkstyle formatでどうしても出力できなかったら、そのライブラリのreporterを書くか、結果のconverterを書く。&lt;/p&gt;

&lt;h3 id=&quot;checkstyle-formatの中から増えた行のエラーだけ抽出する&quot;&gt;checkstyle formatの中から、増えた行のエラーだけ抽出する&lt;/h3&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;git diff &lt;span class=&quot;nt&quot;&gt;-z&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;--name-only&lt;/span&gt; origin/master &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
  | xargs &lt;span class=&quot;nt&quot;&gt;-0&lt;/span&gt; rubocop-select &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
  | xargs rubocop &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
      &lt;span class=&quot;nt&quot;&gt;--require&lt;/span&gt; rubocop/formatter/checkstyle_formatter &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
      &lt;span class=&quot;nt&quot;&gt;--format&lt;/span&gt; RuboCop::Formatter::CheckstyleFormatter &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
  | checkstyle_filter-git diff origin/master
&amp;lt;?xml &lt;span class=&quot;nv&quot;&gt;version&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'1.0'&lt;/span&gt;?&amp;gt;
&amp;lt;checkstyle&amp;gt;
  &amp;lt;file &lt;span class=&quot;nv&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'/Users/sane/work/tmp/packsaddle/example-ruby-travis-ci/lib/example/travis_ci.rb'&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;
    &amp;lt;error &lt;span class=&quot;nv&quot;&gt;column&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'120'&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;line&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'7'&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;message&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'Line is too long. [163/120]'&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;severity&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'info'&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;source&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'com.puppycrawl.tools.checkstyle.Metrics/LineLength'&lt;/span&gt;/&amp;gt;

  &amp;lt;/file&amp;gt;
&amp;lt;/checkstyle&amp;gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;checkstyle formatのなかから、増えた行のエラーだけ抽出する。
この場合7行目はdiffにあったけど、16行目はdiffに無かったのですね。&lt;/p&gt;

&lt;h3 id=&quot;増えた行のエラーをpull-requestにコメントする&quot;&gt;増えた行のエラーをPull requestにコメントする&lt;/h3&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;git diff &lt;span class=&quot;nt&quot;&gt;-z&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;--name-only&lt;/span&gt; origin/master &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
  | xargs &lt;span class=&quot;nt&quot;&gt;-0&lt;/span&gt; rubocop-select &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
  | xargs rubocop &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
      &lt;span class=&quot;nt&quot;&gt;--require&lt;/span&gt; rubocop/formatter/checkstyle_formatter &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
      &lt;span class=&quot;nt&quot;&gt;--format&lt;/span&gt; RuboCop::Formatter::CheckstyleFormatter &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
  | checkstyle_filter-git diff origin/master &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
  | saddler report &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
     &lt;span class=&quot;nt&quot;&gt;--require&lt;/span&gt; saddler/reporter/github &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
     &lt;span class=&quot;nt&quot;&gt;--reporter&lt;/span&gt; Saddler::Reporter::Github::PullRequestReviewComment&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;増えた行のエラーをPull requestにコメントする。
おめでとうございます!&lt;/p&gt;

&lt;h2 id=&quot;demo&quot;&gt;demo&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;TravisCI
    &lt;ul&gt;
      &lt;li&gt;&lt;a href=&quot;https://github.com/packsaddle/example-travis_ci-pull_request_review&quot;&gt;rubocop&lt;/a&gt;,
  &lt;a href=&quot;https://github.com/packsaddle/example-travis_ci-pull_request_review/blob/master/bin/run-rubocop.sh&quot;&gt;実際に実行するスクリプト&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;https://github.com/packsaddle/example-travis_ci-pull_request_review-jscs&quot;&gt;jscs&lt;/a&gt;,
  &lt;a href=&quot;https://github.com/packsaddle/example-travis_ci-pull_request_review-jscs/blob/master/bin/run-jscs.sh&quot;&gt;実際に実行するスクリプト&lt;/a&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;CircleCI
    &lt;ul&gt;
      &lt;li&gt;&lt;a href=&quot;https://github.com/packsaddle/example-circle_ci-pull_request_review&quot;&gt;rubocop&lt;/a&gt;,
  &lt;a href=&quot;https://github.com/packsaddle/example-circle_ci-pull_request_review/blob/master/bin/run-rubocop.sh&quot;&gt;実際に実行するスクリプト&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;https://github.com/packsaddle/example-circle_ci-pull_request_review-jscs&quot;&gt;jscs&lt;/a&gt;,
  &lt;a href=&quot;https://github.com/packsaddle/example-circle_ci-pull_request_review-jscs/blob/master/bin/run-jscs.sh&quot;&gt;実際に実行するスクリプト&lt;/a&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;TravisCIとCircleCIで確認してます。
CircleCIのほうは、外部リポジトリからのPull Requestでbuildしないようにしているので、
TravisCIのリポジトリで、rubocop/jscsが指摘する項目があるプルリクエストを出して試してみてください!
自分のリポジトリに設定する場合、GitHub Tokenの設定が必要です。
各デモのREADMEとスクリプトを参考に設定してください。&lt;/p&gt;

&lt;h2 id=&quot;まとめ&quot;&gt;まとめ&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;変更したファイルにrubocopやjscsを実行して、pull requestに自動でコメントさせる方法。&lt;/li&gt;
  &lt;li&gt;コマンドをパイプでつないで、CIからsaddlerコマンドで書き込みする。&lt;/li&gt;
  &lt;li&gt;デモリポジトリに
&lt;a href=&quot;https://github.com/packsaddle/example-travis_ci-pull_request_review&quot;&gt;rubocop, travis ci&lt;/a&gt;,
&lt;a href=&quot;https://github.com/packsaddle/example-travis_ci-pull_request_review-jscs&quot;&gt;jscs, travis ci&lt;/a&gt;
エラーになるpull requestしてみてね!&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;使ってみたをブログやqiitaに書いてもらえると助かる！フィードバックください！！
詰まったら聞いてください。このサイトやREADMEなどに反映します。
gitlabで使いたい！stashで、bitbucketで、etcなどもこれから作りやすいようにしてます。reporterの作り方書きます。
コマンドラインツールなんでも行けるはずなので他にもeslintなど行ける！！
&lt;a href=&quot;https://github.com/packsaddle/ruby-saddler&quot;&gt;ruby-saddlerにスター&lt;/a&gt;ください!&lt;/p&gt;

    &lt;p&gt;&lt;a href=&quot;https://packsaddle.org/articles/saddler-overview/&quot;&gt;変更したファイルにrubocopやjscsを実行して pull requestに自動でコメントする&lt;/a&gt; was originally published by Kenichi 'Sanemat' Murahashi at &lt;a href=&quot;https://packsaddle.org&quot;&gt;Saddler - checkstyle to anywhere&lt;/a&gt; on February 27, 2015.&lt;/p&gt;
  </content>
</entry>

</feed>