Product / CI & pipelines / Build Optimization

Build optimization: faster, cheaper CI pipelines

Updated November 2026 ยท Cache docs โ†’

Cut pipeline time and compute cost with caching, fail-fast, auto-cancel, conditional runs and job priorities.

TL;DR

  • cache stores dependencies between runs with no extra setup.
  • Fail-fast stops a pipeline as soon as a job fails.
  • Auto-cancel stops pipelines made obsolete by a newer push.
  • change_in runs only the blocks a commit affects.

Watch: Build Optimization

What it does

  • Automatic caching. cache store and cache restore detect common dependency folders. See cache.
  • Fail-fast. Stop the rest of the pipeline when a job fails. See the pipeline YAML reference.
  • Auto-cancel. Stop running or queued pipelines when a newer commit arrives on the same branch.
  • Run on specific changes. Skip blocks with change_in. See the conditions DSL and monorepos.
  • Prioritize jobs so the default branch gets machines first.
  • Optimized images. Pre-built Ubuntu and macOS images with common tools. See the Ubuntu and macOS images.

How it works

.semaphore/semaphore.yml

version: v1.0
name: CI
fail_fast:
  stop:
    when: "branch != 'main'"
auto_cancel:
  running:
    when: "branch != 'main'"
priority:
  - value: 70
    when: "branch = 'main'"
blocks:
  - name: Test
    task:
      prologue:
        commands:
          - checkout
          - cache restore
          - npm ci
          - cache store
      jobs:
        - name: Tests
          parallelism: 4
          commands:
            - npm test

Docs for this feature

FAQ

How do I see which blocks are slow?

Pipeline insights show duration over time, and test reports show the slowest tests in each pipeline.

Does caching need configuration?

For common languages, cache store and cache restore with no arguments detect the dependency folders. You can also pass your own keys and paths.

What does auto-cancel stop?

Pipelines that a newer push to the same branch has made obsolete. You choose whether it stops running pipelines or only queued ones, and on which branches.

Next steps

Read the Cache docs โ†’ ยท All CI & pipelines features โ†’ ยท Plans and pricing โ†’

Star us on GitHub