Skip to content

ci: correct cache-fetch step reference in pipelines#2537

Merged
chmouel merged 1 commit intotektoncd:mainfrom
theakshaypant:fix-ci-cache-fetch-upload
Mar 5, 2026
Merged

ci: correct cache-fetch step reference in pipelines#2537
chmouel merged 1 commit intotektoncd:mainfrom
theakshaypant:fix-ci-cache-fetch-upload

Conversation

@theakshaypant
Copy link
Copy Markdown
Member

@theakshaypant theakshaypant commented Mar 5, 2026

📝 Description of the Change

Fix Go module cache mechanism in Tekton CI pipelines by correcting the step result reference in cache-upload steps.

Problem

The Go module cache configured in .tekton/go.yaml and .tekton/generate-coverage-release.yaml was not working effectively - modules were being re-downloaded on every pipeline run despite successful cache fetches.
Root cause: The cache-upload step was using incorrect syntax to reference the fetched result from the cache-fetch step, causing the variable to remain unexpanded as a literal string.

Changes

Fixed in both pipeline files:

Before:

- name: fetched
  value: $(tasks.cached-fetch.results.fetched)

After:

- name: fetched
  value: $(steps.cache-fetch.results.fetched)

Two bugs corrected:

  • Wrong reference type: tasks → steps
    • Both cache-fetch and cache-upload are steps within the same task
  • Typo in step name: cached-fetchcache-fetch

How It Works

Result Flow:

  1. cache-fetch emits result (writes to own result):
    if [ $? -eq 0 ]; then
      echo -n true > $(step.results.fetched.path)   # Cache hit
    else
      echo -n false > $(step.results.fetched.path)  # Cache miss
    fi
  2. cache-upload consumes result (reads from previous step):
    - name: fetched
      value: $(steps.cache-fetch.results.fetched)  # Expands to "true" or "false"
  3. Upload logic evaluates correctly:
    if [[ ${PARAM_FORCE_CACHE_UPLOAD} == "false" && ${RESULT_CACHE_FETCHED} == "true" ]]; then
      echo "no need to upload cache"
      exit 0
    fi

Before This Fix

Pipeline logs showed the variable was not being substituted:

+ [[ $(tasks.cached-fetch.results.fetched) == \t\r\u\e ]]

Tekton couldn't resolve tasks.cached-fetch (doesn't exist), so it left the literal string unexpanded. This never equals "true", causing cache upload to run unnecessarily on every pipeline execution.

After This Fix

The variable gets properly substituted:

+ [[ true == \t\r\u\e ]]  # When cache was successfully fetched

Now when cache is hit, the upload step correctly skips with "no need to upload cache", avoiding redundant uploads and enabling proper cache reuse.

👨🏻‍ Linked Jira

N/A

🔗 Linked GitHub Issue

Fixes #2533

🧪 Testing Strategy

  • Unit tests
  • Integration tests
  • End-to-end tests
  • Manual testing
  • Not Applicable

🤖 AI Assistance

  • I have not used any AI assistance for this PR.
  • I have used AI assistance for this PR.

If you have used AI assistance, please provide the following details:

Which LLM was used?

  • GitHub Copilot
  • ChatGPT (OpenAI)
  • Claude (Anthropic)
  • Cursor
  • Gemini (Google)
  • Other: ____________

Extent of AI Assistance:

  • Documentation and research only
  • Unit tests or E2E tests only
  • Code generation (parts of the code)
  • Full code generation (most of the PR)
  • PR description and comments
  • Commit message(s)

Important

If the majority of the code in this PR was generated by an AI, please add a Co-authored-by trailer to your commit message.
For example:

Co-authored-by: Gemini gemini@google.com
Co-authored-by: ChatGPT noreply@chatgpt.com
Co-authored-by: Claude noreply@anthropic.com
Co-authored-by: Cursor noreply@cursor.com
Co-authored-by: Copilot Copilot@users.noreply.github.com

**💡You can use the script ./hack/add-llm-coauthor.sh to automatically add
these co-author trailers to your commits.

✅ Submitter Checklist

  • 📝 My commit messages are clear, informative, and follow the project's How to write a git commit message guide. The Gitlint linter ensures in CI it's properly validated
  • ✨ I have ensured my commit message prefix (e.g., fix:, feat:) matches the "Type of Change" I selected above.
  • ♽ I have run make test and make lint locally to check for and fix any
    issues. For an efficient workflow, I have considered installing
    pre-commit and running pre-commit install to
    automate these checks.
  • 📖 I have added or updated documentation for any user-facing changes.
  • 🧪 I have added sufficient unit tests for my code changes.
  • 🎁 I have added end-to-end tests where feasible. See README for more details.
  • 🔎 I have addressed any CI test flakiness or provided a clear reason to bypass it.
  • If adding a provider feature, I have filled in the following and updated the provider documentation:
    • GitHub App
    • GitHub Webhook
    • Gitea/Forgejo
    • GitLab
    • Bitbucket Cloud
    • Bitbucket Data Center

@pipelines-as-code
Copy link
Copy Markdown

pipelines-as-code bot commented Mar 5, 2026

🔍 PR Lint Feedback

Note: This automated check helps ensure your PR follows our contribution guidelines.

⚠️ Items that need attention:

🤖 AI attribution

The following commits lack an explicit AI attribution footer:

  • 7d430a4 ci: use steps syntax for cache-fetch result reference

