This is an automated email from the ASF dual-hosted git repository.

chia7712 pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/kafka.git


The following commit(s) were added to refs/heads/trunk by this push:
     new 972f32d37e9 KAFKA-19768 Update ci-complete to support branch 4.0 
buildscan upload (#20805)
972f32d37e9 is described below

commit 972f32d37e9130be04b4db8af9f86bbdc7338042
Author: Ming-Yen Chung <[email protected]>
AuthorDate: Wed Apr 15 00:48:47 2026 +0800

    KAFKA-19768 Update ci-complete to support branch 4.0 buildscan upload 
(#20805)
    
    Currently, if we merge to the 4.0 branch, the `CI` workflow in branch
    **`4.0`** will be  triggered. After the 4.0 `CI` finishes, it triggers
    the  `ci-complete.yml` workflow in the **`trunk`** branch. However, the
    JDK  version, Gradle version and the names of the build scan files
    differ  (due to
    [KAFKA-18748](https://issues.apache.org/jira/browse/KAFKA-18748)), so
    the trunk `ci-complete.yml` cannot find the correct BuildScan files
    generated by `4.0` CI workflow to upload to Develocity.
    
    To address this, I added a job in `ci-complete` to first retrieve all
    BuildScan file names that start with `build-scan-`, then create a job
    for each file, extract the java version from the name, and finally
    upload the corresponding BuildScan. The reason I chose not to detect the
    target branch is that this information cannot be obtained from the
    GitHub environment (see details in JIRA
    [KAFKA-19768](https://issues.apache.org/jira/browse/KAFKA-19768)).
    
    There is a potential issue with using Gradle 9 to upload Gradle 8
    buildScan archives to Develocity, I am not sure if it will work because
    I don't have access to a Develocity server to test it. I could only find
    the compatibility table for Develocity plugin and Gradle versions.
    https://docs.gradle.com/develocity/compatibility/#build_scans
    
    I have tested this in my forked repo. There are two `ci-complete` runs
    in the following, one for the `trunk` build, and the other for a PR
    merged into the `4.0` branch. Each run can obtain its corresponding
    BuildScan
    files and execute them. The Gradle task `buildScanPublishPrevious` fails
    as expected due to the lack of a Develocity access token.
    * https://github.com/mingyen066/kafka/actions/runs/19000866672
      * `Found:
    
    
["build-scan-25-noflaky-new","build-scan-17-noflaky-new","build-scan-17-flaky-nonew","build-scan-25-flaky-nonew","build-scan-17-noflaky-nonew","build-scan-25-noflaky-nonew"]`
    * https://github.com/mingyen066/kafka/actions/runs/18999744250
      * `Found:
    
    
["build-scan-quarantined-test-23","build-scan-quarantined-test-17","build-scan-test-23","build-scan-test-17"]`
    
    Reviewers: Chia-Ping Tsai <[email protected]>
---
 .github/workflows/ci-complete.yml | 60 +++++++++++++++++++++++++++------------
 1 file changed, 42 insertions(+), 18 deletions(-)

diff --git a/.github/workflows/ci-complete.yml 
b/.github/workflows/ci-complete.yml
index 3c6d9051029..5421ab56437 100644
--- a/.github/workflows/ci-complete.yml
+++ b/.github/workflows/ci-complete.yml
@@ -32,30 +32,54 @@ run-name: Build Scans for ${{ 
github.event.workflow_run.display_title}}
 # the repository secrets. Here we can download the build scan files produced 
by a PR and publish
 # them to develocity.apache.org.
 #
+# The CI workflow itself runs according to the branch of the PR or push event. 
However, this
+# ci-complete workflow always runs using the trunk branch, regardless of the 
source branch of the
+# CI workflow.
+#
 # If we need to do things like comment on, label, or otherwise modify PRs from 
public forks. This
 # workflow is the place to do it. PR number is ${{ 
github.event.workflow_run.pull_requests[0].number }}
 
 jobs:
+  get-build-scan-names:
+    if: (github.event.workflow_run.conclusion == 'success' || 
github.event.workflow_run.conclusion == 'failure')
+    runs-on: ubuntu-latest
+    outputs:
+      build-scan-names: ${{ steps.build-scan-names.outputs.build-scan-names }}
+    steps:
+      - name: List buildscan artifacts
+        id: build-scan-names
+        env:
+          GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+          RUN_ID: ${{ github.event.workflow_run.id }}
+        run: |
+          names=$(gh api \
+            -H "Accept: application/vnd.github+json" \
+            /repos/${{ github.repository }}/actions/runs/$RUN_ID/artifacts \
+            --jq '[.artifacts[] | select(.name | startswith("build-scan-")) | 
.name]')
+          echo "Found: $names"
+
+          echo "build-scan-names=$names" >> $GITHUB_OUTPUT
+
   upload-build-scan:
+    needs: get-build-scan-names
     # Skip this workflow if the CI run was skipped or cancelled
     if: (github.event.workflow_run.conclusion == 'success' || 
github.event.workflow_run.conclusion == 'failure')
     runs-on: ubuntu-latest
     strategy:
       fail-fast: false
       matrix:
-        # Make sure these match build.yml and also keep in mind that GitHub 
Actions build will always use this file from the trunk branch.
-        java: [ 25, 17 ]
-        run-flaky: [ true, false ]
-        run-new: [ true, false ]
-        exclude:
-          - run-flaky: true
-            run-new: true
-
-    env:
-      job-variation: ${{ matrix.java }}-${{ matrix.run-flaky == true && 
'flaky' || 'noflaky' }}-${{ matrix.run-new == true && 'new' || 'nonew' }}
-      status-context: Java ${{ matrix.java }}${{ matrix.run-flaky == true && ' 
/ Flaky' || '' }}${{ matrix.run-new == true && ' / New' || '' }}
-
+        build-scan-name: ${{ 
fromJson(needs.get-build-scan-names.outputs.build-scan-names) }}
     steps:
+      - name: Setup build scan info
+        run: |
+          BUILD_SCAN_NAME="${{ matrix.build-scan-name }}"
+          JAVA=$(echo "$BUILD_SCAN_NAME" | grep -oE '[0-9]+')
+          STATUS_CONTEXT="Java $JAVA"
+          [[ "$BUILD_SCAN_NAME" == *"-flaky"* ]] && 
STATUS_CONTEXT="$STATUS_CONTEXT / Flaky"
+          [[ "$BUILD_SCAN_NAME" == *"-new"* ]] && 
STATUS_CONTEXT="$STATUS_CONTEXT / New"
+
+          echo "JAVA=$JAVA" >> $GITHUB_ENV
+          echo "STATUS_CONTEXT=$STATUS_CONTEXT" >> $GITHUB_ENV
       - name: Env
         run: printenv
         env:
@@ -68,7 +92,7 @@ jobs:
       - name: Setup Gradle
         uses: ./.github/actions/setup-gradle
         with:
-          java-version: ${{ matrix.java }}
+          java-version: ${{ env.JAVA }}
           develocity-access-key: ${{ secrets.DEVELOCITY_ACCESS_KEY }}
       - name: Download build scan archive
         id: download-build-scan
@@ -77,7 +101,7 @@ jobs:
         with:
           github-token: ${{ github.token }}
           run-id: ${{ github.event.workflow_run.id }}
-          name: build-scan-${{ env.job-variation }}
+          name: ${{ matrix.build-scan-name }}
           path: ~/.gradle/build-scan-data  # This is where Gradle buffers 
unpublished build scan data when --no-scan is given
       - name: Handle missing scan
         if: ${{ steps.download-build-scan.outcome == 'failure' }}
@@ -88,8 +112,8 @@ jobs:
           commit_sha: ${{ github.event.workflow_run.head_sha }}
           url: '${{ github.event.workflow_run.html_url }}'
           description: 'Could not find build scan'
-          context: Gradle Build Scan / ${{ env.status-context }}
-          state: 'success' # Always mark as successful as a temporary fix; 
non-trunk branches will miss build scan. Real fix in KAFKA-19768
+          context: Gradle Build Scan / ${{ env.STATUS_CONTEXT }}
+          state: 'error'
       - name: Publish Scan
         id: publish-build-scan
         if: ${{ steps.download-build-scan.outcome == 'success' }}
@@ -116,7 +140,7 @@ jobs:
           commit_sha: ${{ github.event.workflow_run.head_sha }}
           url: '${{ github.event.repository.html_url }}/actions/runs/${{ 
github.run_id }}'
           description: 'The build scan failed to be published'
-          context: Gradle Build Scan / ${{ env.status-context }}
+          context: Gradle Build Scan / ${{ env.STATUS_CONTEXT }}
           state: 'error'
       - name: Update Status Check
         if: ${{ steps.publish-build-scan.outcome == 'success' }}
@@ -127,5 +151,5 @@ jobs:
           commit_sha: ${{ github.event.workflow_run.head_sha }}
           url: ${{ steps.publish-build-scan.outputs.build-scan-url }}
           description: 'The build scan was successfully published'
-          context: Gradle Build Scan / ${{ env.status-context }}
+          context: Gradle Build Scan / ${{ env.STATUS_CONTEXT }}
           state: 'success'

Reply via email to