Skip to content
Merged
Changes from all commits
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
53 changes: 50 additions & 3 deletions .github/actions/java-test/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,46 @@ runs:
restore-keys: |
${{ runner.os }}-java-maven-

# Maven itself is stored outside the dependency repository. Keep its cache
# independent of pom.xml changes and preserve the macOS cache workaround.
- name: Restore Maven distribution
id: maven-distribution
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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

lets also comment the delay is exponential depending on the attempt

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Done!

# 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; tests were not started."
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 subsequent tests fail.
- 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 }}

- name: Run all tests
shell: bash
if: ${{ inputs.suites == '' }}
Expand All @@ -100,25 +140,32 @@ runs:
with:
name: crash-logs-${{ inputs.artifact_name }}
path: "**/hs_err_pid*.log"
if-no-files-found: ignore
- name: Debug listing
if: failure()
shell: bash
run: |
run: |
echo "CWD: $(pwd)"
ls -lah .
ls -lah target
if [ -d target ]; then
ls -lah target
else
echo "No root target directory; Maven may not have started."
fi
find . -name 'unit-tests.log'
- name: Upload unit-tests.log
if: failure()
uses: actions/upload-artifact@v6
with:
name: unit-tests-${{ inputs.artifact_name }}
path: "**/target/unit-tests.log"
if-no-files-found: ignore
- name: Upload test results
if: ${{ inputs.upload-test-reports == 'true' }}
if: ${{ !cancelled() && inputs.upload-test-reports == 'true' }}
uses: actions/upload-artifact@v6
with:
name: java-test-reports-${{ inputs.artifact_name }}
path: "**/target/surefire-reports/*.txt"
if-no-files-found: ignore
retention-days: 7 # 1 week for test reports
overwrite: true
Loading