|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ main, develop, 'feature/**' ] |
| 6 | + pull_request: |
| 7 | + branches: [ main, develop ] |
| 8 | + |
| 9 | +permissions: |
| 10 | + contents: read |
| 11 | + checks: write |
| 12 | + pull-requests: write |
| 13 | + |
| 14 | +jobs: |
| 15 | + build: |
| 16 | + name: Build & Test (Java ${{ matrix.java }}) |
| 17 | + runs-on: ubuntu-latest |
| 18 | + strategy: |
| 19 | + fail-fast: false |
| 20 | + matrix: |
| 21 | + java: [ '17', '21' ] |
| 22 | + |
| 23 | + steps: |
| 24 | + - name: Checkout repository |
| 25 | + uses: actions/checkout@v4 |
| 26 | + with: |
| 27 | + fetch-depth: 1 |
| 28 | + |
| 29 | + - name: Set up JDK ${{ matrix.java }} |
| 30 | + uses: actions/setup-java@v4 |
| 31 | + with: |
| 32 | + java-version: ${{ matrix.java }} |
| 33 | + distribution: 'temurin' |
| 34 | + cache: 'maven' |
| 35 | + |
| 36 | + - name: Build and test with Maven |
| 37 | + run: mvn -B clean verify -Pqa -Ddependency-check.skip=true |
| 38 | + |
| 39 | + - name: Upload test results |
| 40 | + uses: actions/upload-artifact@v4 |
| 41 | + if: always() |
| 42 | + with: |
| 43 | + name: test-results-java-${{ matrix.java }} |
| 44 | + path: | |
| 45 | + **/target/surefire-reports/ |
| 46 | + **/target/failsafe-reports/ |
| 47 | + retention-days: 7 |
| 48 | + |
| 49 | + - name: Upload coverage report |
| 50 | + uses: actions/upload-artifact@v4 |
| 51 | + if: matrix.java == '21' |
| 52 | + with: |
| 53 | + name: coverage-report |
| 54 | + path: | |
| 55 | + **/target/site/jacoco/ |
| 56 | + **/target/jacoco.exec |
| 57 | + retention-days: 7 |
| 58 | + |
| 59 | + - name: Publish Test Report |
| 60 | + uses: mikepenz/action-junit-report@v4 |
| 61 | + if: always() |
| 62 | + with: |
| 63 | + report_paths: '**/target/*-reports/TEST-*.xml' |
| 64 | + check_name: Test Report (Java ${{ matrix.java }}) |
| 65 | + |
| 66 | + quality: |
| 67 | + name: Code Quality Analysis |
| 68 | + runs-on: ubuntu-latest |
| 69 | + needs: build |
| 70 | + |
| 71 | + steps: |
| 72 | + - name: Checkout repository |
| 73 | + uses: actions/checkout@v4 |
| 74 | + with: |
| 75 | + fetch-depth: 1 |
| 76 | + |
| 77 | + - name: Set up JDK 21 |
| 78 | + uses: actions/setup-java@v4 |
| 79 | + with: |
| 80 | + java-version: '21' |
| 81 | + distribution: 'temurin' |
| 82 | + cache: 'maven' |
| 83 | + |
| 84 | + - name: Install artifacts for analysis |
| 85 | + run: mvn -B -Ddependency-check.skip=true clean install -Pqa -DskipTests |
| 86 | + |
| 87 | + - name: Run SpotBugs analysis |
| 88 | + run: mvn -B spotbugs:check -Pqa -Ddependency-check.skip=true |
| 89 | + continue-on-error: true |
| 90 | + |
| 91 | + - name: Run Checkstyle analysis |
| 92 | + run: mvn -B checkstyle:check -Pqa -Ddependency-check.skip=true |
| 93 | + continue-on-error: true |
| 94 | + |
| 95 | + - name: Upload SpotBugs report |
| 96 | + uses: actions/upload-artifact@v4 |
| 97 | + if: always() |
| 98 | + with: |
| 99 | + name: spotbugs-report |
| 100 | + path: '**/target/spotbugsXml.xml' |
| 101 | + retention-days: 7 |
| 102 | + |
| 103 | + - name: Upload Checkstyle report |
| 104 | + uses: actions/upload-artifact@v4 |
| 105 | + if: always() |
| 106 | + with: |
| 107 | + name: checkstyle-report |
| 108 | + path: '**/target/checkstyle-result.xml' |
| 109 | + retention-days: 7 |
| 110 | + |
| 111 | + dependency-check: |
| 112 | + name: OWASP Dependency Check |
| 113 | + runs-on: ubuntu-latest |
| 114 | + needs: build |
| 115 | + env: |
| 116 | + NVD_API_KEY: ${{ secrets.NVD_API_KEY }} |
| 117 | + |
| 118 | + steps: |
| 119 | + - name: Checkout repository |
| 120 | + uses: actions/checkout@v4 |
| 121 | + |
| 122 | + - name: Set up JDK 21 |
| 123 | + uses: actions/setup-java@v4 |
| 124 | + with: |
| 125 | + java-version: '21' |
| 126 | + distribution: 'temurin' |
| 127 | + cache: 'maven' |
| 128 | + |
| 129 | + - name: Cache Dependency-Check DB |
| 130 | + uses: actions/cache@v4 |
| 131 | + with: |
| 132 | + path: ~/.m2/repository/org/owasp/dependency-check-data |
| 133 | + key: depcheck-${{ runner.os }}-${{ hashFiles('**/pom.xml') }} |
| 134 | + restore-keys: | |
| 135 | + depcheck-${{ runner.os }}- |
| 136 | +
|
| 137 | + - name: Run OWASP Dependency Check |
| 138 | + run: mvn -B dependency-check:aggregate -Pqa |
| 139 | + continue-on-error: true |
| 140 | + |
| 141 | + - name: Upload Dependency Check report |
| 142 | + uses: actions/upload-artifact@v4 |
| 143 | + if: always() |
| 144 | + with: |
| 145 | + name: dependency-check-report |
| 146 | + path: | |
| 147 | + target/dependency-check-report.html |
| 148 | + retention-days: 30 |
0 commit comments