Uploaded image for project: 'OpenShift Pipelines'
  1. OpenShift Pipelines
  2. SRVKP-8491

PaC does not match label update when label is referenced in on-cel expression

XMLWordPrintable

    • 3
    • False
    • Hide

      None

      Show
      None
    • False
    • Hide
      The fix introduces proper CEL AST (Abstract Syntax Tree) inspection to intelligently handle label events:
      - Moved the on-label check: The check that skips label events for PipelineRuns without an on-label annotation now only applies to non-CEL matching. This allows CEL expressions to handle label events when appropriate.
      - Added CEL AST-based label detection: When a label event occurs and the PipelineRun uses a CEL expression, the code now inspects the AST to determine if the expression explicitly references:
         - event_type (e.g., event_type == "pull_request_labeled")
         - labels or pull_request_labels via dot notation (e.g., body.pull_request.labels)
         - labels or pull_request_labels via bracket notation (e.g., body["labels"])
        If none of these are referenced, CEL returns False immediately, skipping the PipelineRun.
      - Replaced string/regex parsing with AST inspection: The code previously used regexp to detect variable usage. Now it uses proper AST walking for:
         - Detecting target_branch/source_branch usage (for refs/heads/ prefix stripping on push events)
         - Detecting files usage (to avoid unnecessary API calls when files aren't needed)
      Show
      The fix introduces proper CEL AST (Abstract Syntax Tree) inspection to intelligently handle label events: - Moved the on-label check: The check that skips label events for PipelineRuns without an on-label annotation now only applies to non-CEL matching. This allows CEL expressions to handle label events when appropriate. - Added CEL AST-based label detection: When a label event occurs and the PipelineRun uses a CEL expression, the code now inspects the AST to determine if the expression explicitly references:    - event_type (e.g., event_type == "pull_request_labeled")    - labels or pull_request_labels via dot notation (e.g., body.pull_request.labels)    - labels or pull_request_labels via bracket notation (e.g., body["labels"])   If none of these are referenced, CEL returns False immediately, skipping the PipelineRun. - Replaced string/regex parsing with AST inspection: The code previously used regexp to detect variable usage. Now it uses proper AST walking for:    - Detecting target_branch/source_branch usage (for refs/heads/ prefix stripping on push events)    - Detecting files usage (to avoid unnecessary API calls when files aren't needed)
    • Bug Fix
    • Proposed
    • Pipelines Sprint CrookShank 44, Pipelines Sprint CrookShank 45

      Description of problem:

      When a pipelinerun is defined with an on-cel annotation like body.pull_request.labels.exists(l, l == "run-the-test"), the pipelinerun does not run when a maintainer labels the PR with the "run-the-test" label. The on-cel expression is not currently evaluated at all when labels are updated unless the `on-label` annotation is present.

      Workaround

      Adding an on-label annotation to the pipelinerun allows the on-cel expression to be evaluated whenever a label is added. However the on-label annotation has no additional effect since the on-cel annotation means all other "on-*" annotations are ignored.

      Prerequisites (if any, like setup, operators/versions):

      Steps to Reproduce

      • Author a pipelinerun with an annotation like so: {{on-cel: event == "pull_request" && has(body.pull_request.labels) && body.pull_request.labels.exists(l, l.name == "run-the-test")
      • Open a pull request with this pipelinerun
      • Label the pull request with the "run-the-test" label

      Actual results:

      No pipelinerun is run

      Expected results:

      The pipelinerun starts

      Reproducibility (Always/Intermittent/Only Once): alwaus

      Acceptance criteria: 

      • When an on-cel expression references a pull request's labels, changes to the PR labels can start the PLR if the on-cel expression matches
      • (nice to have) in the above event, the PLR is only evaluated if the new label changes the evaluation of the on-cel expression result

      Definition of Done:

      Build Details:

      Additional info (Such as Logs, Screenshots, etc):

       

       *

              rh-ee-akpant Akshay Pant
              rh-ee-athorp Andrew Thorp
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated: