# Fail-Fast vs Continue-on-Error: CIの停止方法を制御する

> fail-fastは最初の失敗でpipelineを停止し、continue-on-errorは続行させます。それぞれが何をするか、どこに適用されるか、どう選ぶかを学びましょう。

Source: https://latchkey.dev/ja/learn/ci-cd-concepts/fail-fast-vs-continue-on-error  
Updated: 2026-06-25

fail-fastは何かが失敗した瞬間に停止して時間を節約します。continue-on-errorは失敗を押し通してより多くの情報を集めます。両者は正反対の問いに答え - 適用されるレベルも異なります。

この2つの設定はpipelineが失敗にどう反応するかを形づくります。速度のために早期に打ち切るか、網羅性のために続行するかです。両者は異なるスコープで動作し、混同すると無駄な時間か隠れた失敗のどちらかにつながります。

## Fail-fast（matrix/strategyレベル）

fail-fastは1つが失敗するとすぐに残りの並列jobをキャンセルします。どの失敗も変更全体がダメであることを意味する場合に分を節約します。欠点は、最初に失敗した組み合わせしか分からず、そのバグが特定のOSやバージョンに固有かどうかは分からないことです。pass/failの全グリッドが欲しいときは無効にしましょう。

## Continue-on-error（step/jobレベル）

continue-on-errorはstepまたはjobにマークを付け、その失敗が実行を失敗させないようにします - pipelineは続行し、全体としては成功と報告します。重要でない、あるいは情報提供的なstep（オプションのlinter、実験的なmatrixのレッグ）で、結果は記録したいがgateにはしたくない場合に使います。

```Non-gating step
- run: ./optional-linter.sh
  continue-on-error: true
```

## 両者は互いの反対ではない

よくある混乱です。fail-fastは失敗時に*兄弟job*がキャンセルされるかどうかを制御し、continue-on-errorは*特定のstep/jobの*失敗が実行にカウントされるかどうかを制御します。fail-fastを無効にして（すべての組み合わせを実行して）も、一部のstepをgateにし、他をそうしないことができます。

## 選び方

- どの失敗も変更全体を無効にするとき（高速なフィードバック）はfail-fastを使う。
- すべての組み合わせの結果を見る必要があるときはfail-fastを無効にする。
- 本当にオプションで情報提供的なstepにのみcontinue-on-errorを使う。
- 本来gateにすべきstepを取り繕うためにcontinue-on-errorを決して使わない。

## FAQ

### What is Fail-Fast vs Continue-on-Error: controlling how CI stops?

These two settings shape how a pipeline reacts to failure: bail early for speed, or keep going for completeness. They operate at different scopes, and mixing them up leads to either wasted minutes or hidden failures.

### Fail-fast (matrix/strategy level)?

Fail-fast cancels the remaining parallel jobs as soon as one fails. It saves minutes when any failure means the whole change is bad. The downside: you only learn about the first failing combination, not whether the bug is specific to one OS or version. Disable it when you want the full pass/fail grid.

### Continue-on-error (step/job level)?

Continue-on-error marks a step or job so its failure does not fail the run - the pipeline keeps going and reports overall success. It is for non-critical or informational steps (an optional linter, an experimental matrix leg) where you want the result recorded but not gating.

### They are not opposites of each other?

A common confusion: fail-fast governs whether *sibling jobs* get cancelled on a failure; continue-on-error governs whether a *specific step/job’s* failure counts against the run. You can disable fail-fast (run all combinations) and still have some steps gate while others do not.

---

Latchkey runs CI/CD that repairs its own failures. Agent entry points: https://latchkey.dev/agent.txt, https://latchkey.dev/openapi.json, https://latchkey.dev/llms.txt
