update README.md file #2
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: CI with Coverage | |
| # This workflow runs tests and generates code coverage reports | |
| # To use this instead of ci.yml: | |
| # 1. Rename this file to ci.yml | |
| # 2. Backup or delete the current ci.yml | |
| # 3. (Optional) Set up Codecov for coverage badges | |
| on: | |
| push: | |
| branches: [ main, develop ] | |
| pull_request: | |
| branches: [ main, develop ] | |
| jobs: | |
| test-with-coverage: | |
| name: Test with Coverage | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up JDK 17 | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: '17' | |
| distribution: 'temurin' | |
| cache: maven | |
| - name: Run tests with coverage | |
| run: mvn -B clean test jacoco:report | |
| - name: Publish test results | |
| uses: EnricoMi/publish-unit-test-result-action@v2 | |
| if: always() | |
| with: | |
| files: target/surefire-reports/**/*.xml | |
| - name: Upload test reports | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: test-reports | |
| path: target/surefire-reports/ | |
| - name: Upload coverage reports | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: coverage-reports | |
| path: target/site/jacoco/ | |
| - name: Add coverage comment to PR | |
| if: github.event_name == 'pull_request' | |
| uses: madrapps/jacoco-report@v1.6.1 | |
| with: | |
| paths: target/site/jacoco/jacoco.xml | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| min-coverage-overall: 50 | |
| min-coverage-changed-files: 50 | |
| # Optional: Upload to Codecov | |
| # Uncomment if you want to use Codecov for coverage tracking | |
| # - name: Upload to Codecov | |
| # uses: codecov/codecov-action@v4 | |
| # with: | |
| # file: target/site/jacoco/jacoco.xml | |
| # token: ${{ secrets.CODECOV_TOKEN }} | |
| check-coverage: | |
| name: Check Coverage Threshold | |
| runs-on: ubuntu-latest | |
| needs: test-with-coverage | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up JDK 17 | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: '17' | |
| distribution: 'temurin' | |
| cache: maven | |
| - name: Verify coverage threshold | |
| run: mvn -B verify | |
| build: | |
| name: Build Application | |
| runs-on: ubuntu-latest | |
| needs: [test-with-coverage, check-coverage] | |
| if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop' | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up JDK 17 | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: '17' | |
| distribution: 'temurin' | |
| cache: maven | |
| - name: Build with Maven | |
| run: mvn -B clean package -DskipTests | |
| - name: Upload build artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: library-management-jar | |
| path: target/*.jar | |
| retention-days: 7 |