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
11 changes: 8 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ on:
workflow_dispatch:
# Allow manual triggering

permissions:
contents: read
checks: write
pull-requests: write

jobs:
test:
name: Test on ubuntu-latest with Java ${{ matrix.java }}
Expand Down Expand Up @@ -58,7 +63,7 @@ jobs:

- name: Generate test report
uses: dorny/test-reporter@v1
if: success() || failure()
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
Expand Down Expand Up @@ -141,7 +146,7 @@ jobs:
- name: Check for Maven wrapper
run: |
if [ -f "mvnw" ]; then
echo "Maven wrapper found" >> $GITHUB_STEP_SUMMARY
echo "Maven wrapper found" >> $GITHUB_STEP_SUMMARY
else
echo "ℹ️ Maven wrapper not found (using system Maven)" >> $GITHUB_STEP_SUMMARY
echo "Maven wrapper not found (using system Maven)" >> $GITHUB_STEP_SUMMARY
fi
20 changes: 10 additions & 10 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ jobs:
}
}
EOF
echo "Stress test configuration validated" >> $GITHUB_STEP_SUMMARY

echo "Stress test configuration validated" >> $GITHUB_STEP_SUMMARY

- name: Generate comprehensive test report
run: |
Expand All @@ -99,11 +99,11 @@ jobs:
echo "- **Total Tests:** ${TOTAL_TESTS:-0}" >> $GITHUB_STEP_SUMMARY
echo "- **Failed Tests:** ${FAILED_TESTS:-0}" >> $GITHUB_STEP_SUMMARY
echo "- **Error Tests:** ${ERROR_TESTS:-0}" >> $GITHUB_STEP_SUMMARY

if [ "${FAILED_TESTS:-0}" -eq 0 ] && [ "${ERROR_TESTS:-0}" -eq 0 ]; then
echo "- **Status:** All tests passed" >> $GITHUB_STEP_SUMMARY
echo "- **Status:** All tests passed" >> $GITHUB_STEP_SUMMARY
else
echo "- **Status:** Some tests failed" >> $GITHUB_STEP_SUMMARY
echo "- **Status:** Some tests failed" >> $GITHUB_STEP_SUMMARY
fi
fi

Expand Down Expand Up @@ -146,7 +146,7 @@ jobs:
run: |
# Update the Redis image version in test files
sed -i 's/redis:7-alpine/redis:${{ matrix.redis-version }}/g' src/test/java/org/codarama/redlock4j/integration/RedlockIntegrationTest.java
sed -i 's/redis:7-alpine/redis:${{ matrix.redis-version }}/g' src/test/java/org/codarama/redlock4j/pderformance/RedlockPerformanceTest.java
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
Expand All @@ -157,9 +157,9 @@ jobs:
run: |
echo "## Redis ${{ matrix.redis-version }} Test Results" >> $GITHUB_STEP_SUMMARY
if [ $? -eq 0 ]; then
echo "Tests passed with Redis ${{ matrix.redis-version }}" >> $GITHUB_STEP_SUMMARY
echo "Tests passed with Redis ${{ matrix.redis-version }}" >> $GITHUB_STEP_SUMMARY
else
echo "Tests failed with Redis ${{ matrix.redis-version }}" >> $GITHUB_STEP_SUMMARY
echo "Tests failed with Redis ${{ matrix.redis-version }}" >> $GITHUB_STEP_SUMMARY
fi

notification:
Expand All @@ -174,10 +174,10 @@ jobs:
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
echo "message=All nightly tests passed successfully" >> $GITHUB_OUTPUT
else
echo "status=failure" >> $GITHUB_OUTPUT
echo "message=Some nightly tests failed" >> $GITHUB_OUTPUT
echo "message=Some nightly tests failed" >> $GITHUB_OUTPUT
fi

- name: Create issue on failure
Expand Down
99 changes: 82 additions & 17 deletions .github/workflows/pr-validation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ on:

permissions:
contents: read
checks: write
pull-requests: write
issues: write

jobs:
validate-pr:
Expand Down Expand Up @@ -57,15 +57,80 @@ jobs:
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 "" >> $GITHUB_STEP_SUMMARY
echo "**Status:** PASSED" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### Test Results" >> $GITHUB_STEP_SUMMARY
echo "- Maven POM validation: PASSED" >> $GITHUB_STEP_SUMMARY
echo "- Project compilation: PASSED" >> $GITHUB_STEP_SUMMARY
echo "- Unit tests: PASSED" >> $GITHUB_STEP_SUMMARY
echo "- Integration tests: PASSED" >> $GITHUB_STEP_SUMMARY
echo "- Code coverage: $COVERAGE" >> $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
Expand Down Expand Up @@ -118,22 +183,22 @@ jobs:

- name: Check license headers
run: |
echo "Checking license headers in Java files..."
echo "Checking SPDX-compliant license headers in Java files..."
MISSING_LICENSE=0

