tanakh / cargo-atcoder

Cargo subcommand for AtCoder
BSD 3-Clause "New" or "Revised" License
397 stars 36 forks source link

Run `cargo install` on the CI #45

Open qryxip opened 4 years ago

qryxip commented 4 years ago

cargo installが壊れる、といったことがたまーに発生するので。

tanakh commented 3 years ago

ビルドが通ってinstallがこけるというのは具体的にどういった要因によるのかと、それをCIで拾う必要があるのかというのをいただけるでしょうか?

qryxip commented 3 years ago

こける要因としてはこの2つですね。2.は実際に見たことも無いですが、1.を3回くらい踏んだので... CIに入れる理由としては1.が発生したときにCIのバッヂが真っ赤になることによって、ユーザーが「インストールできねーぞ」というissueを立てる前に報告者本人の環境に起因している訳ではないことを本人が容易に確認できるという利点があります。(「なんかわかりませんがインストールに失敗します。私の環境は...(長々と報告者の環境とcargo installのエラー表示)」→ 「インストールできまんせんしCIが真っ赤です。--lockedではとりあえず可能なようですが。n週間前からこうなっているようです」)

  1. デフォルトでCargo.lockが無視されることにより、依存ライブラリがマイナーバージョンアップデートでうっかり破壊的変更をぶちこんできたときにcargo installが失敗することがある。これはユーザーが--locked付きで実行すればとりあえず回避可能。

    cargo install - The Cargo Book

    By default, the Cargo.lock file that is included with the package will be ignored. This means that Cargo will recompute which versions of dependencies to use, possibly using newer versions that have been released since the package was published. The --locked flag can be used to force Cargo to use the packaged Cargo.lock file if it is available. This may be useful for ensuring reproducible builds, to use the exact same set of dependencies that were available when the package was published. It may also be useful if a newer version of a dependency is published that no longer builds on your system, or has other problems. The downside to using --locked is that you will not receive any fixes or updates to any dependency. Note that Cargo did not start publishing Cargo.lock files until version 1.37, which means packages published with prior versions will not have a Cargo.lock file available.

  2. 「あるライブラリの必要であるはずのfeatureが明示的に有効化されていないが、dev-dependencies込みのdependency graph上ではたまたま有効化されている」というケースはしばしば存在する。dev-dependenciescargo installでは除外されるため、これを踏ん付けてcargo install--lockedでも失敗するという可能性がある。これは流石に直接見たことがない。

    rust-lang/cargo#5012

https://github.com/rust-lang/cargo/blob/rust-1.47.0/src/cargo/ops/cargo_install.rs#L593

https://github.com/rust-lang/cargo/blob/rust-1.47.0/src/cargo/core/workspace.rs#L76-L80

qryxip commented 3 years ago

一応dependency graphの乖離が小さければ追加のビルド時間は0に近いし、大きければ1., 2.が発生する確率が増えるので意義はあると思います。 まあ少々神経質すぎるかもしれませんが...