-
Notifications
You must be signed in to change notification settings - Fork 373
ci: retry the Maven distribution download in every job that runs mvnw #5881
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
andygrove
wants to merge
1
commit into
apache:main
Choose a base branch
from
andygrove:ci/maven-bootstrap-retry
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| # 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: Bootstrap Maven | ||
| description: >- | ||
| Install the Maven distribution the wrapper points at, retrying the download | ||
| and caching the result, so a Maven Central hiccup does not fail a job before | ||
| it has built or tested anything. | ||
|
|
||
| # The dependency caches cover ~/.m2/repository, but the wrapper installs Maven | ||
| # itself under ~/.m2/wrapper/dists. On a fresh runner the first ./mvnw call | ||
| # therefore still downloads apache-maven-*-bin.zip from Maven Central, and that | ||
| # single request has failed with HTTP 403 and 429 often enough to matter. | ||
| # Every job that runs ./mvnw (directly, via make, or via setup-spark-builder) | ||
| # goes through setup-builder or setup-macos-builder, which end by calling this | ||
| # action; ci.yml's preflight job calls it directly before the RAT check. | ||
| # | ||
| # Requires a checkout and a JDK on PATH. Runs from the repository root. | ||
|
|
||
| runs: | ||
| using: "composite" | ||
| steps: | ||
| # Maven itself is stored outside the dependency repository. Keep its cache | ||
| # independent of pom.xml changes. | ||
| - name: Restore Maven distribution | ||
| id: maven-distribution | ||
| # Temporarily disabled on macOS to work around | ||
| # https://github.com/actions/runner-images/issues/13341; macOS still | ||
| # gets the retry below, just not the cache. | ||
| if: ${{ runner.os != 'macOS' }} | ||
| uses: actions/cache/restore@v5 | ||
| with: | ||
| path: | | ||
| ~/.m2/wrapper/dists | ||
| /root/.m2/wrapper/dists | ||
| key: ${{ runner.os }}-${{ runner.arch }}-maven-wrapper-${{ hashFiles('.mvn/wrapper/maven-wrapper.properties') }} | ||
|
|
||
| # Retry only the wrapper download, never compilation or test execution. | ||
| # Delays use exponential backoff (10s, 20s, 40s) plus 0-4s of random jitter. | ||
| - name: Bootstrap Maven | ||
| shell: bash | ||
| run: | | ||
| for attempt in 1 2 3 4; do | ||
| if ./mvnw -B --version; then | ||
| break | ||
| fi | ||
| if [ "$attempt" -eq 4 ]; then | ||
| echo "::error::Maven bootstrap failed after $attempt attempts; nothing was built." | ||
| exit 1 | ||
| fi | ||
| delay=$((10 * (1 << (attempt - 1)) + RANDOM % 5)) | ||
| echo "::warning::Maven bootstrap attempt $attempt failed; retrying in ${delay}s." | ||
| sleep "$delay" | ||
| done | ||
|
|
||
| # Save a successful bootstrap even when the rest of the job fails. | ||
| - name: Save Maven distribution | ||
| if: ${{ runner.os != 'macOS' && steps.maven-distribution.outputs.cache-hit != 'true' }} | ||
| uses: actions/cache/save@v5 | ||
| with: | ||
| path: | | ||
| ~/.m2/wrapper/dists | ||
| /root/.m2/wrapper/dists | ||
| key: ${{ steps.maven-distribution.outputs.cache-primary-key }} | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correctness
[P2] Use an accessible distribution cache path in preflight
Could we exclude the inaccessible
/root/.m2/wrapper/distspath for the new non-container preflight caller? In this PR's Preflight log, Maven is installed under/home/runner/.m2/wrapper/dists, butSave Maven distributionemitsEACCES: permission denied, lstat '/root/.m2/wrapper/dists'and saves no cache. The cache action aborts path enumeration on this error, so the valid user-home directory is not saved either, even though the step stays green. This leaves the pipeline's preflight gate downloading Maven again on a cache miss and misses the caching part of the reliability fix. Please select accessible distribution paths for each runner environment in both restore and save, then verify a cold save and warm restore onubuntu-slimas well as the container path.