Skip to content

Conversation

@denver79
Copy link
Owner

@denver79 denver79 commented Oct 4, 2025

The Problem:
In the .github/workflows/code-quality.yml workflow, the clang-tidy job builds a Docker image in two stages: base and code_quality. While the base stage is correctly built and its layers are saved to the GitHub Actions cache (using cache-to), the subsequent code_quality stage only reads from the cache (cache-from) but does not write its own resulting layers back to the cache.

This results in the code_quality stage being rebuilt from scratch on every single run. This leads to significantly longer CI times and inefficient use of resources.

Proposed Solution:

By adding the cache-to parameter to the code_quality build step, we can ensure its layers are also cached. This will dramatically speed up subsequent runs of the workflow. The cache-from should also be updated to look for its own cache first.

Current Code:

  • name: Build code_quality stage
    uses: docker/build-push-action@v5
    with:
    context: .
    file: docker/Dockerfile
    target: code_quality
    cache-from: type=gha,scope=base

Suggested Change:

  • name: Build code_quality stage
    uses: docker/build-push-action@v5
    with:
    context: .
    file: docker/Dockerfile
    target: code_quality

    Attempt to read from both 'code_quality' and 'base' caches

    cache-from: |
    type=gha,scope=code_quality
    type=gha,scope=base

    Write the resulting layers to the 'code_quality' cache scope

    cache-to: type=gha,scope=code_quality,mode=max
    This simple change will make the code quality checks run much faster, improving the overall developer experience and efficiency.

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.

2 participants