Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
8ae831d
Capture URL
mumrah Sep 9, 2024
b4c5a45
shorten the CI
mumrah Sep 9, 2024
9f3c9c6
only run for PRs
mumrah Sep 9, 2024
0ae0550
Fix env
mumrah Sep 9, 2024
e149058
fix whitespace
mumrah Sep 9, 2024
fd4349d
add a comment
mumrah Sep 9, 2024
93fa110
fix comment
mumrah Sep 9, 2024
aa28cc5
one comment for both scans
mumrah Sep 9, 2024
f7b24f0
fix quote
mumrah Sep 9, 2024
0346b06
use status check
mumrah Sep 9, 2024
01a739e
empty
mumrah Sep 9, 2024
31ec37b
fix outputs
mumrah Sep 9, 2024
0341fdd
update workflow
mumrah Sep 9, 2024
beeb8e1
try composite action
mumrah Sep 9, 2024
5cee8ff
Merge branch 'mumrah-trunk' into gh-test-build-scan-comment
mumrah Sep 9, 2024
6ca348c
fix workflow
mumrah Sep 9, 2024
aacd31b
pass token
mumrah Sep 9, 2024
c72d7da
fix state
mumrah Sep 9, 2024
363a96e
fix state value
mumrah Sep 9, 2024
0a34da8
clear check before run
mumrah Sep 9, 2024
f8ca2a0
Merge branch 'mumrah-trunk' into gh-test-build-scan-comment
mumrah Sep 9, 2024
d6e72df
only clear the check in test job
mumrah Sep 9, 2024
8a864a2
Merge branch 'mumrah-trunk' into gh-test-build-scan-comment
mumrah Sep 9, 2024
ca8ffb4
add failure check
mumrah Sep 9, 2024
ee781a4
fix syntax
mumrah Sep 9, 2024
e2bb9f5
add url for failure
mumrah Sep 9, 2024
a8e211e
remove failure
mumrah Sep 9, 2024
654acaf
empty
mumrah Sep 9, 2024
f3fa9c4
Merge branch 'mumrah-trunk' into gh-test-build-scan-comment
mumrah Sep 9, 2024
6cfcdcb
run full tests
mumrah Sep 9, 2024
de87548
add step conditions
mumrah Sep 9, 2024
8c0ca40
simulate failure
mumrah Sep 9, 2024
eb3a652
add conditions to steps
mumrah Sep 9, 2024
6f1bfad
add summary
mumrah Sep 9, 2024
812c731
Merge branch 'mumrah-trunk' into gh-test-build-scan-comment
mumrah Sep 9, 2024
89396ae
remove failure
mumrah Sep 9, 2024
e18df31
simulate failure
mumrah Sep 9, 2024
27ad4d9
remove failure
mumrah Sep 9, 2024
fcbe54f
Merge branch 'mumrah-trunk' into gh-test-build-scan-comment
mumrah Sep 9, 2024
748909a
run all tests
mumrah Sep 9, 2024
0a1423e
cat the gradle stdout
mumrah Sep 9, 2024
c745f11
PR feedback
mumrah Sep 9, 2024
3896ab0
Merge remote-tracking branch 'origin/trunk' into gh-test-build-scan-c…
mumrah Sep 9, 2024
f17700e
more PR feedback
mumrah Sep 9, 2024
93a9216
missed slash
mumrah Sep 9, 2024
a7e801f
document no-scan
mumrah Sep 9, 2024
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
58 changes: 58 additions & 0 deletions .github/actions/gh-api-update-status/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#
---
name: "Update Commit Status Check"
description: "Update the status of a commit check using the GH CLI"
inputs:
gh-token:
description: "The GitHub token for use with the CLI"
required: true
repository:
description: "The repository where the commit is located"
default: "apache/kafka"
commit_sha:
description: "The SHA of the commit we are updating"
required: true
url:
description: "The URL of the status check"
required: false
default: ""
description:
description: "The text to display next to the check"
default: ""
required: false
context:
description: "The name of the status check"
required: true
state:
description: "The state of the check. Can be one of: error, failure, pending, success"
required: true

