TEST-INFRA: [ci-pipeline-design] Improve CI caching strategy #1818

Open
opened 2026-04-02 23:55:32 +00:00 by freemo · 2 comments
Owner

Metadata

  • Branch: chore/ci-improve-caching-strategy
  • Commit Message: chore(ci): improve CI caching strategy with per-job granular cache keys
  • Milestone: v3.8.0
  • Parent Epic: #1678

Background and Context

The current CI caching strategy uses a single cache key based on the pyproject.toml file. While this ensures the cache is invalidated when dependencies change, it is not granular enough — all jobs share the same cache key, meaning a change to any dependency invalidates caches for all jobs, even those unaffected by the change.

Current Behavior

All CI jobs use a cache key derived from the hash of pyproject.toml. If this file changes for any reason, every job's cache is invalidated and must be rebuilt from scratch, even if the specific tooling for a given job (e.g., linting config) has not changed.

Expected Behavior

Each CI job should use a cache key that reflects only the files relevant to that job's tooling. For example:

  • The lint job cache key should include the hash of .ruff.toml (or equivalent linting config).
  • The typecheck job cache key should include the hash of pyrightconfig.json.
  • Other jobs should similarly use targeted cache keys.

This reduces unnecessary cache invalidations and speeds up the CI pipeline.

Acceptance Criteria

  • The CI caching strategy is improved to be more granular, with per-job cache keys.
  • Each job's cache key includes only the files relevant to that job's tooling.
  • The CI pipeline is faster as a result of the improved caching strategy.
  • The CI pipeline continues to function correctly with no regressions.

Supporting Information

  • Parent Epic: #1678 (CI Execution Time Optimization — Timeouts, Concurrency, and Coverage Artifact Sharing)
  • Related files: .forgejo/workflows/ci.yml, .ruff.toml, pyrightconfig.json, pyproject.toml

Subtasks

  • Audit all CI jobs in .forgejo/workflows/ci.yml to identify current cache key usage
  • Define per-job cache key strategy (identify which config files are relevant per job)
  • Update lint job cache key to include hash of linting config (e.g., .ruff.toml)
  • Update typecheck job cache key to include hash of pyrightconfig.json
  • Update remaining jobs with appropriate targeted cache keys
  • Update features/ci_workflow_validation.feature to assert per-job cache key correctness
  • Verify all nox stages pass after changes
  • Confirm coverage ≥ 97%

Definition of Done

This issue is complete when:

  • All subtasks above are completed and checked off.
  • A Git commit is created where the first line of the commit message matches the Commit Message in Metadata exactly (chore(ci): improve CI caching strategy with per-job granular cache keys), followed by a blank line, then additional lines providing relevant details about the implementation.
  • The commit is pushed to the remote on the branch matching the Branch in Metadata exactly (chore/ci-improve-caching-strategy).
  • The commit is submitted as a pull request to master, reviewed, and merged before this issue is marked done.
  • All nox stages pass.
  • Coverage >= 97%

Automated by CleverAgents Bot
Supervisor: Test Infrastructure | Agent: ca-new-issue-creator

## Metadata - **Branch**: `chore/ci-improve-caching-strategy` - **Commit Message**: `chore(ci): improve CI caching strategy with per-job granular cache keys` - **Milestone**: v3.8.0 - **Parent Epic**: #1678 ## Background and Context The current CI caching strategy uses a single cache key based on the `pyproject.toml` file. While this ensures the cache is invalidated when dependencies change, it is not granular enough — all jobs share the same cache key, meaning a change to any dependency invalidates caches for all jobs, even those unaffected by the change. ## Current Behavior All CI jobs use a cache key derived from the hash of `pyproject.toml`. If this file changes for any reason, every job's cache is invalidated and must be rebuilt from scratch, even if the specific tooling for a given job (e.g., linting config) has not changed. ## Expected Behavior Each CI job should use a cache key that reflects only the files relevant to that job's tooling. For example: - The `lint` job cache key should include the hash of `.ruff.toml` (or equivalent linting config). - The `typecheck` job cache key should include the hash of `pyrightconfig.json`. - Other jobs should similarly use targeted cache keys. This reduces unnecessary cache invalidations and speeds up the CI pipeline. ## Acceptance Criteria - The CI caching strategy is improved to be more granular, with per-job cache keys. - Each job's cache key includes only the files relevant to that job's tooling. - The CI pipeline is faster as a result of the improved caching strategy. - The CI pipeline continues to function correctly with no regressions. ## Supporting Information - Parent Epic: #1678 (CI Execution Time Optimization — Timeouts, Concurrency, and Coverage Artifact Sharing) - Related files: `.forgejo/workflows/ci.yml`, `.ruff.toml`, `pyrightconfig.json`, `pyproject.toml` ## Subtasks - [ ] Audit all CI jobs in `.forgejo/workflows/ci.yml` to identify current cache key usage - [ ] Define per-job cache key strategy (identify which config files are relevant per job) - [ ] Update `lint` job cache key to include hash of linting config (e.g., `.ruff.toml`) - [ ] Update `typecheck` job cache key to include hash of `pyrightconfig.json` - [ ] Update remaining jobs with appropriate targeted cache keys - [ ] Update `features/ci_workflow_validation.feature` to assert per-job cache key correctness - [ ] Verify all nox stages pass after changes - [ ] Confirm coverage ≥ 97% ## Definition of Done This issue is complete when: - All subtasks above are completed and checked off. - A Git commit is created where the **first line** of the commit message matches the Commit Message in Metadata exactly (`chore(ci): improve CI caching strategy with per-job granular cache keys`), followed by a blank line, then additional lines providing relevant details about the implementation. - The commit is pushed to the remote on the branch matching the **Branch** in Metadata exactly (`chore/ci-improve-caching-strategy`). - The commit is submitted as a **pull request** to `master`, reviewed, and **merged** before this issue is marked done. - All nox stages pass. - Coverage >= 97% --- **Automated by CleverAgents Bot** Supervisor: Test Infrastructure | Agent: ca-new-issue-creator
freemo added this to the v3.8.0 milestone 2026-04-02 23:55:41 +00:00
Author
Owner

Issue triaged by project owner:

  • State: Verified
  • MoSCoW: MoSCoW/Could Have — CI/test infrastructure improvement.

Automated by CleverAgents Bot
Supervisor: Project Owner | Agent: ca-project-owner

Issue triaged by project owner: - **State**: Verified - **MoSCoW**: MoSCoW/Could Have — CI/test infrastructure improvement. --- **Automated by CleverAgents Bot** Supervisor: Project Owner | Agent: ca-project-owner
Author
Owner

Issue triaged by project owner:

  • State: Verified
  • MoSCoW: MoSCoW/Could Have — CI/test infrastructure improvement.

Automated by CleverAgents Bot
Supervisor: Project Owner | Agent: ca-project-owner

Issue triaged by project owner: - **State**: Verified - **MoSCoW**: MoSCoW/Could Have — CI/test infrastructure improvement. --- **Automated by CleverAgents Bot** Supervisor: Project Owner | Agent: ca-project-owner
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
cleveragents/cleveragents-core#1818
No description provided.