Skip to content

chore: speedup ci and typecheck - #4200

Merged
KATO-Hiro merged 10 commits into
stagingfrom
ci-and-typecheck-speedup
Oct 21, 2026
Merged

KATO-Hiro merged 10 commits into
stagingfrom
ci-and-typecheck-speedup

Conversation

@KATO-Hiro

@KATO-Hiro KATO-Hiro commented Oct 21, 2026 •

Copy link
Copy Markdown
Collaborator

CI と型チェックの高速化、actions の SHA 固定

概要

Kit 3 への移行の後、「build・check が遅い」という相談を受け、時間の内訳を測って効く所だけを直した。
あわせて、GitHub Actions の action を commit SHA に固定した。
branch ci-and-typecheck-speedup で実装済み(2026-10-21)。
tsgo による型チェックの高速化は後回しにし、TASK.md に移した。

Phase 変更 効果
1 pnpm lint の prettier に --cache を付けた ローカルの prettier 8.6 秒 → 1.6 秒
2 tsconfig.json から効いていない3項目を消した tsgo を使う前提を整えた(挙動は同じ)
3 action を commit SHA に固定した tag の書き換えによる攻撃を防ぐ
4 CI の build・lint・check・unit test を並列ジョブにした CI の build の段 1分19秒 → 約42秒(見込み)
5 deploy のジョブの重複した pnpm build を消した deploy のジョブ 約13秒短縮(見込み)

CI 全体は 2分21秒〜2分50秒 → 約1分30秒〜2分の見込み。実測は PR の CI で行う。

判断と根拠

Phase 3: SHA 固定

  • tag は action の repo が乗っ取られると書き換えられる(GitHub の security hardening guide)。この workflow は Vercel の token と DB の接続先を扱うので、actions/* も含めて3つとも固定した。
  • SHA は当時の major tag が指す commit にし、動くコードは変えていない。pnpm/action-setup は annotated tag なので、tag が指す commit(git ls-remote の ^{} の行)を使った。
  • 以後の更新は Renovate の helpers:pinGitHubActionDigestsToSemver が、SHA とコメントの版を一緒に書き換える。

Phase 4: ジョブの並列化

  • lint・check・unit test は build の出力を使わないので、並列にできる。型チェックに要る node_modules/$app/ は build ではなく svelte-kit sync が生成し、check と unit test はそれぞれ自分で sync を実行する。
    • 確認: 空のディレクトリで pnpm install の後に1つずつ単独で実行し、3つとも成功した。
  • build ジョブだけ matrix を残し、既存の check 名 build (24) を変えていない。
  • setup(pnpm・Node.js・install)は composite action にまとめ、deploy のジョブでも使う。SHA の更新を1か所で済ませるため。
  • branch protection(admin が対処済み): 分割後は lint などの失敗が build (24) に出なくなるので、required checks に lint・check・unit-test を追加した。
  • 「Require branches to be up to date before merging」は変えていない。入れると、Renovate の多数の PR がマージのたびに rebase と CI のやり直しになる。

Phase 2: tsconfig の3項目

  • outDir・sourceMap・incremental は、TypeScript がファイルを出力するとき(または tsc を直接実行するとき)だけ効く。Kit が生成する $app/tsconfig が noEmit: true で、tsc を直接実行する所も無いので、どれも効いていなかった。
  • outDir は svelte-check の --tsgo を壊していた(「rootDir の外」のエラー)。tsgo は後回しにしたが、この削除は先に入れた。
  • Vercel への成果物(.vercel/output)は adapter-vercel が決めるので、outDir: "build" とは関係しない。
  • 削除の前後で、check・build・unit test の結果は変わらない。

Phase 5: deploy のジョブの重複

  • vercel build が install と vite build を自分で行うので、その前の pnpm build は重複していた。2024 年に migration の step と一緒に追加されたもので、必要だった記録は無い。
  • prisma migrate deploy を vercel build の後に移し、「build が失敗したら DB を変えない」を保った。
  • 今は build のときに DB を読む処理(prerender など)が無い。将来 prerender を入れると、migration 前の DB を読むことになるので注意する。

採らなかった案

  • rsvelte などの代替ツール: 運用実績が少ない。
  • svelte-check の --incremental: 2回目でも 4.1 秒で、tsgo(2.6 秒)より遅い。
  • Vite・adapter・prisma generate の調整: それぞれ数秒で、削れる余地が小さい。
  • deploy を lint などと並行に走らせる: lint・check が失敗した変更でも、preview の DB に migration が当たる。
  • workflow dependency lockfile(actions.lock): SHA 固定より強いが、GitHub 側は public preview、Renovate の対応も experimental。
  • oxfmt への移行: 別 PR(#2226、計画)。移行すると Phase 1 は不要になるが、1行の変更なので先に入れた。

残りの確認(人が行う)

  • Vercel のダッシュボードの Build Command が想定外のコマンドになっていないか(vercel.json には指定が無い)。
  • PR の CI で4ジョブが並行に走り、時間が見込みどおり縮むか。
  • PR の preview ジョブが成功し、preview の URL でログインできるか。production はマージ後の最初の実行で確かめる。
  • マージ後の Renovate の action の更新 PR が、SHA とコメントを一緒に書き換えるか。

後で決めること

  • ESLint の --cache: 測ってから判断する。
  • workflow dependency lockfile: GitHub と Renovate の対応が安定したら、SHA 固定から乗り換えるかを決める。

確認限界

  • CI の見込みは、分割前の build (24) の1回分の時間からの計算。
  • vercel build そのものは token が要るので実行しておらず、vite build までで確かめた。
  • actionlint は実行できず、workflow は yaml のパーサーと Prettier でしか確かめていない。
  • Vercel のダッシュボードと branch protection の設定は、repo からは見えない。

付録: 計測(2026-10-19、devcontainer)

コマンド 時間 主な内訳
pnpm build 14.4 秒 Vite 4.6 秒、adapter-vercel 2.3 秒、prisma generate 1.8 秒
pnpm lint 11.6 秒 prettier 9.3 秒、ESLint 4.4 秒、oxlint 0.1 秒
pnpm check 10.6 秒 svelte-check 9.3 秒
pnpm test:unit 6.0 秒
  • CI の staging の直近10回は、全体で 2分21秒〜2分50秒。
  • 分割前の build (24) ジョブは 1分19秒。うち setup などジョブごとの固定分が約29秒、Build・Lint・Check・Unit test の本体が順に計48秒。

Summary by CodeRabbit

  • 改善

    • プレビューおよび本番環境のデプロイ手順を更新し、環境に応じたビルドとデータベース更新を実行するようにしました。
    • CIで使用するツールの参照方法を固定し、実行環境の安定性を高めました。
  • 開発体験

    • コード品質チェックの処理を効率化しました。
    • GitHub Actionsの更新管理を強化しました。
  • 設定

    • TypeScriptのビルド関連設定を整理しました。

KATO-Hiro and others added 4 commits October 21, 2026 07:36
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The generated $app/tsconfig sets noEmit, so outDir, sourceMap, and
incremental have no effect; outDir also breaks svelte-check --tsgo.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Pin each action to the commit its current major tag points to, and let
Renovate keep the digests and version comments up to date.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
vercel build already runs install and the build command, so the prior
pnpm build was redundant. Run prisma migrate deploy after vercel build to
keep migrations gated on a successful build.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 4 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Repository: AtCoder-NoviSteps/AtCoderNoviSteps/.coderabbit.yaml
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 300689b9-1793-4861-9b60-a970f390d5de
📥 Commits

Reviewing files that changed from the base of the PR and between ec81f37 and d4aabb5.

📒 Files selected for processing: 2
  • .github/actions/setup/action.yml
  • .github/workflows/ci.yml

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: AtCoder-NoviSteps/AtCoderNoviSteps/.coderabbit.yaml
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 8ffa5172-f804-4710-8b97-9c3dea9fd80a
📥 Commits

Reviewing files that changed from the base of the PR and between 1794772 and ec81f37.

📒 Files selected for processing: 4
  • .github/workflows/ci.yml
  • package.json
  • renovate.json
  • tsconfig.json
💤 Files with no reviewable changes: 1
  • tsconfig.json

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

📝 Walkthrough

CIワークフローのアクション参照を固定し、previewとproductionのビルド後にデータベースマイグレーションを適用する順序へ変更しました。lintスクリプトとTypeScript設定も更新しました。

Changes: デプロイパイプライン

Layer / File(s) Summary
GitHub Actionsの参照固定
.github/workflows/ci.yml, renovate.json
ワークフロー内のcheckout、pnpm、Node.jsアクションを固定コミット参照に変更しました。Renovateに、GitHub Actionsの参照を固定するプリセットを追加しました。
Vercelビルドとマイグレーションの順序
.github/workflows/ci.yml
previewではpreview環境、productionではproduction環境を使ってVercelアーティファクトをビルドします。両環境とも、ビルド後に保留中のPrismaマイグレーションを適用します。

プロジェクト設定

Layer / File(s) Summary
lintとTypeScriptの設定
package.json, tsconfig.json
Prettierチェックに--cacheを追加しました。tsconfig.jsonからincremental、outDir、sourceMapを削除しました。

Priority: ⬇️ Low

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Other

Sequence Diagram(s)

sequenceDiagram
  participant DeployJob as Preview / production job
  participant VercelCLI as Vercel CLI
  participant Prisma
  participant Database
  DeployJob->>VercelCLI: 環境情報を取得してアーティファクトをビルド
  VercelCLI-->>DeployJob: ビルド結果
  DeployJob->>Prisma: 保留中のマイグレーションを実行
  Prisma->>Database: マイグレーションを適用
Loading
Merge Risk: ⚪ Minimal · up to ec81f

The reviewed CI and development-configuration changes do not present an established merge-blocking risk.

Pre-merge checks: Passed 5
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed タイトルはCIの高速化と型チェック改善という変更の主目的を示しています。実際の変更内容と関連しています。
Docstring Coverage Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 0…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 0 files. (3 skipped: 3 unsupported.)

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

KATO-Hiro and others added 2 commits October 21, 2026 08:14
Every job ran the same pnpm, Node.js, and install steps; keep them and
their pinned SHAs in one place.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
None of them uses the build output, so split them out of the build job
and make the deploy jobs wait for all four. The build job keeps its
matrix so the existing build (24) check name stays the same.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
KATO-Hiro and others added 4 commits October 21, 2026 08:32
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

@KATO-Hiro KATO-Hiro left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

LGTM

@KATO-Hiro
KATO-Hiro merged commit 648da20 into staging Oct 21, 2026
6 checks passed
@KATO-Hiro
KATO-Hiro deleted the ci-and-typecheck-speedup branch October 21, 2026 08:55

This branch was successfully deployed

1 active deployment
preview — d4aabb53 Deployed Oct 21, 2026 by KATO-Hiro via preview #9052
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.

1 participant