Repository: PingCAP-QE/ee-ops
Pull request #1522: feat(apps/prod/tekton/configs/triggers): add and update triggers for next-gen branch builds
Author: login: wuhuizuo
Labels: name: approved
name: size/M
name: env/prod
description: will deploy on the main product cluster
name: area/apps
Created: 2025-05-28T03:33:23Z | Merged: 2025-05-28T03:45:04Z

Close PingCAP-QE/ci#3536
Close PingCAP-QE/ci#3543

## Changes
- Add triggers for pingcap/tidb, pingcap/tiflash, and tikv/pd branch builds
- Update kustomization.yaml to reference new trigger files
- Rename and update trigger files for consistency and next-gen support


Diff:
diff --git a/apps/prod/tekton/configs/triggers/triggers/kustomization.yaml b/apps/prod/tekton/configs/triggers/triggers/kustomization.yaml
index 11e299259..c2fe7fc99 100644
--- a/apps/prod/tekton/configs/triggers/triggers/kustomization.yaml
+++ b/apps/prod/tekton/configs/triggers/triggers/kustomization.yaml
@@ -31,15 +31,16 @@ resources:
   - pingcap/tidb-operator/git-push.yaml
   - pingcap/tidb-tools/git-create-tag.yaml
   - pingcap/tidb-tools/git-push.yaml
-  - pingcap/tidb/git-push.yaml
+  - pingcap/tidb/git-push-branch-build.yaml
+  - pingcap/tiflash/git-push-branch-build.yaml
   - pingcap/tiflow-operator/git-create-tag.yaml
   - pingcap/tiflow-operator/git-push.yaml
   - pingcap/tiproxy/git-create-tag.yaml
   - pingcap/tiproxy/git-push.yaml
   - tidbcloud/cloud-storage-engine/git-push-branch-build.yaml
-  - tidbcloud/tiflash-cse/git-push-branch-build.yaml
   - tikv/_/git-push-branch-build-community.yaml
   - tikv/_/git-push-branch-build-enterprise.yaml
   - tikv/_/git-push-branch-build-failpoint.yaml
+  - tikv/pd/git-push-branch-build.yaml
   - tikv/tikv/git-create-branch.yaml
   - tikv/tikv/git-create-tag.yaml
diff --git a/apps/prod/tekton/configs/triggers/triggers/pingcap/tidb/git-push.yaml b/apps/prod/tekton/configs/triggers/triggers/pingcap/tidb/git-push-branch-build.yaml
similarity index 51%
rename from apps/prod/tekton/configs/triggers/triggers/pingcap/tidb/git-push.yaml
rename to apps/prod/tekton/configs/triggers/triggers/pingcap/tidb/git-push-branch-build.yaml
index 0022f786e..e1fade63d 100644
--- a/apps/prod/tekton/configs/triggers/triggers/pingcap/tidb/git-push.yaml
+++ b/apps/prod/tekton/configs/triggers/triggers/pingcap/tidb/git-push-branch-build.yaml
@@ -1,8 +1,39 @@
+apiVersion: triggers.tekton.dev/v1beta1
+kind: Trigger
+metadata:
+  name: github-push-tidb-build-next-gen
+  labels:
+    type: github-branch-push
+    github-owner: pingcap
+    profile: next-gen
+spec:
+  interceptors:
+    - name: filter on repo
+      ref: { name: cel }
+      params:
+        - name: filter
+          value: >-
+            body.repository.full_name == 'pingcap/tidb'
+            &&
+            body.ref.matches('^refs/heads/(master|feature/next-gen.*)$')
+
+  bindings:
+    - ref: github-branch-push
+    - { name: component, value: $(body.repository.name) }
+    - { name: os, value: linux }
+    - { name: profile, value: next-gen }
+    - { name: timeout, value: 45m }
+    - { name: source-ws-size, value: 50Gi }
+    - { name: builder-resources-memory, value: 32Gi }
+    - { name: builder-resources-cpu, value: "8" }
+  template:
+    ref: build-component
+
 ---
 apiVersion: triggers.tekton.dev/v1beta1
 kind: Trigger
 metadata:
-  name: git-push-pingcap-tidb-enterprise-without-plugins
+  name: git-push-pingcap-tidb-build-enterprise-without-plugins
   labels:
     type: github-branch-push
     github-owner: pingcap
