Skip to content
Merged
Show file tree
Hide file tree
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
26 changes: 13 additions & 13 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,40 +43,40 @@ jobs:
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2

- name: Compile project
run: mvn clean compile test-compile

- name: Run unit tests
run: mvn test -Dtest=RedlockConfigurationTest
run: mvn test

- name: Run integration tests with Testcontainers
run: mvn test -Dtest=RedlockIntegrationTest
run: mvn verify -Dmaven.test.skip.exec=false
env:
# Ensure Docker is available for Testcontainers
TESTCONTAINERS_RYUK_DISABLED: false
- name: Run all tests (including performance tests on nightly)

- name: Run performance tests (on nightly schedule only)
if: github.event_name == 'schedule'
run: mvn test -Dtest=RedlockPerformanceTest
run: mvn test -Dgroups=performance
env:
TESTCONTAINERS_RYUK_DISABLED: false

- name: Generate test report
uses: dorny/test-reporter@v1
if: (success() || failure()) && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository)
with:
name: Maven Tests (ubuntu-latest, Java ${{ matrix.java }})
path: target/surefire-reports/*.xml
path: |
target/surefire-reports/*.xml
target/failsafe-reports/*.xml
reporter: java-junit
fail-on-error: true

- name: Upload test results
uses: actions/upload-artifact@v4
if: always()
with:
name: test-results-ubuntu-latest-java${{ matrix.java }}
path: |
target/surefire-reports/
target/failsafe-reports/
target/site/jacoco/
retention-days: 30

Expand Down Expand Up @@ -104,7 +104,7 @@ jobs:
restore-keys: ${{ runner.os }}-m2

- name: Run tests with coverage
run: mvn clean test jacoco:report
run: mvn clean verify jacoco:report

- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v4
Expand Down
126 changes: 14 additions & 112 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,53 +36,20 @@ jobs:
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2

- name: Clean and compile
run: mvn clean compile test-compile

- name: Run all unit tests
run: mvn test -Dtest=RedlockConfigurationTest

- name: Run all integration tests
run: mvn test -Dtest=RedlockIntegrationTest
- name: Run unit tests
run: mvn test

- name: Run integration tests
run: mvn verify -Dmaven.test.skip.exec=false
env:
TESTCONTAINERS_RYUK_DISABLED: false

- name: Run performance tests
if: github.event.inputs.run_performance_tests == 'true' || github.event_name == 'schedule'
run: |
# Enable performance tests by removing @Disabled annotation temporarily
sed -i 's/@Disabled("Performance tests - enable manually when needed")/\/\/@Disabled("Performance tests - enable manually when needed")/g' src/test/java/org/codarama/redlock4j/performance/RedlockPerformanceTest.java
mvn test -Dtest=RedlockPerformanceTest
run: mvn test -Dgroups=performance
env:
TESTCONTAINERS_RYUK_DISABLED: false

- name: Run stress tests
run: |
echo "## Stress Test Results" >> $GITHUB_STEP_SUMMARY
echo "Running extended stress tests..." >> $GITHUB_STEP_SUMMARY

# Create a simple stress test
cat > stress-test.java << 'EOF'
import org.codarama.redlock4j.*;
import java.util.concurrent.*;
import java.util.concurrent.locks.Lock;

public class StressTest {
public static void main(String[] args) throws Exception {
RedlockConfiguration config = RedlockConfiguration.builder()
.addRedisNode("localhost", 6379)
.addRedisNode("localhost", 6380)
.addRedisNode("localhost", 6381)
.defaultLockTimeout(5, TimeUnit.SECONDS)
.build();

System.out.println("Stress test completed successfully");
}
}
EOF

echo "Stress test configuration validated" >> $GITHUB_STEP_SUMMARY

- name: Generate comprehensive test report
run: |
echo "## Nightly Test Summary" >> $GITHUB_STEP_SUMMARY
Expand All @@ -91,10 +58,10 @@ jobs:
echo "- **Java Version:** $(java -version 2>&1 | head -n 1)" >> $GITHUB_STEP_SUMMARY

# Count test results
if [ -d "target/surefire-reports" ]; then
TOTAL_TESTS=$(find target/surefire-reports -name "*.xml" -exec grep -h "tests=" {} \; | sed 's/.*tests="\([0-9]*\)".*/\1/' | awk '{sum+=$1} END {print sum}')
FAILED_TESTS=$(find target/surefire-reports -name "*.xml" -exec grep -h "failures=" {} \; | sed 's/.*failures="\([0-9]*\)".*/\1/' | awk '{sum+=$1} END {print sum}')
ERROR_TESTS=$(find target/surefire-reports -name "*.xml" -exec grep -h "errors=" {} \; | sed 's/.*errors="\([0-9]*\)".*/\1/' | awk '{sum+=$1} END {print sum}')
if [ -d "target/surefire-reports" ] || [ -d "target/failsafe-reports" ]; then
TOTAL_TESTS=$(find target/surefire-reports target/failsafe-reports -name "*.xml" 2>/dev/null -exec grep -h "tests=" {} \; | sed 's/.*tests="\([0-9]*\)".*/\1/' | awk '{sum+=$1} END {print sum}')
FAILED_TESTS=$(find target/surefire-reports target/failsafe-reports -name "*.xml" 2>/dev/null -exec grep -h "failures=" {} \; | sed 's/.*failures="\([0-9]*\)".*/\1/' | awk '{sum+=$1} END {print sum}')
ERROR_TESTS=$(find target/surefire-reports target/failsafe-reports -name "*.xml" 2>/dev/null -exec grep -h "errors=" {} \; | sed 's/.*errors="\([0-9]*\)".*/\1/' | awk '{sum+=$1} END {print sum}')

