|
| 1 | +name: PR Checks |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + branches: [develop, main] |
| 6 | + |
| 7 | +jobs: |
| 8 | + |
| 9 | + detect-changes: |
| 10 | + name: Detect Changed Services |
| 11 | + runs-on: ubuntu-latest |
| 12 | + outputs: |
| 13 | + api-gateway: ${{ steps.changes.outputs.api-gateway }} |
| 14 | + user-service: ${{ steps.changes.outputs.user-service }} |
| 15 | + post-service: ${{ steps.changes.outputs.post-service }} |
| 16 | + connections-service: ${{ steps.changes.outputs.connections-service }} |
| 17 | + notification-service: ${{ steps.changes.outputs.notification-service }} |
| 18 | + uploader-service: ${{ steps.changes.outputs.uploader-service }} |
| 19 | + config-server: ${{ steps.changes.outputs.config-server }} |
| 20 | + discovery-server: ${{ steps.changes.outputs.discovery-server }} |
| 21 | + steps: |
| 22 | + - uses: actions/checkout@v4 |
| 23 | + - uses: dorny/paths-filter@v3 |
| 24 | + id: changes |
| 25 | + with: |
| 26 | + filters: | |
| 27 | + api-gateway: |
| 28 | + - 'api-gateway/**' |
| 29 | + user-service: |
| 30 | + - 'user-service/**' |
| 31 | + post-service: |
| 32 | + - 'post-service/**' |
| 33 | + connections-service: |
| 34 | + - 'connections-service/**' |
| 35 | + notification-service: |
| 36 | + - 'notification-service/**' |
| 37 | + uploader-service: |
| 38 | + - 'uploader-service/**' |
| 39 | + config-server: |
| 40 | + - 'config-server/**' |
| 41 | + discovery-server: |
| 42 | + - 'discovery-server/**' |
| 43 | +
|
| 44 | + unit-tests: |
| 45 | + name: Unit Tests |
| 46 | + runs-on: ubuntu-latest |
| 47 | + continue-on-error: true |
| 48 | + steps: |
| 49 | + - uses: actions/checkout@v4 |
| 50 | + - name: Set up JDK 17 |
| 51 | + uses: actions/setup-java@v4 |
| 52 | + with: |
| 53 | + java-version: '17' |
| 54 | + distribution: 'corretto' |
| 55 | + cache: maven |
| 56 | + - name: Run unit tests |
| 57 | + run: | |
| 58 | + if [ -f "pom.xml" ]; then |
| 59 | + mvn test -DskipIntegrationTests=true || true |
| 60 | + else |
| 61 | + echo "No root pom.xml found — skipping tests" |
| 62 | + fi |
| 63 | + - name: Upload test results |
| 64 | + uses: actions/upload-artifact@v4 |
| 65 | + if: always() |
| 66 | + continue-on-error: true |
| 67 | + with: |
| 68 | + name: unit-test-results |
| 69 | + path: '**/target/surefire-reports/*.xml' |
| 70 | + |
| 71 | + code-coverage: |
| 72 | + name: Code Coverage |
| 73 | + runs-on: ubuntu-latest |
| 74 | + continue-on-error: true |
| 75 | + steps: |
| 76 | + - uses: actions/checkout@v4 |
| 77 | + - name: Set up JDK 17 |
| 78 | + uses: actions/setup-java@v4 |
| 79 | + with: |
| 80 | + java-version: '17' |
| 81 | + distribution: 'corretto' |
| 82 | + cache: maven |
| 83 | + - name: Run tests with coverage |
| 84 | + run: | |
| 85 | + if [ -f "pom.xml" ]; then |
| 86 | + mvn verify jacoco:report -DskipIntegrationTests=true || true |
| 87 | + else |
| 88 | + echo "No root pom.xml — skipping coverage" |
| 89 | + fi |
| 90 | + - name: Upload coverage report |
| 91 | + uses: actions/upload-artifact@v4 |
| 92 | + continue-on-error: true |
| 93 | + with: |
| 94 | + name: coverage-report |
| 95 | + path: '**/target/site/jacoco/' |
| 96 | + |
| 97 | + security-scan: |
| 98 | + name: Security Scan |
| 99 | + runs-on: ubuntu-latest |
| 100 | + continue-on-error: true |
| 101 | + steps: |
| 102 | + - uses: actions/checkout@v4 |
| 103 | + - name: Set up JDK 17 |
| 104 | + uses: actions/setup-java@v4 |
| 105 | + with: |
| 106 | + java-version: '17' |
| 107 | + distribution: 'corretto' |
| 108 | + cache: maven |
| 109 | + - name: OWASP Dependency Check |
| 110 | + run: | |
| 111 | + if [ -f "pom.xml" ]; then |
| 112 | + mvn dependency-check:check \ |
| 113 | + -DfailBuildOnCVSS=7 \ |
| 114 | + -DskipTestScope=true || true |
| 115 | + else |
| 116 | + echo "No root pom.xml — skipping OWASP" |
| 117 | + fi |
| 118 | + continue-on-error: true |
| 119 | + - name: Upload OWASP report |
| 120 | + uses: actions/upload-artifact@v4 |
| 121 | + if: always() |
| 122 | + continue-on-error: true |
| 123 | + with: |
| 124 | + name: owasp-report |
| 125 | + path: '**/target/dependency-check-report.html' |
| 126 | + |
| 127 | + code-quality: |
| 128 | + name: Code Quality |
| 129 | + runs-on: ubuntu-latest |
| 130 | + continue-on-error: true |
| 131 | + steps: |
| 132 | + - uses: actions/checkout@v4 |
| 133 | + with: |
| 134 | + fetch-depth: 0 |
| 135 | + - name: Set up JDK 17 |
| 136 | + uses: actions/setup-java@v4 |
| 137 | + with: |
| 138 | + java-version: '17' |
| 139 | + distribution: 'corretto' |
| 140 | + cache: maven |
| 141 | + - name: Checkstyle |
| 142 | + run: | |
| 143 | + if [ -f "pom.xml" ]; then |
| 144 | + mvn checkstyle:check || true |
| 145 | + else |
| 146 | + echo "No root pom.xml — skipping checkstyle" |
| 147 | + fi |
| 148 | + continue-on-error: true |
| 149 | + - name: SpotBugs |
| 150 | + run: | |
| 151 | + if [ -f "pom.xml" ]; then |
| 152 | + mvn spotbugs:check || true |
| 153 | + else |
| 154 | + echo "No root pom.xml — skipping spotbugs" |
| 155 | + fi |
| 156 | + continue-on-error: true |
0 commit comments