Files
hdf5/.github/workflows/java-examples-maven-test.yml
T
dependabot[bot] 3c617d23a5 Bump the github-actions group across 1 directory with 11 updates (#6215)
* Bump the github-actions group across 1 directory with 11 updates

Bumps the github-actions group with 11 updates in the / directory:

| Package | From | To |
| --- | --- | --- |
| [actions/cache](https://github.com/actions/cache) | `5.0.1` | `5.0.3` |
| [lukka/get-cmake](https://github.com/lukka/get-cmake) | `4.2.1` | `4.2.3` |
| [softwareforgood/check-artifact-v4-existence](https://github.com/softwareforgood/check-artifact-v4-existence) | `0.3.0` | `0.4.1` |
| [github/codeql-action](https://github.com/github/codeql-action) | `3.31.9` | `4.32.2` |
| [azure/trusted-signing-action](https://github.com/azure/trusted-signing-action) | `0.5.11` | `1.1.0` |
| [cygwin/cygwin-install-action](https://github.com/cygwin/cygwin-install-action) | `7d2dc1e241644c3318bed9ec74115d1929baa681` | `2566376092c4e280f21131be027af3f5bb2420a4` |
| [aws-actions/configure-aws-credentials](https://github.com/aws-actions/configure-aws-credentials) | `5.1.1` | `6.0.0` |
| [vmactions/freebsd-vm](https://github.com/vmactions/freebsd-vm) | `1.3.4` | `1.4.2` |
| [vmactions/openbsd-vm](https://github.com/vmactions/openbsd-vm) | `1.3.1` | `1.3.5` |
| [mpi4py/setup-mpi](https://github.com/mpi4py/setup-mpi) | `1.4.1` | `1.4.2` |
| [actions/setup-python](https://github.com/actions/setup-python) | `6.1.0` | `6.2.0` |

 vmactions/openbsd-vm@d6c29ce1b4 (`1.3.5`) failed to run ssh on the github runner.  271a1ba62300483cfc58345ff9f425f1349a2cab for v1.3.4 was used instead.
2026-02-13 07:42:14 -06:00

474 lines
19 KiB
YAML

name: Java Examples Maven Testing
on:
workflow_call:
inputs:
build_mode:
description: "release vs. debug build"
required: true
type: string
maven_artifacts_version:
description: "HDF5 Maven artifacts version to test against"
required: true
type: string
permissions:
contents: read
jobs:
# Parallel testing by platform and example category
test-examples-linux:
name: "Test Examples Linux (${{ matrix.category }})"
runs-on: ubuntu-latest
continue-on-error: true # Non-blocking failures
strategy:
fail-fast: false
matrix:
category: [H5D, H5T, H5G, TUTR]
steps:
- name: Checkout code
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
- name: Download Maven artifacts (Linux)
uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7.0.0
with:
name: maven-staging-artifacts-linux-x86_64
path: ./maven-artifacts
continue-on-error: true
- name: Set up JDK 21
uses: actions/setup-java@f2beeb24e141e01a676f977032f5a29d81c9e27e # v5
with:
java-version: '21'
distribution: 'temurin'
- name: Cache Maven dependencies
uses: actions/cache@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v4
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-examples-${{ hashFiles('**/pom-examples.xml*') }}
restore-keys: |
${{ runner.os }}-maven-examples-
${{ runner.os }}-maven-
- name: Identify HDF5 JAR files
run: |
echo "=== Identifying HDF5 JAR files ==="
# Find HDF5 JAR files (not dependencies)
HDF5_JARS=$(find ./maven-artifacts -name "*hdf5*.jar" -o -name "jarhdf5*.jar")
DEP_JARS=$(find ./maven-artifacts -name "*.jar" ! -name "*hdf5*" ! -name "jarhdf5*")
echo "HDF5 JARs found:"
echo "$HDF5_JARS"
echo ""
echo "Dependency JARs found:"
echo "$DEP_JARS"
if [ -z "$HDF5_JARS" ]; then
echo "❌ No HDF5 JAR files found!"
echo "All available JARs:"
find ./maven-artifacts -name "*.jar"
exit 1
fi
- name: Test Examples Category ${{ matrix.category }}
id: test-examples
run: |
cd HDF5Examples/JAVA/${{ matrix.category }}
echo "=== Testing ${{ matrix.category }} Examples ==="
# Create test results directory
mkdir -p ../../../test-results/${{ matrix.category }}
FAILED_EXAMPLES=""
TOTAL_EXAMPLES=0
PASSED_EXAMPLES=0
# Test each Java example in the category
for java_file in *.java; do
if [ -f "$java_file" ]; then
TOTAL_EXAMPLES=$((TOTAL_EXAMPLES + 1))
example_name=$(basename "$java_file" .java)
echo "--- Testing $example_name ---"
# Build classpath (use platform-specific artifacts)
MAVEN_ARTIFACTS_DIR="../../../maven-artifacts"
HDF5_JAR=$(find "$MAVEN_ARTIFACTS_DIR" -name "*hdf5*.jar" -o -name "jarhdf5*.jar" | head -1)
DEP_JARS=$(find "$MAVEN_ARTIFACTS_DIR" -name "slf4j-api*.jar" -o -name "slf4j-simple*.jar")
if [ -z "$HDF5_JAR" ]; then
echo "❌ No HDF5 JAR found"
find "$MAVEN_ARTIFACTS_DIR" -name "*.jar" | head -10
continue
fi
CLASSPATH="$HDF5_JAR"
for dep_jar in $DEP_JARS; do
CLASSPATH="$CLASSPATH:$dep_jar"
done
# Compile the example
if javac -cp "$CLASSPATH" "$java_file"; then
echo "✓ Compilation successful for $example_name"
# Run the example and capture output
if timeout 30s java -cp ".:$CLASSPATH" "$example_name" > "../../../test-results/${{ matrix.category }}/${example_name}.output" 2>&1; then
# Validate output using pattern matching
output_file="../../../test-results/${{ matrix.category }}/${example_name}.output"
# Check for common success patterns
if grep -q -i -E "(dataset|datatype|group|success|created|written|read)" "$output_file" && \
! grep -q -i -E "(error|exception|failed|cannot)" "$output_file"; then
echo "✓ Execution and validation successful for $example_name"
PASSED_EXAMPLES=$((PASSED_EXAMPLES + 1))
else
echo "✗ Output validation failed for $example_name"
FAILED_EXAMPLES="$FAILED_EXAMPLES $example_name"
echo "Output:"
cat "$output_file"
fi
else
# Check if failure is due to expected native library issue (acceptable for Maven-only testing)
output_file="../../../test-results/${{ matrix.category }}/${example_name}.output"
if grep -q "UnsatisfiedLinkError.*hdf5_java.*java.library.path" "$output_file"; then
echo "✓ Expected native library error for Maven-only testing: $example_name"
echo " (This confirms JAR structure is correct)"
PASSED_EXAMPLES=$((PASSED_EXAMPLES + 1))
else
echo "✗ Unexpected execution failure for $example_name"
FAILED_EXAMPLES="$FAILED_EXAMPLES $example_name"
echo "Output:"
cat "$output_file"
fi
fi
else
echo "✗ Compilation failed for $example_name"
FAILED_EXAMPLES="$FAILED_EXAMPLES $example_name"
fi
echo ""
fi
done
# Summary
echo "=== ${{ matrix.category }} Summary ==="
echo "Total examples: $TOTAL_EXAMPLES"
echo "Passed: $PASSED_EXAMPLES"
echo "Failed: $((TOTAL_EXAMPLES - PASSED_EXAMPLES))"
if [ -n "$FAILED_EXAMPLES" ]; then
echo "Failed examples:$FAILED_EXAMPLES"
echo "failed-examples=$FAILED_EXAMPLES" >> $GITHUB_OUTPUT
echo "test-status=FAILED" >> $GITHUB_OUTPUT
else
echo "All examples passed!"
echo "test-status=PASSED" >> $GITHUB_OUTPUT
fi
echo "total-examples=$TOTAL_EXAMPLES" >> $GITHUB_OUTPUT
echo "passed-examples=$PASSED_EXAMPLES" >> $GITHUB_OUTPUT
- name: Upload failure artifacts (Linux ${{ matrix.category }})
if: steps.test-examples.outputs.test-status == 'FAILED'
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v5
with:
name: java-examples-failure-linux-${{ matrix.category }}-${{ github.run_id }}
path: |
test-results/${{ matrix.category }}/
HDF5Examples/JAVA/${{ matrix.category }}/*.class
HDF5Examples/JAVA/${{ matrix.category }}/*.h5
retention-days: 7
test-examples-windows:
name: "Test Examples Windows (${{ matrix.category }})"
runs-on: windows-latest
continue-on-error: true
strategy:
fail-fast: false
matrix:
category: [H5D, H5T, H5G, TUTR]
steps:
- name: Checkout code
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
- name: Download Maven artifacts (Windows)
uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7.0.0
with:
name: maven-staging-artifacts-windows-x86_64
path: ./maven-artifacts
continue-on-error: true
- name: Set up JDK 21
uses: actions/setup-java@f2beeb24e141e01a676f977032f5a29d81c9e27e # v5
with:
java-version: '21'
distribution: 'temurin'
- name: Cache Maven dependencies
uses: actions/cache@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v4
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-examples-${{ hashFiles('**/pom-examples.xml*') }}
- name: Test Examples Category ${{ matrix.category }}
id: test-examples
shell: pwsh
run: |
cd HDF5Examples/JAVA/${{ matrix.category }}
Write-Host "=== Testing ${{ matrix.category }} Examples ==="
# Create test results directory
New-Item -ItemType Directory -Force -Path "../../../test-results/${{ matrix.category }}"
$FAILED_EXAMPLES = @()
$TOTAL_EXAMPLES = 0
$PASSED_EXAMPLES = 0
# Test each Java example in the category
Get-ChildItem -Filter "*.java" | ForEach-Object {
$TOTAL_EXAMPLES++
$example_name = $_.BaseName
Write-Host "--- Testing $example_name ---"
# Compile the example
$compile_result = javac -cp "../../../maven-artifacts/*.jar" $_.Name
if ($LASTEXITCODE -eq 0) {
Write-Host "✓ Compilation successful for $example_name"
# Run the example and capture output
$timeout_cmd = "timeout 30s java -cp '.;../../../maven-artifacts/*' $example_name"
$output_file = "../../../test-results/${{ matrix.category }}/${example_name}.output"
try {
& cmd /c "$timeout_cmd > `"$output_file`" 2>&1"
if ($LASTEXITCODE -eq 0) {
# Validate output using pattern matching
$content = Get-Content $output_file -Raw
if (($content -match "(?i)(dataset|datatype|group|success|created|written|read)") -and
($content -notmatch "(?i)(error|exception|failed|cannot)")) {
Write-Host "✓ Execution and validation successful for $example_name"
$PASSED_EXAMPLES++
} else {
Write-Host "✗ Output validation failed for $example_name"
$FAILED_EXAMPLES += $example_name
Write-Host "Output:"
Get-Content $output_file
}
} else {
Write-Host "✗ Execution failed for $example_name"
$FAILED_EXAMPLES += $example_name
}
} catch {
Write-Host "✗ Execution failed for $example_name"
$FAILED_EXAMPLES += $example_name
}
} else {
Write-Host "✗ Compilation failed for $example_name"
$FAILED_EXAMPLES += $example_name
}
Write-Host ""
}
# Summary
Write-Host "=== ${{ matrix.category }} Summary ==="
Write-Host "Total examples: $TOTAL_EXAMPLES"
Write-Host "Passed: $PASSED_EXAMPLES"
Write-Host "Failed: $($TOTAL_EXAMPLES - $PASSED_EXAMPLES)"
if ($FAILED_EXAMPLES.Count -gt 0) {
Write-Host "Failed examples: $($FAILED_EXAMPLES -join ' ')"
echo "failed-examples=$($FAILED_EXAMPLES -join ' ')" >> $env:GITHUB_OUTPUT
echo "test-status=FAILED" >> $env:GITHUB_OUTPUT
} else {
Write-Host "All examples passed!"
echo "test-status=PASSED" >> $env:GITHUB_OUTPUT
}
echo "total-examples=$TOTAL_EXAMPLES" >> $env:GITHUB_OUTPUT
echo "passed-examples=$PASSED_EXAMPLES" >> $env:GITHUB_OUTPUT
- name: Upload failure artifacts (Windows ${{ matrix.category }})
if: steps.test-examples.outputs.test-status == 'FAILED'
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v5
with:
name: java-examples-failure-windows-${{ matrix.category }}-${{ github.run_id }}
path: |
test-results/${{ matrix.category }}/
HDF5Examples/JAVA/${{ matrix.category }}/*.class
HDF5Examples/JAVA/${{ matrix.category }}/*.h5
test-examples-macos:
name: "Test Examples macOS (${{ matrix.category }})"
runs-on: macos-latest
continue-on-error: true
strategy:
fail-fast: false
matrix:
category: [H5D, H5T, H5G, TUTR]
steps:
- name: Checkout code
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
- name: Download Maven artifacts (macOS aarch64)
uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7.0.0
with:
name: maven-staging-artifacts-macos-aarch64
path: ./maven-artifacts
continue-on-error: true
- name: Set up JDK 21
uses: actions/setup-java@f2beeb24e141e01a676f977032f5a29d81c9e27e # v5
with:
java-version: '21'
distribution: 'temurin'
- name: Cache Maven dependencies
uses: actions/cache@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v4
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-examples-${{ hashFiles('**/pom-examples.xml*') }}
- name: Test Examples Category ${{ matrix.category }}
id: test-examples
run: |
cd HDF5Examples/JAVA/${{ matrix.category }}
echo "=== Testing ${{ matrix.category }} Examples ==="
# Create test results directory
mkdir -p ../../../test-results/${{ matrix.category }}
FAILED_EXAMPLES=""
TOTAL_EXAMPLES=0
PASSED_EXAMPLES=0
# Test each Java example in the category
for java_file in *.java; do
if [ -f "$java_file" ]; then
TOTAL_EXAMPLES=$((TOTAL_EXAMPLES + 1))
example_name=$(basename "$java_file" .java)
echo "--- Testing $example_name ---"
# Build classpath (use platform-specific artifacts)
MAVEN_ARTIFACTS_DIR="../../../maven-artifacts"
HDF5_JAR=$(find "$MAVEN_ARTIFACTS_DIR" -name "*hdf5*.jar" -o -name "jarhdf5*.jar" | head -1)
DEP_JARS=$(find "$MAVEN_ARTIFACTS_DIR" -name "slf4j-api*.jar" -o -name "slf4j-simple*.jar")
if [ -z "$HDF5_JAR" ]; then
echo "❌ No HDF5 JAR found"
find "$MAVEN_ARTIFACTS_DIR" -name "*.jar" | head -10
continue
fi
CLASSPATH="$HDF5_JAR"
for dep_jar in $DEP_JARS; do
CLASSPATH="$CLASSPATH:$dep_jar"
done
# Compile the example
if javac -cp "$CLASSPATH" "$java_file"; then
echo "✓ Compilation successful for $example_name"
# Run the example and capture output
if timeout 30s java -cp ".:$CLASSPATH" "$example_name" > "../../../test-results/${{ matrix.category }}/${example_name}.output" 2>&1; then
# Validate output using pattern matching
output_file="../../../test-results/${{ matrix.category }}/${example_name}.output"
# Check for common success patterns
if grep -q -i -E "(dataset|datatype|group|success|created|written|read)" "$output_file" && \
! grep -q -i -E "(error|exception|failed|cannot)" "$output_file"; then
echo "✓ Execution and validation successful for $example_name"
PASSED_EXAMPLES=$((PASSED_EXAMPLES + 1))
else
echo "✗ Output validation failed for $example_name"
FAILED_EXAMPLES="$FAILED_EXAMPLES $example_name"
fi
else
echo "✗ Execution failed for $example_name"
FAILED_EXAMPLES="$FAILED_EXAMPLES $example_name"
fi
else
echo "✗ Compilation failed for $example_name"
FAILED_EXAMPLES="$FAILED_EXAMPLES $example_name"
fi
echo ""
fi
done
# Summary
echo "=== ${{ matrix.category }} Summary ==="
echo "Total examples: $TOTAL_EXAMPLES"
echo "Passed: $PASSED_EXAMPLES"
echo "Failed: $((TOTAL_EXAMPLES - PASSED_EXAMPLES))"
if [ -n "$FAILED_EXAMPLES" ]; then
echo "Failed examples:$FAILED_EXAMPLES"
echo "failed-examples=$FAILED_EXAMPLES" >> $GITHUB_OUTPUT
echo "test-status=FAILED" >> $GITHUB_OUTPUT
else
echo "All examples passed!"
echo "test-status=PASSED" >> $GITHUB_OUTPUT
fi
echo "total-examples=$TOTAL_EXAMPLES" >> $GITHUB_OUTPUT
echo "passed-examples=$PASSED_EXAMPLES" >> $GITHUB_OUTPUT
- name: Upload failure artifacts (macOS ${{ matrix.category }})
if: steps.test-examples.outputs.test-status == 'FAILED'
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v5
with:
name: java-examples-failure-macos-${{ matrix.category }}-${{ github.run_id }}
path: |
test-results/${{ matrix.category }}/
HDF5Examples/JAVA/${{ matrix.category }}/*.class
HDF5Examples/JAVA/${{ matrix.category }}/*.h5
analyze-cross-platform-failures:
name: "Analyze Cross-Platform Failures"
runs-on: ubuntu-latest
needs: [test-examples-linux, test-examples-windows, test-examples-macos]
if: always()
steps:
- name: Collect Test Results
run: |
echo "=== Java Examples Testing Summary ==="
# Collect results from matrix outputs (this would need to be enhanced
# to actually collect the outputs from the matrix jobs)
echo "Cross-platform failure analysis:"
echo "- Examples failing on multiple platforms require attention"
echo "- Single-platform failures may be platform-specific issues"
# This step would analyze patterns in failures across platforms
# and generate appropriate alerts/issues for multi-platform failures
- name: Generate Test Summary Report
run: |
cat > java-examples-test-summary.md << 'EOF'
# Java Examples Maven Testing Summary
**Build Mode**: ${{ inputs.build_mode }}
**Maven Version**: ${{ inputs.maven_artifacts_version }}
**Date**: $(date -u +"%Y-%m-%d %H:%M:%S UTC")
## Platform Results
- **Linux**: See individual category results
- **Windows**: See individual category results
- **macOS**: See individual category results
## Cross-Platform Analysis
Examples failing on multiple platforms require investigation.
EOF
echo "Test summary report generated"
- name: Upload Test Summary
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v5
with:
name: java-examples-test-summary-${{ github.run_id }}
path: java-examples-test-summary.md
retention-days: 30