diff --git a/apps/prod/tekton/configs/triggers/triggers/tidbcloud/tiflash-cse/git-push-branch-build.yaml b/apps/prod/tekton/configs/triggers/triggers/pingcap/tiflash/git-push-branch-build.yaml
similarity index 69%
rename from apps/prod/tekton/configs/triggers/triggers/tidbcloud/tiflash-cse/git-push-branch-build.yaml
rename to apps/prod/tekton/configs/triggers/triggers/pingcap/tiflash/git-push-branch-build.yaml
index ea0a0aca2..88f688b17 100644
--- a/apps/prod/tekton/configs/triggers/triggers/tidbcloud/tiflash-cse/git-push-branch-build.yaml
+++ b/apps/prod/tekton/configs/triggers/triggers/pingcap/tiflash/git-push-branch-build.yaml
@@ -1,10 +1,10 @@
 apiVersion: triggers.tekton.dev/v1beta1
 kind: Trigger
 metadata:
-  name: github-push-tiflash-cse-build
+  name: github-push-tiflash-build-next-gen
   labels:
     type: github-branch-push
-    github-owner: tidbcloud
+    github-owner: pingcap
     profile: next-gen
 spec:
   interceptors:
@@ -13,13 +13,13 @@ spec:
       params:
         - name: filter
           value: >-
-            body.repository.full_name == 'tidbcloud/tiflash-cse'
+            body.repository.full_name == 'pingcap/tiflash'
             &&
-            body.ref.matches('^refs/heads/(cloud-engine-on-release-8.5)$')
+            body.ref.matches('^refs/heads/(feature/next-gen)$')
 
   bindings:
     - ref: github-branch-push
-    - { name: component, value: tiflash }
+    - { name: component, value: $(body.repository.name) }
     - { name: profile, value: next-gen }
     - { name: timeout, value: 2h }
     - { name: source-ws-size, value: 100Gi }
diff --git a/apps/prod/tekton/configs/triggers/triggers/tikv/pd/git-push-branch-build.yaml b/apps/prod/tekton/configs/triggers/triggers/tikv/pd/git-push-branch-build.yaml
new file mode 100644
index 000000000..6af1c6982
--- /dev/null
+++ b/apps/prod/tekton/configs/triggers/triggers/tikv/pd/git-push-branch-build.yaml
@@ -0,0 +1,30 @@
+apiVersion: triggers.tekton.dev/v1beta1
+kind: Trigger
+metadata:
+  name: github-push-pd-build-next-gen
+  labels:
+    type: github-branch-push
+    github-owner: tikv
+    profile: next-gen
+spec:
+  interceptors:
+    - name: filter on repo
+      ref: { name: cel }
+      params:
+        - name: filter
+          value: >-
+            body.repository.full_name == 'tikv/pd'
+            &&
+            body.ref.matches('^refs/heads/(master)$')
+
+  bindings:
+    - ref: github-branch-push
+    - { name: component, value: $(body.repository.name) }
+    - { name: profile, value: next-gen }
+    - { name: timeout, value: 40m }
+    - { name: source-ws-size, value: 50Gi }
+    - { name: builder-resources-cpu, value: "8" }
+    - { name: builder-resources-memory, value: "32Gi" }
+
+  template:
+    ref: build-component


Reviews:
user: login: gemini-code-assist[bot]
body: Hello @wuhuizuo, I'm Gemini Code Assist[^1]! 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!

## Summary of Changes
Hello team, gemini-code-assist here to provide a summary of this pull request. This PR focuses on enhancing our Tekton CI/CD setup by adding and updating triggers specifically for branch builds related to the "next-gen" profile for key repositories: `pingcap/tidb`, `pingcap/tiflash`, and `tikv/pd`. The changes involve introducing new trigger configurations, modifying existing ones for consistency and correct targeting, and updating the central `kustomization.yaml` file to ensure these new configurations are included in our deployment.

### Highlights
* **New Branch Build Triggers**: Adds new Tekton Trigger configurations to enable automated branch builds for `pingcap/tidb`, `pingcap/tiflash`, and `tikv/pd` repositories, specifically targeting branches relevant to the 'next-gen' profile.
* **Kustomization Update**: Updates the `kustomization.yaml` file to reference the newly added and updated trigger configuration files, ensuring they are part of the deployed Tekton configuration.
* **Trigger Configuration Refinement**: Modifies existing trigger files (or creates new versions) to standardize naming, update repository and branch filtering logic, and adjust bindings for components and resources, aligning them with the requirements for next-gen branch builds.

### Changelog
<details>
<summary>Click here to see the changelog</summary>

* **apps/prod/tekton/configs/triggers/triggers/kustomization.yaml**
  * Replaced reference to `pingcap/tidb/git-push.yaml` with `pingcap/tidb/git-push-branch-build.yaml`.
  * Added reference to `pingcap/tiflash/git-push-branch-build.yaml`.
  * Removed reference to `tidbcloud/tiflash-cse/git-push-branch-build.yaml`.
  * Added reference to `tikv/pd/git-push-branch-build.yaml`.
* **apps/prod/tekton/configs/triggers/triggers/pingcap/tidb/git-push-branch-build.yaml**
  * Added a new Tekton Trigger definition (`github-push-tidb-build-next-gen`) configured to trigger on pushes to `master` or `feature/next-gen*` branches in the `pingcap/tidb` repository, using the `next-gen` profile.
  * Renamed the existing trigger within this file from `git-push-pingcap-tidb-enterprise-without-plugins` to `git-push-pingcap-tidb-build-enterprise-without-plugins`.
* **apps/prod/tekton/configs/triggers/triggers/pingcap/tiflash/git-push-branch-build.yaml**
  * Renamed the trigger from `github-push-tiflash-cse-build` to `github-push-tiflash-build-next-gen`.
  * Updated the `github-owner` label from `tidbcloud` to `pingcap`.
  * Modified the trigger filter to target `pingcap/tiflash` on the `feature/next-gen` branch (previously `tidbcloud/tiflash-cse` on `cloud-engine-on-release-8.5`).
  * Changed the `component` binding to use the repository name variable `$(body.repository.name)`.
* **apps/prod/tekton/configs/triggers/triggers/tikv/pd/git-push-branch-build.yaml**
  * Added a new file defining a Tekton Trigger (`github-push-cloud-storage-engine-build`) configured to trigger on pushes to the `master` branch in the `tikv/pd` repository, using the `next-gen` profile.

</details>


<details>

<summary><b>Using Gemini Code Assist</b></summary>
<br>

The full guide for Gemini Code Assist can be found on our [documentation page](https://developers.google.com/gemini-code-assist/docs/review-github-code), here are some quick tips.

<b>Invoking Gemini</b>

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either `/gemini <command>` or `@gemini-code-assist <command>`. Below is a summary of the supported commands.

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 issue comments and review comments.
Help | `/gemini help` | Displays a list of available commands.

<b>Customization</b>

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](https://developers.google.com/gemini-code-assist/docs/customize-gemini-behavior-github).

<b>Limitations & Feedback</b>

Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with :thumbsup: and :thumbsdown: on @gemini-code-assist comments to provide feedback.

</details>

<b>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](https://cloud.google.com/products/gemini/code-assist).</b>


[^1]: Review the [Privacy Notices](https://policies.google.com/privacy), [Generative AI Prohibited Use Policy](https://policies.google.com/terms/generative-ai/use-policy), [Terms of Service](https://policies.google.com/terms), and learn how to configure Gemini Code Assist in GitHub [here](https://developers.google.com/gemini-code-assist/docs/review-github-code). Gemini can make mistakes, so double check it and [use code with caution](https://support.google.com/legal/answer/13505487).

---

> Push code, trigger runs,
> Tekton builds the branch bright,
> Next-gen is the goal.


state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-05-28T03:34:03Z
user: login: gemini-code-assist[bot]
body: ## Code Review
The pull request successfully adds and updates Tekton triggers to support branch builds for `pingcap/tidb`, `pingcap/tiflash`, and `tikv/pd` repositories with a 'next-gen' profile. The changes align with the stated objectives of closing the linked issues and updating the kustomization file accordingly. The use of the shared `build-component` template and `github-branch-push` binding promotes consistency.

### Summary of Findings
* **Incorrect Trigger Name**: The trigger name in `tikv/pd/git-push-branch-build.yaml` appears to be copied from another trigger and does not reflect the repository it is intended for. This is a high severity issue that should be corrected.
* **Potentially Restrictive Branch Regex**: The branch filter regex for the tiflash trigger is very specific (`feature/next-gen`), unlike the tidb trigger which allows for suffixes (`feature/next-gen.*`). This might be intentional, but could prevent the trigger from firing on related `next-gen` branches in the future. This is a medium severity issue.
* **Hardcoded Resource Values**: Specific resource values (timeout, workspace size, CPU, memory) are hardcoded in the trigger definitions. While the `build-component` template supports parameters for these, they are set directly in the trigger. This is acceptable but could be made more flexible by passing them as parameters if needed in the future. (Not commented on per review settings).

### Merge Readiness
The changes introduce the necessary Tekton triggers for the next-gen branch builds. However, there is a high severity issue regarding an incorrect trigger name in the `tikv/pd` file that needs to be addressed before merging. Additionally, consider the medium severity point about the tiflash branch regex. I am unable to approve this pull request, please have other reviewers review and approve this code before merging.
state: CHANGES_REQUESTED
author_association: CONTRIBUTOR
submitted_at: 2025-05-28T03:34:50Z

Review comments:
diff_hunk: @@ -0,0 +1,30 @@
+apiVersion: triggers.tekton.dev/v1beta1
+kind: Trigger
+metadata:
+  name: github-push-cloud-storage-engine-build
path: apps/prod/tekton/configs/triggers/triggers/tikv/pd/git-push-branch-build.yaml
user: login: gemini-code-assist[bot]
body: ![high](https://img.shields.io/badge/priority-high-orange)

The trigger name `github-push-cloud-storage-engine-build` seems incorrect for a trigger intended for the `tikv/pd` repository. It appears to be a leftover name from another trigger (likely `tidbcloud/cloud-storage-engine`). Could you please update it to reflect the repository and profile, similar to the other new triggers (e.g., `github-push-pd-build-next-gen`)?

```
name: github-push-pd-build-next-gen
```
created_at: 2025-05-28T03:34:50Z
author_association: CONTRIBUTOR
diff_hunk: @@ -13,13 +13,13 @@ spec:
       params:
         - name: filter
           value: >-
-            body.repository.full_name == 'tidbcloud/tiflash-cse'
+            body.repository.full_name == 'pingcap/tiflash'
             &&
-            body.ref.matches('^refs/heads/(cloud-engine-on-release-8.5)$')
+            body.ref.matches('^refs/heads/(feature/next-gen)$')
path: apps/prod/tekton/configs/triggers/triggers/pingcap/tiflash/git-push-branch-build.yaml
user: login: gemini-code-assist[bot]
body: ![medium](https://img.shields.io/badge/priority-medium-yellow)

The branch filter regex `^refs/heads/(feature/next-gen)$` is very specific, only matching the exact branch name `feature/next-gen`. The tidb trigger added in this PR uses `^refs/heads/(master|feature/next-gen.*)$` which allows for suffixes on `feature/next-gen` branches. Is it intentional that the tiflash trigger only matches the exact `feature/next-gen` branch? If other `next-gen` related branches might exist in the future (e.g., `feature/next-gen-v1`), you might want to adjust the regex to be more flexible, perhaps similar to the tidb one.

```
body.ref.matches('^refs/heads/(feature/next-gen.*)$')
```
created_at: 2025-05-28T03:34:50Z
author_association: CONTRIBUTOR

PR comments:
user: login: ti-chi-bot[bot]
created_at: 2025-05-28T03:33:29Z
body: > **I have already done a preliminary review for you, and I hope to help you do a better job.**

**Summary:**
The pull request adds and updates triggers for branch builds in the `apps/prod/tekton/configs/triggers` directory. Triggers for various components like `pingcap/tidb`, `pingcap/tiflash`, and `tikv/pd` have been added or modified for consistency and next-gen support. The changes include adding new trigger files, updating `kustomization.yaml` to reference the new trigger files, and renaming existing trigger files.

**Critical Issues:**
None identified.

**Code Improvements:**
1. **File: apps/prod/tekton/configs/triggers/triggers/kustomization.yaml**
   - **Issue:** In the `kustomization.yaml` file, there are references to removed trigger files like `tidbcloud/tiflash-cse/git-push-branch-build.yaml`.
   - **Suggested Solution:** Remove references to the removed trigger files to keep the configuration in sync with the actual trigger files available.

**Best Practices:**
1. **File: apps/prod/tekton/configs/triggers/triggers/kustomization.yaml (lines 31-39)**
   - **Issue:** Lack of documentation explaining the purpose of each trigger or the reason behind the changes.
   - **Suggested Solution:** Add comments or documentation above each trigger specifying the component it relates to and any relevant details. This will help in understanding the purpose of each trigger without needing to dive into the details.

Overall, the changes look good, but it's essential to keep configuration files like `kustomization.yaml` updated to prevent any inconsistencies. Additionally, adding documentation to explain the purpose of triggers can improve maintainability and understanding for future developers working on the codebase.
author_association: CONTRIBUTOR
user: login: ti-chi-bot[bot]
created_at: 2025-05-28T03:34:51Z
body: @gemini-code-assist[bot]: changing LGTM is restricted to collaborators

<details>

In response to [this](https://github.com/PingCAP-QE/ee-ops/pull/1522#pullrequestreview-2873450810):

>## Code Review
>The pull request successfully adds and updates Tekton triggers to support branch builds for `pingcap/tidb`, `pingcap/tiflash`, and `tikv/pd` repositories with a 'next-gen' profile. The changes align with the stated objectives of closing the linked issues and updating the kustomization file accordingly. The use of the shared `build-component` template and `github-branch-push` binding promotes consistency.
>
>### Summary of Findings
>* **Incorrect Trigger Name**: The trigger name in `tikv/pd/git-push-branch-build.yaml` appears to be copied from another trigger and does not reflect the repository it is intended for. This is a high severity issue that should be corrected.
>* **Potentially Restrictive Branch Regex**: The branch filter regex for the tiflash trigger is very specific (`feature/next-gen`), unlike the tidb trigger which allows for suffixes (`feature/next-gen.*`). This might be intentional, but could prevent the trigger from firing on related `next-gen` branches in the future. This is a medium severity issue.
>* **Hardcoded Resource Values**: Specific resource values (timeout, workspace size, CPU, memory) are hardcoded in the trigger definitions. While the `build-component` template supports parameters for these, they are set directly in the trigger. This is acceptable but could be made more flexible by passing them as parameters if needed in the future. (Not commented on per review settings).
>
>### Merge Readiness
>The changes introduce the necessary Tekton triggers for the next-gen branch builds. However, there is a high severity issue regarding an incorrect trigger name in the `tikv/pd` file that needs to be addressed before merging. Additionally, consider the medium severity point about the tiflash branch regex. I am unable to approve this pull request, please have other reviewers review and approve this code before merging.


Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md).  If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes-sigs/prow](https://github.com/kubernetes-sigs/prow/issues/new?title=Prow%20issue:) repository.
</details>
author_association: CONTRIBUTOR
user: login: ti-chi-bot[bot]
created_at: 2025-05-28T03:36:23Z
body: > **I have already done a preliminary review for you, and I hope to help you do a better job.**

**Summary:**
The pull request aims to add and update triggers for next-gen branch builds for various components like `pingcap/tidb`, `pingcap/tiflash`, and `tikv/pd`. The changes involve adding new trigger files, updating `kustomization.yaml`, and renaming existing trigger files for consistency and next-gen support. The approach taken seems straightforward and the overall quality of the changes appears good.

**Critical Issues:**
- No critical issues found in the provided diff.

**Code Improvements:**
- **Naming Consistency in Trigger Files**:
  - File: `apps/prod/tekton/configs/triggers/triggers/kustomization.yaml`
  - Inconsistency in naming conventions for trigger files like `git-push.yaml` being renamed to `git-push-branch-build.yaml`. It's good to maintain naming consistency for better clarity and organization.
  - *Suggested Solution*: Ensure consistent naming conventions for trigger files to improve maintainability.
  
**Best Practices:**
- **Documentation for Triggers**:
  - It would be beneficial to add comments/documentation within the trigger files to explain their purpose, usage, and any important details for future developers or maintainers.
  - *Suggested Solution*: Add comments at the beginning of each trigger file explaining what the trigger does, any dependencies, and how it should be used.
  
- **Testing Coverage**:
  - Ensure that these trigger changes are appropriately tested to verify their functionality and interactions with other components.
  - *Suggested Solution*: Include tests for the triggers to cover different scenarios and ensure they work as expected.

By addressing the naming consistency and adding documentation for the triggers, the codebase can become more maintainable and easier to understand for developers working on these triggers in the future. Additionally, thorough testing will ensure the reliability of the trigger functionality.
author_association: CONTRIBUTOR
user: login: wuhuizuo
created_at: 2025-05-28T03:40:37Z
body: /approve
author_association: COLLABORATOR
user: login: ti-chi-bot[bot]
created_at: 2025-05-28T03:40:41Z
body: [APPROVALNOTIFIER] This PR is **APPROVED**

This pull-request has been approved by: *<a href="https://github.com/PingCAP-QE/ee-ops/pull/1522#issuecomment-2914798596" title="Approved">wuhuizuo</a>*

The full list of commands accepted by this bot can be found [here](https://prow.tidb.net/command-help?repo=PingCAP-QE%2Fee-ops).

The pull request process is described [here](https://book.prow.tidb.net/#/workflows/pr)

<details >
Needs approval from an approver in each of these files:

- ~~[apps/prod/OWNERS](https://github.com/PingCAP-QE/ee-ops/blob/main/apps/prod/OWNERS)~~ [wuhuizuo]

Approvers can indicate their approval by writing `/approve` in a comment
Approvers can cancel approval by writing `/approve cancel` in a comment
</details>
<!-- META={"approvers":[]} -->
author_association: CONTRIBUTOR