If no AI assistance was used for a commit, you can ignore this warning.
Otherwise add an Assisted-by: or Co-authored-by: footer referencing the AI used.


ℹ️ Next Steps

  • Review and address the items above
  • Push new commits to update this PR
  • This comment will be automatically updated when issues are resolved
🔧 Admin Tools (click to expand)

Automated Issue/Ticket Creation:

  • /issue-create - Generate a GitHub issue from this PR content using AI
  • /jira-create - Create a SRVKP Jira ticket from this PR content using AI

⚠️ Important: Always review and edit generated content before finalizing tickets/issues.
The AI-generated content should be used as a starting point and may need adjustments.

These commands are available to maintainers and will post the generated content as PR comments for review.

🤖 This feedback was generated automatically by the PR CI system

@pipelines-as-code pipelines-as-code bot added bug Something isn't working ci fix labels Mar 5, 2026
@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses a critical issue in the CI pipelines by rectifying a misnamed step reference. The correction ensures that the caching mechanism functions as intended, leading to more efficient pipeline execution by avoiding redundant cache uploads and improving overall build performance.

Highlights

  • CI Pipeline Fix: Corrected a typo in the cache-upload step reference within Tekton pipelines, changing 'cached-fetch' to 'cache-fetch'.
  • Cache Optimization: This fix ensures that the cache-fetch result is properly utilized, preventing unnecessary cache uploads when a cache has already been successfully fetched.
Changelog
  • .tekton/generate-coverage-release.yaml
    • Updated the 'fetched' parameter value from 'tasks.cached-fetch.results.fetched' to 'tasks.cache-fetch.results.fetched' to correct a typo.
  • .tekton/go.yaml
    • Updated the 'fetched' parameter value from 'tasks.cached-fetch.results.fetched' to 'tasks.cache-fetch.results.fetched' to correct a typo.
Activity
  • The pull request was created by theakshaypant to fix a typo in CI pipeline configurations.
  • The author indicated using AI assistance (Claude) for commit message generation.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request corrects a typo in two Tekton pipeline definitions, .tekton/generate-coverage-release.yaml and .tekton/go.yaml. The reference to the cache-fetch task was misspelled as cached-fetch, which prevented the cache from being used correctly. The fix aligns the task reference, ensuring that the CI pipelines can properly utilize the cache and avoid unnecessary work. The changes are correct and effectively address the issue.

Fix cache-upload step to use $(steps.cache-fetch.results.fetched)
instead of $(tasks.cache-fetch.results.fetched). Since both steps
are in the same task, the result must be referenced using steps
syntax. This prevented the variable from being substituted, causing
cache uploads to run even when cache was successfully fetched.

Fixes: tektoncd#2533

Signed-off-by: Akshay Pant <akshay.akshaypant@gmail.com>
@theakshaypant theakshaypant force-pushed the fix-ci-cache-fetch-upload branch from f035123 to 7d430a4 Compare March 5, 2026 13:16
@theakshaypant
Copy link
Copy Markdown
Member Author

STEP_CACHE_UPLOAD before:

Patterns: **go.mod **go.sum                                                                                                                                                                                                                                
  + [[ false == \f\a\l\s\e ]]                                                                                                                                                                                                                                
  + [[ $(tasks.cache-fetch.results.fetched) == \t\r\u\e ]]                                                                                                                                                                                                   
  + PATTERN_FLAGS=                                                                                                                                                                                                                                           
  + echo 'Patterns: **go.mod **go.sum'                                                                                                                                                                                                                       
  + for p in $*                                                                                                                                                                                                                                              
  + PATTERN_FLAGS=' --pattern **go.mod'                                                                                                                                                                                                                      
  + for p in $*                                                                                                                                                                                                                                              
  + PATTERN_FLAGS=' --pattern **go.mod --pattern **go.sum'                                                                                                                                                                                                   
  + for i in {1..3}                                                                                                                                                                                                                                          
  + /ko-app/cache upload --pattern '**go.mod' --pattern '**go.sum' --target 'oci://image-registry.openshift-image-registry.svc:5000/pipelines-as-code-ci/cache-go:{{hash}}' --folder /workspace/source/go-build-cache --insecure false --workingdir          
  /workspace/source                                                                                                                                                                                                                                          
  Matched the following files: [/workspace/source/docs/go.mod /workspace/source/docs/go.sum /workspace/source/go.mod /workspace/source/go.sum]                                                                                                               
  Upload /workspace/source/go-build-cache content to oci image image-registry.openshift-image-registry.svc:5000/pipelines-as-code-ci/cache-go:22bda2cf0c02b775cfde6d85dc2c7159757db12852e9b04e1c4777911213a1b6 

STEP_CACHE_UPLOAD after:
image

Notice the bool variable being expanded properly and "no need to upload cache" because RESULT_CACHE_FETCHED was true denoting the cache was fetched successfully for this PLR.

@theakshaypant theakshaypant marked this pull request as ready for review March 5, 2026 13:35
@chmouel chmouel merged commit f8814d8 into tektoncd:main Mar 5, 2026
3 checks passed
@theakshaypant theakshaypant deleted the fix-ci-cache-fetch-upload branch March 5, 2026 14:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working ci fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ci: fix go module cache in Tekton pipelines or build a nightly base image

2 participants