echo "- **Total Tests:** ${TOTAL_TESTS:-0}" >> $GITHUB_STEP_SUMMARY
echo "- **Failed Tests:** ${FAILED_TESTS:-0}" >> $GITHUB_STEP_SUMMARY
Expand All @@ -114,6 +81,7 @@ jobs:
name: nightly-test-results-${{ github.run_number }}
path: |
target/surefire-reports/
target/failsafe-reports/
target/site/
retention-days: 7

Expand Down Expand Up @@ -149,7 +117,7 @@ jobs:
sed -i 's/redis:7-alpine/redis:${{ matrix.redis-version }}/g' src/test/java/org/codarama/redlock4j/performance/RedlockPerformanceTest.java

- name: Run integration tests with Redis ${{ matrix.redis-version }}
run: mvn test -Dtest=RedlockIntegrationTest
run: mvn verify -Dmaven.test.skip.exec=false
env:
TESTCONTAINERS_RYUK_DISABLED: false

Expand All @@ -160,70 +128,4 @@ jobs:
echo "Tests passed with Redis ${{ matrix.redis-version }}" >> $GITHUB_STEP_SUMMARY
else
echo "Tests failed with Redis ${{ matrix.redis-version }}" >> $GITHUB_STEP_SUMMARY
fi

notification:
name: Send Notifications
runs-on: ubuntu-latest
needs: [comprehensive-test, multi-redis-version-test]
if: always()

steps:
- name: Determine overall status
id: status
run: |
if [[ "${{ needs.comprehensive-test.result }}" == "success" && "${{ needs.multi-redis-version-test.result }}" == "success" ]]; then
echo "status=success" >> $GITHUB_OUTPUT
echo "message=All nightly tests passed successfully" >> $GITHUB_OUTPUT
else
echo "status=failure" >> $GITHUB_OUTPUT
echo "message=Some nightly tests failed" >> $GITHUB_OUTPUT
fi

