Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KAFKA-18500 Build PRs at HEAD commit #18449

Merged
merged 26 commits into from
Mar 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
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
45 changes: 44 additions & 1 deletion .github/workflows/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,4 +133,47 @@ Composite actions are a convenient way to reuse build logic, but they have
some limitations.

- Cannot run more than one step in a composite action (see `workflow_call` instead)
- Inputs can only be strings, no support for typed parameters. See: https://github.com/actions/runner/issues/2238
- Inputs can only be strings, no support for typed parameters. See: https://github.com/actions/runner/issues/2238

## Troubleshooting

### Gradle Cache Misses

If your PR is running for longer than you would expect due to cache misses, there are a
few things to check.

First, find the cache that was loaded into your PR build. This is found in the Setup Gradle
output. Look for a line starting with "Restored Gradle User Home from cache key".
For example,

```
Restored Gradle User Home from cache key: gradle-home-v1|Linux-X64|test[188616818c9a3165053ef8704c27b28e]-5c20aa187aa8f51af4270d7d1b0db4963b0cd10b
```

The last part of the cache key is the SHA of the commit on trunk where the cache
was created. If that commit is not on your branch, it means your build loaded a
cache that includes changes your PR does not yet have. This is a common way to
have cache misses. To resolve this, update your PR with the latest cached trunk commit:

```commandline
git fetch origin
./committer-tools/update-cache.sh
Copy link
Member

Choose a reason for hiding this comment

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

I noticed that this script requires us to login Github (or access key) - is it possible to use curl + jq to parse https://api.github.com/repos/apache/kafka/actions/caches?key=gradle-home-v1&&ref=refs/heads/trunk?

Copy link
Member Author

Choose a reason for hiding this comment

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

Wow, I'm surprised that works! I would have assumed that even public APIs would need some kind of auth token.

I filed https://issues.apache.org/jira/browse/KAFKA-18903 for this

git merge trunk-cached
```

then push your branch.

If your build seems to be using the correct cache, the next thing to check is for
changes to task inputs. You can find this by locating the trunk Build Scan from
the cache commit on trunk and comparing it with the build scan of your PR build.
This is done in the Develocity UI using the two overlapping circles like `(A()B)`.
This will show you differences in the task inputs for the two builds.

Finally, you can run your PR with extra cache debugging. Add this to the gradle invocation in
[run-gradle/action.yml](../actions/run-gradle/action.yml).

```
-Dorg.gradle.caching.debug=true
```

This will dump out a lot of output, so you may also reduce the test target to one module.
13 changes: 9 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ jobs:
name: Configure Workflow
outputs:
is-draft: ${{ steps.check-draft-pr.outputs.is-draft }}
test-catalog-days: ${{ steps.test-catalog.outputs.days }}
test-catalog-days: ${{ steps.configure-outputs.outputs.days }}
sha: ${{ steps.configure-outputs.outputs.sha }}
steps:
- name: Env
run: printenv
Expand All @@ -48,13 +49,15 @@ jobs:
github.event_name == 'pull_request' &&
github.event.pull_request.draft
run: echo "is-draft=true" >> "$GITHUB_OUTPUT"
- name: Test Catalog Age
id: test-catalog
- name: Configure Outputs
id: configure-outputs
run: |
if [ "${{ github.event_name }}" = "pull_request" ]; then
echo "days=0" >> "$GITHUB_OUTPUT"
echo "sha=${{ github.event.pull_request.head.sha }}" >> "$GITHUB_OUTPUT"
else
echo "days=7" >> "$GITHUB_OUTPUT"
echo "sha=${{ github.sha }}" >> "$GITHUB_OUTPUT"
fi

load-catalog:
Expand Down Expand Up @@ -108,7 +111,7 @@ jobs:
validate:
needs: [configure]
runs-on: ubuntu-latest
name: Compile and Check Java
name: Compile and Check (Merge Ref)
steps:
- name: Env
run: printenv
Expand All @@ -118,6 +121,7 @@ jobs:
uses: actions/checkout@v4
with:
persist-credentials: false
ref: ${{ github.sha }} # this is the default, just being explicit.
- name: Setup Python
uses: ./.github/actions/setup-python
- name: Setup Gradle
Expand Down Expand Up @@ -189,6 +193,7 @@ jobs:
uses: actions/checkout@v4
with:
persist-credentials: false
ref: ${{ needs.configure.outputs.sha }}
- name: Setup Python
uses: ./.github/actions/setup-python
- name: Setup Gradle
Expand Down