runs:
using: "composite"
steps:
- name: Update Check
shell: bash
env:
GH_TOKEN: ${{ inputs.gh-token }}
run: |
gh api --method POST -H "Accept: application/vnd.github+json" -H "X-GitHub-Api-Version: 2022-11-28" \
/repos/${{ inputs.repository }}/statuses/${{ inputs.commit_sha }} \
-f "state=${{ inputs.state }}" -f "target_url=${{ inputs.url }}" \
-f "description=${{ inputs.description }}" \
-f "context=${{ inputs.context }}"
10 changes: 7 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,12 @@ jobs:
# Gradle flags
# --build-cache: Let Gradle restore the build cache
# --info: For now, we'll generate lots of logs while setting up the GH Actions
# --scan: Attempt to publish build scans in PRs. This will only work on PRs from apache/kafka, not public forks.
run: ./gradlew --build-cache --info --scan check -x test
# --scan: Publish the build scan. This will only work on PRs from apache/kafka and trunk
# --no-scan: For public fork PRs, we won't attempt to publish the scan
run: |
./gradlew --build-cache --info \
${{ inputs.is-public-fork == 'true' && '--no-scan' || '--scan' }} \
check -x test
- name: Archive check reports
if: always()
uses: actions/upload-artifact@v4
Expand All @@ -85,7 +89,7 @@ jobs:
strategy:
fail-fast: false
matrix:
java: [ 17, 11 ]
java: [ 17, 11 ] # If we change these, make sure to adjust ci-complete.yml
name: JUnit tests Java ${{ matrix.java }}
steps:
- name: Checkout code
Expand Down
65 changes: 59 additions & 6 deletions .github/workflows/ci-complete.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,30 @@ on:
types:
- completed

run-name: Build Scans for ${{ github.event.workflow_run.display_title}}

# This workflow runs after the completion of the CI workflow triggered on a "pull_request" event.
# The "pull_request" event type is run in an unprivileged context without access to the repository
# secrets. This means that PRs from public forks cannot publish Gradle Build Scans or modify the
# PR contents.
#
# This "workflow_run" triggered workflow is run in a privileged context and so does have access to
# the repository secrets. Here we can download the build scan files produced by a PR and publish
# them to ge.apache.org.
#
# 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:
upload-build-scan:
if: ${{ github.event.workflow_run.head_repository.full_name != 'apache/kafka' }}
# Skip this workflow if CI was run for anything other than "pull_request" (like "push").
# Also skip this workflow if the PR was from apache/kafka. Those will have already published the build scan in CI.
if: ${{ github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.head_repository.full_name != 'apache/kafka' }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
java: [ 21, 17, 11, 8 ]
java: [ 17, 11 ]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please comment to https://github.com/apache/kafka/blob/trunk/.github/workflows/build.yml#L88 to remind that we need to keep the JDK consistency.

steps:
- name: Env
run: printenv
Expand All @@ -44,11 +60,48 @@ jobs:
with:
java-version: ${{ matrix.java }}
develocity-access-key: ${{ secrets.GE_ACCESS_TOKEN }}
- uses: actions/download-artifact@v4
- name: Download build scan archive
id: download-build-scan
uses: actions/download-artifact@v4
continue-on-error: true
with:
github-token: ${{ github.token }}
run-id: ${{ github.event.workflow_run.id }}
name: build-scan-test-${{ matrix.java }}
path: ~/.gradle/build-scan-data
- name: Publish scan
run: ./gradlew --info buildScanPublishPrevious
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' }}
run: |
echo "Could not download build scans from ${{ github.event.workflow_run.html_url }} " >> $GITHUB_STEP_SUMMARY
- name: Publish Scan
id: publish-build-scan
continue-on-error: true
if: ${{ steps.download-build-scan.outcome == 'success' }}
run: |
./gradlew --info buildScanPublishPrevious > gradle.out
Comment thread
chia7712 marked this conversation as resolved.
SCAN_URL=$(grep '^https://.*$' gradle.out)
cat gradle.out
Comment thread
chia7712 marked this conversation as resolved.
echo "Published build scan to $SCAN_URL" >> $GITHUB_STEP_SUMMARY
echo "build-scan-url=$SCAN_URL" >> $GITHUB_OUTPUT
- name: Handle failed publish
if: ${{ steps.publish-build-scan.outcome == 'failure' }}
uses: ./.github/actions/gh-api-update-status
with:
gh-token: ${{ secrets.GITHUB_TOKEN }}
repository: ${{ github.event.workflow_run.head_repository.full_name }}
commit_sha: ${{ github.event.workflow_run.head_sha }}
url: '${{ github.event.repository.html_url }}/actions/runs/${{ github.run_id }}'
Comment thread
chia7712 marked this conversation as resolved.
description: 'The build scan could not be published'
context: 'Gradle Build Scan / Java ${{ matrix.java }}'
state: 'error'
- name: Update Status Check
if: ${{ steps.publish-build-scan.outcome == 'success' }}
uses: ./.github/actions/gh-api-update-status
with:
gh-token: ${{ secrets.GITHUB_TOKEN }}
repository: ${{ github.event.workflow_run.head_repository.full_name }}
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 / Java ${{ matrix.java }}'
state: 'success'