Skip to content

サブモジュール "the-rust-programming-language-ja" の自動更新 #6

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 18 commits into
base: master
Choose a base branch
from

Conversation

tatsuya6502
Copy link
Member

@tatsuya6502 tatsuya6502 commented Jul 16, 2017

Travis による CI 実行時に、サブモジュール "the-rust-programming-language-ja" を最新版に自動更新するように変更します。以前検討した この案 をベースにしています。

現在の CI からの変更点

  1. PDF を生成する前に、サブモジュール "the-rust-programming-language-ja" のディレクトリで git pull origin master し、最新のリビジョンを取得する 。(.travis.yml ファイルの変更)
  2. PDF の生成に成功したら、サブモジュールのリビジョンをコミットし GitHub 上の同じブランチへ push する。(ci-scripts/commit-trpl-submodule-revision.sh で実現) なお、その際、コミットメッセージに [ci skip] の文字列を含めることで、これをトリガーにした新たな CI が起動することを防ぐ。
  3. 現在のブランチが master ブランチの時だけ、生成した PDF を gh-pages ブランチへ push する。(ci-scripts/publish-pdf.sh で実現)

CI 実行例

テストのために、本リポジトリのフォークで CI を実行しました。

@y-yu さん、レビューをお願いします。

tatsuya6502 and others added 16 commits April 19, 2017 23:01
- Fix a bug in commit-trpl-submodule-revision.sh, which tries to push
  local commit to a wrong remote branch.
- Better error handlings in all scripts in ci-scripts directory.
- Fix a bug in commit-trpl-submodule-revision.sh about here document.
- Save and restore only the state of nounset option.
- Run `git checkout` before committing a branch.
- More informative messages for pushing to remote git repositories.
Update the-rust-programming-language-ja submodule to fb31d86.
Update the-rust-programming-language-ja submodule to fb31d86.
Also remove an extra new-line at the bottom of .travis
@tatsuya6502 tatsuya6502 requested a review from y-yu July 16, 2017 08:18
`$EVENT_TYPE` should read `$TRAVIS_EVENT_TYPE`.
@y-yu
Copy link
Member

y-yu commented Jul 18, 2017

@tatsuya6502 さん。

ありがとうございます。
1つ質問なんですが、このPRはthe-rust-programming-language-jaリポジトリが更新されたときにPDF版が自動で生成される、ということを達成しようとしているということでよいでしょうか。それとも、Travis CIを1日1回などペースで定期的に実行するという感じでしょうか。

@tatsuya6502
Copy link
Member Author

@y-yu さん

このPRはthe-rust-programming-language-jaリポジトリが更新されたときにPDF版が自動で生成される、ということを達成しようとしているということでよいでしょうか。それとも、...

はい、そうです。この PR では前者を達成しようとしています。

もちろん、この PR をマージしただけでは不十分で、the-rust-programming-language-ja(trpl-ja)に更新があったことを検知できません。そこで、この後、trpl-ja の Circle CI ジョブに修正を加え、trpl-ja の master ブランチが更新されたときに、こちら(trpl-ja-pdf)の Jenkins CI ジョブを自動起動するようにします。具体的には Travis CI ドキュメントの このページ で解説されている curl コマンドを使った方法を用います。

trpl-ja の Circle CI ジョブの修正は、数日中に行う予定です。(PR を上げた時点でお知らせします) その PR がマージされたら、trpl-ja が更新されるごとに trpl-ja-pdf の Jenkins CI ジョブが起動され、PDF が自動生成されるようになります。

@y-yu
Copy link
Member

y-yu commented Jul 18, 2017

@tatsuya6502 さん。

なるほど! 承知しました。
そういう前提で変更点を詳しく見てみることにします。

@tatsuya6502
Copy link
Member Author

trpl-ja の Circle CI ジョブの修正は、数日中に行う予定です。

こちらですが、 trpl-ja の方へ PR を上げました。
rust-lang-ja/the-rust-programming-language-ja#278

