Zenn
Open35

Contributing to Rust - Rust にコントリビュートする

山とコード山とコード

【初めて用】アサインの依頼と頑張ります宣言

Hi. I'm also interested in this issue as the first time for contribution to rust!

@rustbot claim
山とコード山とコード

コントリビューターのお話

RustコントリビューターTaKO8Kiさんに、コンパイラの内部処理やOSSについて聞いてみた! - TechFeed
https://techfeed.io/entries/649b84871047436417c17e83

山とコード山とコード

Getting Started - Rust Compiler Development Guide

質問は以下でする。

コンパイラのさまざまな部分について誰が専門知識を調べる。

最近のコミットを見てみることができる。

例:1.68.2リリース以降に名前解決に関して最近作業した人を見つける

git shortlog -n 1.68.2.. compiler/rustc_resolve/
山とコード山とコード

まず、ビルド。

./x build

ツールチェインとリンクさせる。

rustup toolchain link stage1 build/host/stage1

testfile.rs を作って、コンパイルする。

testfile.rs
fn main() {
    // 世界よ、こんにちは
    println!("Hello, world!");
}
rustc +stage1 testfile.rs
./testfile
山とコード山とコード
山とコード山とコード

対応しないで OK?

syn クレートのメソッド

compiler/rustc_macros/src/hash_stable.rs
18:        let _ = attr.parse_nested_meta(|nested| {
24:                let _ = nested.parse_nested_meta(|meta| {

compiler/rustc_macros/src/diagnostics/subdiagnostic.rs
446:                list.parse_nested_meta(|nested| {

compiler/rustc_macros/src/diagnostics/utils.rs
716:        list.parse_nested_meta(|nested| {

compiler/rustc_macros/src/diagnostics/diagnostic_builder.rs
191:            attr.parse_nested_meta(|nested| {

compiler/rustc_macros/src/type_visitable.rs
21:            let _ = attr.parse_nested_meta(|nested| {

compiler/rustc_macros/src/type_foldable.rs
29:                let _ = x.parse_nested_meta(|nested| {

山とコード山とコード

コンフリクトしたら...

Using Git - Rust Compiler Development Guide
https://rustc-dev-guide.rust-lang.org/git.html#rebasing-and-conflicts

山とコード山とコード

リベースして

git pull --rebase https://github.com/rust-lang/rust.git master

コンフリクトを解消したら、チェックしてテストして、

./x check
./x test

OK なら add して

git add .

リベースを完了させる。

git rebase --continue

最後に、フォーク側にも完了を反映させる。

git push --force-with-lease
山とコード山とコード

rusbot のコメント

$ # rebase
$ git pull --rebase https://github.com/rust-lang/rust.git master
$ git push --force-with-lease
山とコード山とコード

コミットを一つにまとめる方法

まずはログを確認(長い場合は q で抜けられる)

git log --online

HEAD~ でのどこまでのコミットを修正するかを指定する

git rebase -i HEAD~3

vi でまとめるコミットを pick から s に変更する

  • i -- インサートモード
  • esc -- インサートモード終了
  • :wq -- 保存して終了
  • :q! -- 保存せずに終了
Before
pick aaaaaaa Update README
pick bbbbbbb Update README.md
pick ccccccc feat: Update README

# Rebase a7c1cff..02f8854 onto a7c1cff (3 commands)
#
# Commands:
# p, pick <commit> = use commit
# r, reword <commit> = use commit, but edit the commit message
# e, edit <commit> = use commit, but stop for amending
# s, squash <commit> = use commit, but meld into previous commit
# f, fixup [-C | -c] <commit> = like "squash" but keep only the previous
#                    commit's log message, unless -C is used, in which case
#                    keep only this commit's message; -c is same as -C but
#                    opens the editor
# x, exec <command> = run command (the rest of the line) using shell
# b, break = stop here (continue rebase later with 'git rebase --continue')
# d, drop <commit> = remove commit
# l, label <label> = label current HEAD with a name
# t, reset <label> = reset HEAD to a label
# m, merge [-C <commit> | -c <commit>] <label> [# <oneline>]
#         create a merge commit using the original merge commit's
#         message (or the oneline, if no original merge commit was
#         specified); use -c <commit> to reword the commit message
# u, update-ref <ref> = track a placeholder for the <ref> to be updated
#                       to this position in the new commits. The <ref> is
#                       updated at the end of the rebase
#
# These lines can be re-ordered; they are executed from top to bottom.
#
# If you remove a line here THAT COMMIT WILL BE LOST.
#
# However, if you remove everything, the rebase will be aborted.
#
After
pick aaaaaaa Update README
s bbbbbbb Update README.md
s ccccccc feat: Update README

# Rebase a7c1cff..02f8854 onto a7c1cff (3 commands)
#
# Commands:
# p, pick <commit> = use commit
# r, reword <commit> = use commit, but edit the commit message
# e, edit <commit> = use commit, but stop for amending
# s, squash <commit> = use commit, but meld into previous commit
# f, fixup [-C | -c] <commit> = like "squash" but keep only the previous
#                    commit's log message, unless -C is used, in which case
#                    keep only this commit's message; -c is same as -C but
#                    opens the editor
# x, exec <command> = run command (the rest of the line) using shell
# b, break = stop here (continue rebase later with 'git rebase --continue')
# d, drop <commit> = remove commit
# l, label <label> = label current HEAD with a name
# t, reset <label> = reset HEAD to a label
# m, merge [-C <commit> | -c <commit>] <label> [# <oneline>]
#         create a merge commit using the original merge commit's
#         message (or the oneline, if no original merge commit was
#         specified); use -c <commit> to reword the commit message
# u, update-ref <ref> = track a placeholder for the <ref> to be updated
#                       to this position in the new commits. The <ref> is
#                       updated at the end of the rebase
#
# These lines can be re-ordered; they are executed from top to bottom.
#
# If you remove a line here THAT COMMIT WILL BE LOST.
#
# However, if you remove everything, the rebase will be aborted.
#

vi でコミットメッセージを決める

Before
# This is a combination of 3 commits.
# This is the 1st commit message:

Update README

# This is the commit message #2:

Update README.md

# This is the commit message #3:

feat: Update README

# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
#
# Date:      Mon Oct 7 15:58:49 2024 +0900
#
# interactive rebase in progress; onto a7c1cff
# Last commands done (3 commands done):
#    squash 16082f7 Update README.md
#    squash 02f8854 feat: Update README
# No commands remaining.
# You are currently rebasing branch 'rebase-test' on 'a7c1cff'.
#
# Changes to be committed:
#       modified:   README.md
#
After
# This is a combination of 3 commits.
# This is the 1st commit message:

feat: Update README (rebase)

# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
#
# Date:      Mon Oct 7 15:58:49 2024 +0900
#
# interactive rebase in progress; onto a7c1cff
# Last commands done (3 commands done):
#    squash 16082f7 Update README.md
#    squash 02f8854 feat: Update README
# No commands remaining.
# You are currently rebasing branch 'rebase-test' on 'a7c1cff'.
#
# Changes to be committed:
#       modified:   README.md
#

ログの確認

git log -2

強制プッシュ

git push -f
山とコード山とコード

rust-lang/rustのHomu queueについて(Claudeに聞いた)

https://bors.rust-lang.org/queue/rust

Homu queue は、Rust プロジェクトのコントリビューションプロセスで重要な役割を果たすツールで、開発ワークフローを支えています。

大規模なオープンソースプロジェクトにおいて、コードの品質維持と開発速度の向上に貢献しています。

以下に主なポイントをまとめます:

目的:

  • Homu queueは、プルリクエスト(PR)のマージを自動化し、コードベースの品質を維持するために使用されます。

機能:

  • PRのテストと承認プロセスを管理します。
  • 承認されたPRを自動的にマージします。
  • コンフリクトや問題が発生した場合、人間のレビューアーに通知します。

プロセス:

  • PRが作成されると、Homuがそれをキューに追加します。
  • 必要なレビューと承認が得られると、Homuは自動的にテストを実行します。
  • すべてのテストがパスすると、PRは自動的にマージされます。

利点:

  • 手動のマージ作業を減らし、開発者の時間を節約します。
  • 一貫したテストと品質管理を保証します。
  • マージの順序を管理し、コンフリクトのリスクを低減します。

コマンド:
レビューアーは特定のコメントを使用してHomuを制御できます。

例えば:

  • @bors r+: PRを承認し、テストとマージのキューに追加します。
  • @bors r-: PRの承認を取り消します。
山とコード山とコード

より詳細な情報...

詳細な情報 by Claude

Homu の歴史と背景:
Homu は元々 Servo プロジェクト用に開発されたツールで、その後 Rust プロジェクトに採用されました。現在は "bors" という名前でも知られています。これは Homu のコマンドプレフィックスである "@bors" に由来します。

キューの仕組み:

  • Homu は複数のキューを管理します。主に "try" と "auto" キューがあります。
  • "try" キューは非破壊的なテストを実行します。
  • "auto" キューは最終的なテストとマージを行います。

詳細なコマンド:

  • @bors try: PR を "try" キューに追加し、テストを実行します。
  • @bors r+: PR を承認し、"auto" キューに追加します。
  • @bors r=username: 特定のユーザー名で PR を承認します。
  • @bors p=N: PR の優先度を設定します(N は数字)。
  • @bors rollup: 小さな変更を一つの大きなコミットにまとめます。

ロールバック機能:
Homu はマージ後に問題が発見された場合、自動的にロールバックを行う機能も持っています。

CI との連携:
Homu は GitHub Actions や他の CI システムと密接に連携し、テスト結果を監視します。

優先順位付け:
PRs は通常 FIFO (First In, First Out) で処理されますが、重要な修正や緊急の変更は優先的に処理できます。

ステータス報告:
Homu は GitHub 上で PR のステータスを常に更新し、現在のキューの状態や進行中のアクションを報告します。

コンフリクト解決:
PR 間でコンフリクトが発生した場合、Homu は自動的にそれを検出し、開発者に通知します。

カスタマイズ性:
Rust プロジェクトの需要に合わせて、Homu の設定は細かくカスタマイズされています。

セキュリティ:
Homu は承認されたコントリビューターからの指示のみを受け付けるよう設定されており、プロジェクトのセキュリティを強化しています。

パフォーマンス最適化:
Homu は複数の PR を並行してテストすることで、全体的なマージプロセスを高速化しています。

コミュニティの影響:
Homu の採用により、Rust コミュニティは効率的に協力し、高品質のコードを維持することが可能になりました。

ログインするとコメントできます