From 0d98bd96d6e973ebd1849d5b2ba8222c2f7a89a3 Mon Sep 17 00:00:00 2001 From: Ming-Yen Chung Date: Wed, 22 Oct 2025 21:22:06 +0800 Subject: [PATCH 1/3] Make ci-complete support 4.0 buildscan --- .github/workflows/ci-complete.yml | 55 +++++++++++++++++++++---------- 1 file changed, 38 insertions(+), 17 deletions(-) diff --git a/.github/workflows/ci-complete.yml b/.github/workflows/ci-complete.yml index 3c6d905102974..f8df6bf9e21ee 100644 --- a/.github/workflows/ci-complete.yml +++ b/.github/workflows/ci-complete.yml @@ -36,26 +36,47 @@ run-name: Build Scans for ${{ github.event.workflow_run.display_title}} # 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') + if: github.event.workflow_run.conclusion == 'success' || github.event.workflow_run.conclusion == 'failure' runs-on: ubuntu-latest strategy: fail-fast: false matrix: + build-scan-name: ${{ fromJson(needs.get-build-scan-names.outputs.build-scan-names) }} # 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' || '' }} - 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 +89,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 +98,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,7 +109,7 @@ 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 }} + 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 - name: Publish Scan id: publish-build-scan @@ -116,7 +137,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 +148,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' From da6a43f4662f46ff96a8122936afc5ba4f288c38 Mon Sep 17 00:00:00 2001 From: Ming-Yen Chung Date: Sun, 2 Nov 2025 16:08:25 +0800 Subject: [PATCH 2/3] Fix condition --- .github/workflows/ci-complete.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci-complete.yml b/.github/workflows/ci-complete.yml index f8df6bf9e21ee..2ccb6fff0a580 100644 --- a/.github/workflows/ci-complete.yml +++ b/.github/workflows/ci-complete.yml @@ -37,7 +37,7 @@ run-name: Build Scans for ${{ github.event.workflow_run.display_title}} jobs: get-build-scan-names: - if: github.event.workflow_run.conclusion == 'success' || github.event.workflow_run.conclusion == 'failure' + 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 }} @@ -59,7 +59,7 @@ jobs: 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' + if: (github.event.workflow_run.conclusion == 'success' || github.event.workflow_run.conclusion == 'failure') runs-on: ubuntu-latest strategy: fail-fast: false @@ -110,7 +110,7 @@ jobs: 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 + state: 'error' - name: Publish Scan id: publish-build-scan if: ${{ steps.download-build-scan.outcome == 'success' }} From 2a0fe464acfeaf60878ce7732b841ab11c3ca44a Mon Sep 17 00:00:00 2001 From: Ming-Yen Chung Date: Sun, 2 Nov 2025 16:17:42 +0800 Subject: [PATCH 3/3] Added comments to explain that the ci-complete workflow always runs using the trunk branch --- .github/workflows/ci-complete.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci-complete.yml b/.github/workflows/ci-complete.yml index 2ccb6fff0a580..5421ab5643744 100644 --- a/.github/workflows/ci-complete.yml +++ b/.github/workflows/ci-complete.yml @@ -32,6 +32,10 @@ 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 }} @@ -65,7 +69,6 @@ jobs: fail-fast: false matrix: build-scan-name: ${{ fromJson(needs.get-build-scan-names.outputs.build-scan-names) }} - # Make sure these match build.yml and also keep in mind that GitHub Actions build will always use this file from the trunk branch. steps: - name: Setup build scan info run: |