Skip to content

KAFKA-18903: update-cache.sh use curl + jq to get sha contains gradle cache instead of gh cli #19753

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

Open
wants to merge 4 commits into
base: trunk
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
11 changes: 11 additions & 0 deletions committer-tools/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,3 +103,14 @@ Found tests that were started, but not finished:

2024-09-10T20:31:26.6830206Z Gradle Test Run :streams:test > Gradle Test Executor 47 > StreamThreadTest > shouldReturnErrorIfProducerInstanceIdNotInitialized(boolean, boolean) > "shouldReturnErrorIfProducerInstanceIdNotInitialized(boolean, boolean).stateUpdaterEnabled=true, processingThreadsEnabled=true" STARTED
```


## Speed up the CI
`update-cache.sh` allows developers to retrieve the latest commit SHA that contains the Gradle build cache and create a local branch called `trunk-cached`.
Developers can then checkout a new branch based on `trunk-cached` to speed up CI.

```bash
./update-cache.sh

Local branch 'trunk-cached' successfully updated to f26974b16d (from 19 hours ago).
```
19 changes: 3 additions & 16 deletions committer-tools/update-cache.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,9 @@
# specific language governing permissions and limitations
# under the License.

if ! git config --get alias.update-cache > /dev/null; then
printf '\e[36m%s\n\n %s\n\e[0m\n' \
'Hint: you can create a Git alias to execute this script. Example:' \
"git config alias.update-cache '!bash $(realpath "$0")'"
fi

key="$(
gh cache list \
--key 'gradle-home-v1|Linux-X64|test' \
--sort 'created_at' \
--limit 1 \
--json 'key' \
--jq '.[].key'
)"

sha="$(cut -d '-' -f 5 <<< "$key")"
# Get the latest commit SHA that contains the Gradle build cache.
sha=$(curl -s "https://api.github.com/repos/apache/kafka/actions/caches?key=gradle-home-v1&ref=refs/heads/trunk" \
| jq -r '.actions_caches | max_by(.created_at) | .key | split("-")[4]')

if ! git show "$sha" &> /dev/null; then
printf '\e[33m%s\n%s\e[0m\n' \
Expand Down