DEV Community

hiko1129
hiko1129

Posted on • Originally published at note.hiko1129.com on

[Ruby][Sorbet] How to check RBI file update omission with CI

Translate ja to en

tapiocaに関しては--verifyオプションが用意されているのでそれを利用する

bin/tapioca gems --verify
bin/tapioca dsl --verify
Enter fullscreen mode Exit fullscreen mode

sorbet-railsに関してはtapiocaのようなオプションが用意されていないようなので下記の感じで差分があるか確認する

bin/rails db:schema:load # ridgepoleを使っている場合にはridgepole --applyを。
bundle exec rake rails_rbi:all
git diff --exit-code --quiet
Enter fullscreen mode Exit fullscreen mode

実際のところ現状だと各RBIのコンフリクト解消が関わってくるので自分は下記のような感じで対応しています

bundle exec srb rbi sorbet-typed
bin/rails db:schema:load
bin/rails rails_rbi:all
bin/tapioca gem --workers=8
bin/tapioca todo
bundle exec srb rbi suggest-typed # コンフリクト解消をここで行ってから差分がでないことを確認する。こうしないとコンフリクト解消前の状態とコンフリクト解消後の状態の比較になってしまい差分が頻繁に発生する状態になってしまいほぼ常にCIで引っかかる状態になってしまう

git diff --exit-code --quiet
if [ $? -ne 0 ]; then
    echo "Please resolve the difference of RBI files"
    exit 1
fi
Enter fullscreen mode Exit fullscreen mode

参考:

Postmark Image

Speedy emails, satisfied customers

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

AWS GenAI LIVE!

GenAI LIVE! is a dynamic live-streamed show exploring how AWS and our partners are helping organizations unlock real value with generative AI.

Tune in to the full event

DEV is partnering to bring live events to the community. Join us or dismiss this billboard if you're not interested. ❤️