Copy link
Member

@y-yu y-yu left a comment

Choose a reason for hiding this comment

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

2点、指摘させていただきましたので、ご確認をおねがいします。


exit_if_not_ci

if [ -z "${TRAVIS+x}" -o "x_${TRAVIS}" != "x_true" ]; then
Copy link
Member

Choose a reason for hiding this comment

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

ここでやっていることは、直前にあるexit_if_not_ciとどう違うのでしょうか?

Copy link
Member Author

Choose a reason for hiding this comment

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

あ、同じ内容ですね。どうやら編集ミスのようです。最初にこの if 文があったのですが、その後 common-lib に exit_if_not_ci を作った時に、if 文を削除し忘れたようです。

重複部分を削除しますね。見つけていただいて良かったです。

.travis.yml Outdated
@@ -24,6 +24,7 @@ install:
- ./tlmgr.sh update --self --all || echo "ignore errors"
- ./tlmgr.sh install collection-luatex collection-langjapanese collection-fontsrecommended type1cm mdframed needspace hyphenat quotchap framed everyhook svn-prov
before_script:
- (cd the-rust-programming-language-ja && git fetch origin && git checkout master && git pull origin master)
Copy link
Member

Choose a reason for hiding this comment

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

ささいですが、git pullするならばgit fetchは必要ないかもしれないです。

Copy link
Member Author

Choose a reason for hiding this comment

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

たしかにそうですね。git fetch は削除します。

- Remove duplicate codes from publish-pdf.sh.
- Remove unnecessary `git fetch`.
@tatsuya6502
Copy link
Member Author

レビュー、ありがとうございました。ご指摘の2点は修正しました。

が、問題が1つあることに気づきました。修正できるか今夜(?)調べますので、まだマージしないでください。

今回、フォークしたリポジトリ(tatsuya6502)のブランチ(auto-update-submodules)で作業しているのですが、PR を上げたままコミットすると、Travis CI のジョブが2つ走るようです。

前者は期待通り動いているのですが、後者はそうではありません。commit-trpl-submodule-revision.sh がサブモジュールの変更を trpl-ja-pdf の master ブランチに commit して、push しようとします。(deploy.key の decrypt ができなかったのか、push には失敗しています) こういう場合には、PR 先のリポジトリでは commit-trpl-submodule-revision.sh は何もしない方がいいと思います。修正できるか調べてみます。

@y-yu
Copy link
Member

y-yu commented Jul 21, 2017

承知しました。

@tatsuya6502
Copy link
Member Author

tatsuya6502 commented Sep 3, 2017

メモ:テストリポジトリで実施したテスト結果(7/22/2017)

No. リポジトリ ブランチ アクション Travis Job TRAVIS_ EVENT_TYPE TRAVIS_ BRANCH TRAVIS_ PULL_REQUEST TRAVIS_ PULL_REQUEST_ BRANCH TRAVIS_ SECURE_ ENV_VARS MY_SECRET_ VALUE
1 root master push root #3 (master) push master false true [secure]
2 root local-branch1 push root #4 (local-branch1) push local-branch1 false true [secure]
3 root local-branch1 open PR #1 to master root #5 (master) pull_request master 1 local-branch1 true [secure]
4 root local-branch1 push root #6 (local-branch1) push local-branch1 false true [secure]
root #7 (master) pull_request master 1 local-branch1 true [secure]
5 root master merge PR #1 root #8 (master) push master false true [secure]
6 fork fork-branch1 push fork #2 (fork-branch1) push fork-branch1 false false
7 fork fork-branch1 open PR #2 to master root #9 (master) pull_request master 2 fork-branch1 false
8 fork fork-branch1 push fork #3 (fork-branch1) push fork-branch1 false false
root #10 (master) pull_request master 2 fork-branch1 false
9 root master merge PR #2 root #11 (master) push master false true [secure]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants