Skip to content

Add cache.maxAge to CI - #1779

Open
jpwilliams wants to merge 16 commits into
mainfrom
jack/ci-cache-max-age-v3
Open

jpwilliams wants to merge 16 commits into
mainfrom
jack/ci-cache-max-age-v3

Conversation

@jpwilliams

Copy link
Copy Markdown
Member

Summary

Adds cache.maxAge to ci.job()s, allowing JIT builds/caching to rebuild if the latest is not recent enough.

const base = ci.job(
  {
    id: "base",
    cache: {
      key: files("images/node-base/**"),
      maxAge: "1d",
    },
  },
  async () => {
    await checkout();

    await $`pnpm install`;
  },
);

Checklist

  • Added a docs PR that references this PR N/A Later bump
  • Added unit/integration tests
  • Added changesets if applicable

x and others added 14 commits October 9, 2026 23:02
Jobs, commands and extra machines become spans, CI's steps are named for what
they do and marked as CI's work. A job's `name` sets its span name.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Every span is an entry in the `spans` catalog with a required kind, step IDs
are built by `joinId`, and starting a machine is a flat staged function in
`machine/start.ts`. Folds the CI half of ci2-span-kinds: commands, sandboxes,
saves and attempts carry kinds, each statement on a background process is a
row of its own, and a snapshot's span is passed to an SDK that takes it
(feature-detected by version) and opened by CI otherwise. Names the checkout
steps. Adds a `ciTest` harness.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Moving it to its own file cost more diff than it saved.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The span API and a snapshot's own span are always there, so the stub, the
version gate and the dual snapshot-span path are gone. The shared test
harness had one user, so it is local to that test again.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…he lookups

CI's step IDs and names move to one catalog in pipeline/names.ts, run through
a thin ciRun helper that tags the step as before. Sandbox paging and snapshot
deletes (machine/admin.ts), snapshot names (cache/names.ts), the cache lookup
and the check-complete payload each have one implementation. No step ID, name
or wire format changes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A cached snapshot older than cache.maxAge counts as a miss. One usableFor predicate decides whether a snapshot may be used.

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

A later direct call has the path `id (n)`, which is not a registry key, so
its span lost the configured name. The span now takes the name from the
job's config and keeps the call number.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Adapt the job span name fix into the steps catalog refactor: names.ts keeps
the catalog and takes traceName.job(config, path) from the base.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…al to main's helpers)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@jpwilliams jpwilliams self-assigned this Oct 13, 2026
Copilot AI balanced review requested due to automatic review settings October 13, 2026 23:32
@changeset-bot

changeset-bot Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 6ec7368

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@inngest/ci Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

The freshness behavior, validation, race resolution, tests, and public documentation are consistent, with only a minor grammar issue noted.

1 open finding
What changed in this PR

Adds configurable cache freshness to @inngest/ci, allowing jobs to rebuild snapshots older than cache.maxAge.

Changes:

  • Adds and validates the cache.maxAge duration option.
  • Applies freshness checks during cache lookup and name-conflict resolution.
  • Adds tests, documentation, and a minor changeset.
File Description
.changeset/​ci-cache-max-age.md Records the new cache option.
packages/​ci/​README.md Documents maxAge usage.
packages/​ci/​src/​cache/​cache.test.ts Tests snapshot freshness and replacement.
packages/​ci/​src/​cache/​cache.ts Implements age-aware cache usability.
packages/​ci/​src/​machine/​machine.ts Passes cache configuration during snapshot naming.
packages/​ci/​src/​pipeline/​cacheGuarantees.test.ts Adds end-to-end cache-age tests.
packages/​ci/​src/​pipeline/​job.ts Validates durations and forwards cache settings.
packages/​ci/​src/​types.ts Exposes CacheConfig.maxAge.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread packages/ci/src/pipeline/job.ts Outdated
@greptile-apps

greptile-apps Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

RetriggerConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no actionable defects were found.

Summary

Adds cache.maxAge so jobs rebuild snapshots that are too old.

  • CI jobs rebuild cached snapshots after a configured age.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Resolve parent snapshot] --> B[Compute cache name]
  B --> C{Usable snapshot found?}
  C -->|Yes| D[Reuse snapshot]
  C -->|No| E[Build job]
  E --> F{Cache name available?}
  F -->|Yes| G[Save named snapshot]
  F -->|No| H{Usable holder found?}
  H -->|Yes| D
  H -->|No| I[Delete old ready holder]
  I --> J[Retry named snapshot]
Loading

Reviews (1) · Last reviewed commit: "docs(ci): rewrite cache-max-age changese..." · Reviewed by Greptile

jpwilliams and others added 2 commits October 13, 2026 23:42
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jpwilliams
jpwilliams added this pull request to stack #1788 October 15, 2026 18:14

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants