Feat/ci cd pipeline #2
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: PR - Quality Checks | |
| on: | |
| pull_request: | |
| branches: [ main ] | |
| types: [ opened, synchronize, reopened, ready_for_review ] | |
| jobs: | |
| quality-checks: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v6 | |
| - name: Set up JDK 25 | |
| uses: actions/setup-java@v5 | |
| with: | |
| distribution: 'temurin' | |
| java-version: '25' | |
| cache: 'maven' | |
| check-latest: true | |
| - name: Check code formatting with Spotless | |
| run: mvn spotless:check | |
| - name: Run static code analysis with PMD | |
| run: mvn pmd:check | |
| continue-on-error: true | |
| - name: Check for vulnerabilities | |
| run: mvn dependency-check:check | |
| continue-on-error: true | |
| - name: Run all tests with coverage | |
| run: mvn test jacoco:report | |
| - name: Upload test results | |
| if: always() | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: test-reports | |
| path: target/surefire-reports/ | |
| - name: Upload coverage report | |
| if: always() | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: coverage-report | |
| path: target/site/jacoco/ | |
| - name: Comment PR with coverage summary | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| const fs = require('fs'); | |
| try { | |
| const coverage = fs.readFileSync('target/site/jacoco/index.html', 'utf8'); | |
| const match = coverage.match(/Total<\/td><td[^>]*>(\d+)%<\/td>/); | |
| if (match) { | |
| const coveragePercent = match[1]; | |
| await github.rest.issues.createComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: context.payload.pull_request.number, | |
| body: `## Test Coverage Report\n\n**Coverage: ${coveragePercent}%**\n\nQuality checks completed.\n\nFull coverage report available in workflow artifacts.` | |
| }); | |
| } else { | |
| await github.rest.issues.createComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: context.payload.pull_request.number, | |
| body: `## Test Coverage Report\n\nCoverage report generated but could not parse percentage. Check artifacts for details.` | |
| }); | |
| } | |
| } catch(e) { | |
| console.log('Could not parse coverage report:', e.message); | |
| } |