ci: add Tekton Task for /retest slash command#3246
Conversation
|
883ec2b to
9c21872
Compare
|
/assign @savitaashture |
|
Hi @vdemeester , |
| @@ -0,0 +1,166 @@ | |||
| apiVersion: tekton.dev/v1beta1 | |||
There was a problem hiding this comment.
We should use tekton.dev/v1 here instead of v1beta1.
| default: "false" | ||
| steps: | ||
| - name: rerun-failed-checks-and-react | ||
| image: ghcr.io/github/cli/gh:latest |
There was a problem hiding this comment.
ghcr.io/github/cli/gh:latest is Alpine-based. mapfile is a bash builtin not available in Alpine's default /bin/sh. The shebang says #!/usr/bin/env bash but the image may not have bash — only sh/ash.
So this is likely to fail at runtime.
| echo "Starting /retest for ${repo}#${pr}" | ||
|
|
||
| # gh uses GH_TOKEN or GITHUB_TOKEN for authentication. | ||
| if [[ -z "${GH_TOKEN:-${GITHUB_TOKEN:-}}" ]]; then |
There was a problem hiding this comment.
How are those environment variables (GITHUB_TOKEN or GH_TOKTEN) provided ?
| gh api \ | ||
| -X POST \ | ||
| -H "Accept: application/vnd.github+json" \ | ||
| "repos/${repo}/issues/${pr}/reactions" \ |
There was a problem hiding this comment.
This will add a reaction to the PR isn't it ? Not to the comment that issued /retest.
| mapfile -t run_ids < <( | ||
| gh api "repos/${repo}/commits/${sha}/check-runs" --paginate \ | ||
| --jq "${jq_filter} | .external_id // empty" | ||
| ) |
There was a problem hiding this comment.
external_id is not the workflow run ID. GitHub Actions sets external_id to a UUID (e.g., 5cd96773-9f60-588e-974c-6bbce156716f), not the numeric run ID that gh run rerun expects. As a result, the rerun step will silently fail. The run ID can be extracted from details_url instead:
.details_url | capture("runs/(?<id>[0-9]+)") | .idResults should be deduplicated with sort -u since multiple failed jobs within the same workflow share the same run ID.
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Changes
Implements a minimal Tekton Task and Pipeline for the
/retestslash command as part of migrating chatops from GitHub Actions to Tekton (dogfooding cluster).This PR establishes a simple and extensible baseline for
/retestbehavior aligned with the plumbing migration effort.Implementation
Adds a
slash-retestTask attekton/ci/slash-commands/retest-pipeline.yaml.Parameters:
repository: GitHub repository inowner/repoformatpull_request_number: PR number invoking/retestcommit_sha(optional): commit to inspect; if not provided, resolves PR head SHA via GitHub APIcheck_name_prefix(optional): filter failed checks by name prefixdry_run:"true"or"false"(default"false")Behavior:
commit_shais not providedgh apistatus == completed,conclusion == failure)check_name_prefixgh run rerunwhen possibleexternal_idis not available, skips rerun and logs the behaviordry_runmode for safe validation without triggering re-runsPipeline
Adds a
slash-retestPipeline that directly invokes the Task.The Pipeline is designed to be triggered via Tekton Triggers (EventListener → TriggerBinding → TriggerTemplate) from
issue_commentwebhooks.Integration (High-Level)
GitHub
issue_commentwebhook receives/retestTriggerBinding maps:
repository←$(body.repository.full_name)pull_request_number←$(body.issue.number)commit_sha(optional)TriggerTemplate creates a PipelineRun for
slash-retestDesign Notes
ghCLI withGH_TOKEN/GITHUB_TOKENdry_runmode enables safe testing during rolloutThis PR focuses on providing a minimal, functional baseline. Additional refinements (e.g., advanced filtering or extended command support) can be introduced incrementally in follow-up PRs based on feedback.
Related Issues
Fixes #3126
Part of #3121
Release Notes