Skip to content

Docs/javadoc

Docs/javadoc #7

Workflow file for this run

name: CI/CD Pipeline
on:
push:
branches: [ main, dev ]
pull_request:
branches: [ main, dev ]
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
java-version: [17, 21]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up JDK ${{ matrix.java-version }}
uses: actions/setup-java@v4
with:
java-version: ${{ matrix.java-version }}
distribution: 'temurin'
- name: Cache Gradle packages
uses: actions/cache@v3
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Make gradlew executable
run: chmod +x ./gradlew
- name: Run unit tests
run: ./gradlew test --info
- name: Run integration tests
run: ./gradlew test --tests "*IntegrationTest*"
- name: Run performance tests
run: ./gradlew test --tests "*StressTest*" --info
continue-on-error: true # Performance tests may have timing variations
- name: Generate test report
run: ./gradlew test jacocoTestReport
if: always()
- name: Upload test results
uses: actions/upload-artifact@v3
if: always()
with:
name: test-results-java-${{ matrix.java-version }}
path: |
build/reports/tests/
build/reports/jacoco/
build/test-results/
build/reports/performance/
- name: Check test coverage
run: |
# Extract coverage percentage from JaCoCo report
COVERAGE=$(grep -oP 'Total.*?instruction.*?>\K\d+(?:\.\d+)?' build/reports/jacoco/test/html/index.html | head -1)
echo "Test coverage: $COVERAGE%"
# Fail if coverage is below 80%
if (( $(echo "$COVERAGE < 80" | bc -l) )); then
echo "❌ Test coverage too low: $COVERAGE% (minimum: 80%)"
exit 1
else
echo "✅ Test coverage acceptable: $COVERAGE%"
fi
performance-analysis:
runs-on: ubuntu-latest
needs: test
if: github.event_name == 'push'
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Download performance reports
uses: actions/download-artifact@v3
with:
name: test-results-java-17
path: build/reports/
- name: Analyze performance metrics
run: |
echo "📊 Performance Analysis Report"
echo "================================"
# Check if performance reports exist
if [ -d "build/reports/performance" ]; then
echo "✅ Performance reports found"
ls -la build/reports/performance/
# Analyze latest performance report
LATEST_REPORT=$(find build/reports/performance -name "*.txt" -type f -printf '%T@ %p\n' | sort -n | tail -1 | cut -f2- -d" ")
if [ -n "$LATEST_REPORT" ]; then
echo "📈 Latest Performance Report: $LATEST_REPORT"
echo "---"
cat "$LATEST_REPORT"
echo "---"
# Check for performance issues
if grep -q "❌ Poor" "$LATEST_REPORT"; then
echo "🚨 CRITICAL: Performance regression detected!"
exit 1
elif grep -q "⚠️" "$LATEST_REPORT"; then
echo "⚠️ WARNING: Performance issues detected"
else
echo "✅ Performance within acceptable limits"
fi
fi
else
echo "⚠️ No performance reports found - running basic performance test"
# Run a quick performance test if no reports exist
./gradlew test --tests "SessionStressTest.shouldHandleTenConcurrentSessions" --quiet
fi
build:
runs-on: ubuntu-latest
needs: [test, performance-analysis]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
- name: Cache Gradle packages
uses: actions/cache@v3
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Build plugin JAR
run: ./gradlew build -x test # Skip tests since we already ran them
- name: Verify JAR contents
run: |
echo "📦 Plugin JAR contents:"
java -jar build/libs/Matchbox-*.jar --version 2>/dev/null || echo "JAR created successfully"
echo "📊 JAR file details:"
ls -la build/libs/
- name: Upload build artifacts
uses: actions/upload-artifact@v3
with:
name: matchbox-plugin
path: build/libs/Matchbox-*.jar
release:
runs-on: ubuntu-latest
needs: build
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Download build artifacts
uses: actions/download-artifact@v3
with:
name: matchbox-plugin
path: build/libs/
- name: Create release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ github.run_number }}
release_name: Matchbox v${{ github.run_number }}
body: |
## 🚀 Automated Release
This release has been automatically built and tested.
### ✅ Quality Assurance
- All unit tests passed
- Integration tests completed
- Performance tests validated
- Code coverage requirements met
### 📦 Assets
- Plugin JAR file attached
### 🔗 Links
- [Full Changelog](CHANGELOG.md)
- [API Documentation](MatchboxAPI_Docs.md)
draft: false
prerelease: false
- name: Upload release asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: build/libs/Matchbox-*.jar
asset_name: Matchbox-${{ github.run_number }}.jar
asset_content_type: application/java-archive
# Performance regression detection for PRs
performance-regression-check:
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
steps:
- name: Checkout base branch
uses: actions/checkout@v4
with:
ref: ${{ github.base_ref }}
- name: Run baseline performance test
run: |
echo "📊 Running baseline performance test on ${{ github.base_ref }}"
./gradlew test --tests "SessionStressTest.shouldHandleTenConcurrentSessions" --quiet --info > baseline_performance.log 2>&1
# Extract key metrics from baseline
BASELINE_TIME=$(grep "Session.*created in" baseline_performance.log | grep -oP '\d+ ms' | awk '{sum+=$1} END {print sum/NR}')
echo "BASELINE_AVG_TIME=$BASELINE_TIME" >> $GITHUB_ENV
- name: Checkout PR branch
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
- name: Run PR performance test
run: |
echo "📊 Running PR performance test on ${{ github.head_ref }}"
./gradlew test --tests "SessionStressTest.shouldHandleTenConcurrentSessions" --quiet --info > pr_performance.log 2>&1
# Extract key metrics from PR
PR_TIME=$(grep "Session.*created in" pr_performance.log | grep -oP '\d+ ms' | awk '{sum+=$1} END {print sum/NR}')
echo "PR_AVG_TIME=$PR_TIME" >> $GITHUB_ENV
- name: Compare performance
run: |
echo "📈 Performance Comparison"
echo "========================"
echo "Baseline (${{ github.base_ref }}): ${{ env.BASELINE_AVG_TIME }}ms average"
echo "PR (${{ github.head_ref }}): ${{ env.PR_AVG_TIME }}ms average"
# Calculate performance change
if [ -n "${{ env.BASELINE_AVG_TIME }}" ] && [ -n "${{ env.PR_AVG_TIME }}" ]; then
BASELINE="${{ env.BASELINE_AVG_TIME }}"
PR="${{ env.PR_AVG_TIME }}"
# Calculate percentage change
if (( $(echo "$BASELINE > 0" | bc -l) )); then
CHANGE=$(echo "scale=2; (($PR - $BASELINE) / $BASELINE) * 100" | bc -l)
echo "Performance change: ${CHANGE}%"
# Check for significant regression
if (( $(echo "$CHANGE > 25" | bc -l) )); then
echo "🚨 SIGNIFICANT PERFORMANCE REGRESSION: +${CHANGE}% slower"
echo "This PR introduces a performance regression that should be addressed."
exit 1
elif (( $(echo "$CHANGE < -10" | bc -l) )); then
echo "✅ PERFORMANCE IMPROVEMENT: ${CHANGE}% faster"
else
echo "✅ Performance change within acceptable range: ${CHANGE}%"
fi
fi
else
echo "⚠️ Could not calculate performance change - missing metrics"
fi