test workflow

This commit is contained in:
Branislav Stojkovic
2025-03-19 14:38:51 +01:00
parent 8ddb685d9d
commit c5293da570
2 changed files with 52 additions and 0 deletions
+51
View File
@@ -0,0 +1,51 @@
name: Java CI Tests
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up JDK
uses: actions/setup-java@v3
with:
java-version: '11' # Adjust version as needed
distribution: 'temurin'
cache: maven
- name: Run Tests
run: mvn test
# Generate and report coverage without failing
- name: Generate Coverage Report
run: mvn jacoco:report
- name: Report Coverage
run: |
COVERAGE=$(mvn jacoco:report | grep -oP 'Total coverage: \K[0-9.]+' || echo "unknown")
echo "Current test coverage: $COVERAGE%"
- name: Upload Coverage Report
uses: actions/upload-artifact@v3
with:
name: coverage-report
path: target/site/jacoco/
# Optional: Comment test results on PR
- name: Add Test Results Comment
uses: marocchino/sticky-pull-request-comment@v2
if: github.event_name == 'pull_request'
with:
message: |
### Test Results Summary
✅ Tests completed
📊 Coverage: ${{ env.COVERAGE }}%
Coverage report available in workflow artifacts
+1
View File
@@ -0,0 +1 @@
[![Java CI Tests](https://github.com/{owner}/{repo}/actions/workflows/tests.yml/badge.svg)](https://github.com/{owner}/{repo}/actions/workflows/tests.yml)