for file in $(find src -name "*.java"); do
if ! head -5 "$file" | grep -q "MIT License"; then
echo "Missing license header: $file"
if ! head -5 "$file" | grep -q "SPDX-License-Identifier: MIT"; then
echo "Missing SPDX license header: $file"
MISSING_LICENSE=1
fi
done

if [ $MISSING_LICENSE -eq 0 ]; then
echo "All Java files have proper license headers"
echo "- **License Headers:** All files compliant" >> $GITHUB_STEP_SUMMARY
echo "All Java files have proper SPDX license headers"
echo "- **License Headers:** All files SPDX-compliant" >> $GITHUB_STEP_SUMMARY
else
echo "Some files are missing license headers"
echo "- **License Headers:** Some files missing headers" >> $GITHUB_STEP_SUMMARY
echo "Some files are missing SPDX license headers"
echo "- **License Headers:** Some files missing SPDX headers" >> $GITHUB_STEP_SUMMARY
exit 1
fi

Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ jobs:
run: |
echo "Running tests before release..."
mvn --no-transfer-progress --batch-mode clean test -Dtest=RedlockConfigurationTest
echo "Unit tests passed"
echo "Unit tests passed"

# Run integration tests
mvn --no-transfer-progress --batch-mode test -Dtest=RedlockIntegrationTest
echo "Integration tests passed"
echo "Integration tests passed"

- name: Install GPG key
run: |
Expand All @@ -76,7 +76,7 @@ jobs:

- name: Create release summary
run: |
echo "## 🎉 Release Published Successfully" >> $GITHUB_STEP_SUMMARY
echo "## Release Published Successfully" >> $GITHUB_STEP_SUMMARY
echo "- **Version:** ${{ steps.version.outputs.version }}" >> $GITHUB_STEP_SUMMARY
echo "- **Repository:** Maven Central" >> $GITHUB_STEP_SUMMARY
echo "- **Group ID:** org.codarama" >> $GITHUB_STEP_SUMMARY
Expand Down Expand Up @@ -105,7 +105,7 @@ jobs:
script: |
const version = '${{ steps.version.outputs.version }}';
const comment = `
## 🎉 Successfully Published to Maven Central!
## Successfully Published to Maven Central!

**Version:** \`${version}\`

Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ target/
.idea/compiler.xml
.idea/libraries/
.idea/AugmentWebviewStateStore.xml
.idea/*

*.iws
*.iml
Expand Down
10 changes: 0 additions & 10 deletions .idea/AugmentWebviewStateStore.xml

This file was deleted.

69 changes: 20 additions & 49 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,52 +33,35 @@ mvn test jacoco:report
mvn org.owasp:dependency-check-maven:check
```

### Automated Testing
Our CI/CD pipeline automatically runs:

- ✅ **Compilation** on multiple platforms (Ubuntu, Windows, macOS)
- ✅ **Unit tests** with Java 8, 11, 17, and 21
- ✅ **Integration tests** with Testcontainers (Redis 6, 7, latest)
- ✅ **Code coverage** analysis with JaCoCo
- ✅ **Security scanning** with OWASP dependency check
- ✅ **License header** validation
- ✅ **Code style** checks

## 📝 Code Guidelines

### Code Style
- Use **4 spaces** for indentation (no tabs)
- Follow **Java naming conventions**
- Add **Javadoc** for public APIs
- Keep **line length** under 120 characters
- Remove **trailing whitespace**
We use automated code formatting to ensure consistency across the codebase:

- **Formatter**: Eclipse formatter with custom configuration (`formatting.xml`)
- **Indentation**: 4 spaces (no tabs)
- **Line length**: 120 characters maximum
- **Braces**: End-of-line style
- **Javadoc**: Required for all public APIs

#### Formatting Commands
```bash
# Format all code
mvn formatter:format

# Validate formatting (runs automatically during build)
mvn formatter:validate
```

**Note**: The build will fail if code is not properly formatted. Always run `mvn formatter:format` before committing.

### License Headers
All Java files must include the MIT license header:
All Java files must include an [SPDX-compliant](https://spdx.dev/learn/handling-license-info/) license header:

```java
/*
* MIT License
*
* SPDX-License-Identifier: MIT
* Copyright (c) 2025 Codarama
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
```

Expand Down Expand Up @@ -122,12 +105,6 @@ When you submit a PR, our automation will:
- **Docker** (for integration tests)
- **Git**

### IDE Setup
We recommend:
- **IntelliJ IDEA** or **Eclipse**
- **Checkstyle** plugin for code style
- **SonarLint** for code quality

### Environment Variables
For local development:
```bash
Expand Down Expand Up @@ -188,11 +165,5 @@ We welcome contributions in:
- **GitHub Discussions** - For questions and ideas
- **Code Review** - Learn from PR feedback

## 🏆 Recognition

Contributors are recognized in:
- **GitHub contributors** list
- **Release notes** for significant contributions
- **Documentation** acknowledgments

Thank you for contributing to Redlock4j! 🚀
Loading
Loading