Skip to content

Commit

Permalink
MINOR Allow PRs to publish build scan (#17123)
Browse files Browse the repository at this point in the history
Publish Gradle build scans produced by PRs. This is done by using a `workflow_run` action that is triggered when the "CI" workflow completes. It downloads the build scan files from the PR workflow and publishes to ge.apache.org.

Reviewers: Chia-Ping Tsai <[email protected]>
  • Loading branch information
mumrah authored Sep 8, 2024
1 parent 04dee3b commit 049b7cd
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 1 deletion.
13 changes: 12 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ on:
description: "Should we run the opt-in steps?"
default: "false"
type: string
is-public-fork:
description: "Is this CI run from a public fork?"
default: "true"
type: string

jobs:
validate:
Expand Down Expand Up @@ -110,7 +114,8 @@ jobs:
id: junit-test
run: |
set +e
timeout 180m ./gradlew --build-cache --scan --continue \
timeout 180m ./gradlew --build-cache --continue \
${{ inputs.is-public-fork == 'true' && '--no-scan' || '--scan' }} \
-PtestLoggingEvents=started,passed,skipped,failed \
-PmaxParallelForks=2 \
-PmaxTestRetries=1 -PmaxTestRetryFailures=10 \
Expand All @@ -132,3 +137,9 @@ jobs:
GITHUB_WORKSPACE: ${{ github.workspace }}
REPORT_URL: ${{ steps.junit-upload-artifact.outputs.artifact-url }}
GRADLE_EXIT_CODE: ${{ steps.junit-test.outputs.exitcode }}
- name: Archive Build Scan
if: ${{ inputs.is-public-fork == 'true' }}
uses: actions/upload-artifact@v4
with:
name: build-scan-test-${{ matrix.java }}
path: ~/.gradle/build-scan-data
54 changes: 54 additions & 0 deletions .github/workflows/ci-complete.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# 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: CI Complete

on:
workflow_run:
workflows: [CI]
types:
- completed

jobs:
upload-build-scan:
if: ${{ github.event.workflow_run.head_repository.full_name != 'apache/kafka' }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
java: [ 21, 17, 11, 8 ]
steps:
- name: Env
run: printenv
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
- name: Checkout code
uses: actions/checkout@v4
with:
persist-credentials:
false
- name: Setup Gradle
uses: ./.github/actions/setup-gradle
with:
java-version: ${{ matrix.java }}
develocity-access-key: ${{ secrets.GE_ACCESS_TOKEN }}
- uses: actions/download-artifact@v4
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
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,6 @@ jobs:
gradle-cache-read-only: ${{ github.ref != 'refs/heads/trunk' }}
gradle-cache-write-only: ${{ github.ref == 'refs/heads/trunk' }}
github-actions-opt-in: ${{ github.ref == 'refs/heads/trunk' || contains(github.head_ref, 'gh-') }}
is-public-fork: ${{ github.event.pull_request.head.repo.full_name != 'apache/kafka' }}
secrets:
inherit

0 comments on commit 049b7cd

Please sign in to comment.