66
77jobs :
88
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-
449 unit-tests :
4510 name : Unit Tests
4611 runs-on : ubuntu-latest
47- continue-on-error : true
4812 steps :
4913 - uses : actions/checkout@v4
5014 - name : Set up JDK 17
@@ -55,23 +19,21 @@ jobs:
5519 cache : maven
5620 - name : Run unit tests
5721 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
22+ for svc in user-service post-service connections-service notification-service uploader-service; do
23+ echo "=== Testing $svc ==="
24+ cd $svc && mvn test -q && cd ..
25+ done
6326 - name : Upload test results
6427 uses : actions/upload-artifact@v4
6528 if : always()
66- continue-on-error : true
6729 with :
6830 name : unit-test-results
6931 path : ' **/target/surefire-reports/*.xml'
7032
7133 code-coverage :
7234 name : Code Coverage
7335 runs-on : ubuntu-latest
74- continue-on-error : true
36+ needs : unit-tests
7537 steps :
7638 - uses : actions/checkout@v4
7739 - name : Set up JDK 17
@@ -82,14 +44,12 @@ jobs:
8244 cache : maven
8345 - name : Run tests with coverage
8446 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
47+ for svc in user-service post-service connections-service notification-service uploader-service; do
48+ echo "=== Coverage for $svc ==="
49+ cd $svc && mvn test jacoco:report -q && cd ..
50+ done
9051 - name : Upload coverage report
9152 uses : actions/upload-artifact@v4
92- continue-on-error : true
9353 with :
9454 name : coverage-report
9555 path : ' **/target/site/jacoco/'
@@ -108,18 +68,14 @@ jobs:
10868 cache : maven
10969 - name : OWASP Dependency Check
11070 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
71+ for svc in user-service post-service connections-service notification-service uploader-service; do
72+ echo "=== OWASP scan for $svc ==="
73+ cd $svc && mvn dependency-check:check -DfailBuildOnCVSS=7 -DskipTestScope=true || true
74+ cd ..
75+ done
11976 - name : Upload OWASP report
12077 uses : actions/upload-artifact@v4
12178 if : always()
122- continue-on-error : true
12379 with :
12480 name : owasp-report
12581 path : ' **/target/dependency-check-report.html'
13086 continue-on-error : true
13187 steps :
13288 - uses : actions/checkout@v4
133- with :
134- fetch-depth : 0
13589 - name : Set up JDK 17
13690 uses : actions/setup-java@v4
13791 with :
@@ -140,17 +94,54 @@ jobs:
14094 cache : maven
14195 - name : Checkstyle
14296 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
97+ for svc in user-service post-service connections-service notification-service uploader-service; do
98+ echo "=== Checkstyle for $svc ==="
99+ cd $svc && mvn checkstyle:check -q || true
100+ cd ..
101+ done
149102 - name : SpotBugs
150103 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
104+ for svc in user-service post-service connections-service notification-service uploader-service; do
105+ echo "=== SpotBugs for $svc ==="
106+ cd $svc && mvn compile spotbugs:check -q || true
107+ cd ..
108+ done
109+
110+ sonarcloud :
111+ name : SonarCloud Analysis
112+ runs-on : ubuntu-latest
113+ needs : unit-tests
114+ continue-on-error : true
115+ steps :
116+ - uses : actions/checkout@v4
117+ with :
118+ fetch-depth : 0
119+ - name : Set up JDK 17
120+ uses : actions/setup-java@v4
121+ with :
122+ java-version : ' 17'
123+ distribution : ' corretto'
124+ cache : maven
125+ - name : Cache SonarCloud packages
126+ uses : actions/cache@v4
127+ with :
128+ path : ~/.sonar/cache
129+ key : ${{ runner.os }}-sonar
130+ restore-keys : ${{ runner.os }}-sonar
131+ - name : SonarCloud Scan
132+ env :
133+ SONAR_TOKEN : ${{ secrets.SONAR_TOKEN }}
134+ run : |
135+ for svc in user-service post-service connections-service notification-service uploader-service; do
136+ echo "=== Scanning $svc ==="
137+ cd $svc
138+ mvn verify jacoco:report sonar:sonar -DskipTests \
139+ -Dsonar.projectKey=premtsd-code_LinkedIn_${svc} \
140+ -Dsonar.organization=premtsd-code \
141+ -Dsonar.host.url=https://sonarcloud.io \
142+ -Dsonar.projectName="${svc}" \
143+ -Dsonar.java.coveragePlugin=jacoco \
144+ -Dsonar.coverage.jacoco.xmlReportPaths=target/site/jacoco/jacoco.xml \
145+ || true
146+ cd ..
147+ done
0 commit comments