Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 42 additions & 18 deletions .github/workflows/ci-complete.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand All @@ -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' }}
Expand All @@ -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' }}
Expand All @@ -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' }}
Expand All @@ -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'