- name: Create issue on failure
if: steps.status.outputs.status == 'failure'
uses: actions/github-script@v7
with:
script: |
const title = `Nightly Tests Failed - ${new Date().toISOString().split('T')[0]}`;
const body = `
## Nightly Test Failure Report

**Date:** ${new Date().toISOString()}
**Workflow:** ${{ github.workflow }}
**Run ID:** ${{ github.run_id }}
**Commit:** ${{ github.sha }}

### Failed Jobs:
- Comprehensive Test: ${{ needs.comprehensive-test.result }}
- Multi Redis Version Test: ${{ needs.multi-redis-version-test.result }}

### Action Required:
Please investigate the test failures and fix any issues.

**Workflow URL:** ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
`;

// Check if issue already exists
const issues = await github.rest.issues.listForRepo({
owner: context.repo.owner,
repo: context.repo.repo,
labels: ['nightly-test-failure'],
state: 'open'
});

if (issues.data.length === 0) {
await github.rest.issues.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: title,
body: body,
labels: ['nightly-test-failure', 'bug']
});
}

- name: Summary
run: |
echo "## Nightly Test Summary" >> $GITHUB_STEP_SUMMARY
echo "${{ steps.status.outputs.message }}" >> $GITHUB_STEP_SUMMARY
echo "**Workflow completed at:** $(date)" >> $GITHUB_STEP_SUMMARY
fi
121 changes: 0 additions & 121 deletions .github/workflows/pr-validation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,127 +11,6 @@ permissions:
pull-requests: write

jobs:
validate-pr:
name: Validate Pull Request
runs-on: ubuntu-latest
if: github.event.pull_request.draft == false

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch full history for better analysis

- name: Set up JDK 11
uses: actions/setup-java@v4
with:
java-version: 11
distribution: 'temurin'

- name: Cache Maven dependencies
uses: actions/cache@v4
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2

- name: Validate Maven POM
run: mvn validate

- name: Compile project
run: mvn clean compile test-compile

- name: Run unit tests
run: mvn test -Dtest=RedlockConfigurationTest

- name: Run integration tests
run: mvn test -Dtest=RedlockIntegrationTest
env:
TESTCONTAINERS_RYUK_DISABLED: false

- name: Generate test coverage
run: mvn jacoco:report

- name: Check code coverage
run: |
COVERAGE=$(mvn jacoco:report | grep -o 'Total.*[0-9]*%' | tail -1 | grep -o '[0-9]*%' || echo "0%")
echo "Code coverage: $COVERAGE"
echo "## PR Validation Results" >> $GITHUB_STEP_SUMMARY
echo "- **Code Coverage:** $COVERAGE" >> $GITHUB_STEP_SUMMARY
echo "- **Build Status:** Passed" >> $GITHUB_STEP_SUMMARY

- name: Comment PR with results
uses: actions/github-script@v7
if: always() && github.event.pull_request.head.repo.full_name == github.repository
with:
script: |
const fs = require('fs');

// Read test results
let testResults = "Tests completed";
try {
const summaryFile = process.env.GITHUB_STEP_SUMMARY;
if (fs.existsSync(summaryFile)) {
testResults = fs.readFileSync(summaryFile, 'utf8');
}
} catch (error) {
console.log('Could not read test results:', error);
}

const jobStatus = '${{ job.status }}';
const statusText = jobStatus === 'success' ? 'Passed' : 'Failed';
const nextSteps = jobStatus === 'success'
? 'All checks passed! This PR is ready for review.'
: 'Some checks failed. Please review the workflow logs and fix any issues.';

const comment = `
## PR Validation Results

**Commit:** \`${{ github.event.pull_request.head.sha }}\`
**Status:** ${statusText}

### Test Results
- Maven POM validation
- Project compilation
- Unit tests
- Integration tests with Testcontainers
- Code coverage analysis

### Next Steps
${nextSteps}

**Workflow:** [${{ github.workflow }}](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})
`;

// Find existing comment
const comments = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
});

const existingComment = comments.data.find(comment =>
comment.body.includes('PR Validation Results')
);

if (existingComment) {
// Update existing comment
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: existingComment.id,
body: comment
});
} else {
// Create new comment
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: comment
});
}

security-scan:
name: Security Scan
runs-on: ubuntu-latest
Expand Down
Loading
Loading