Skip to content

Commit 08d3704

Browse files
committed
Updated the Code-quality action to be also done for taxonomy service.
1 parent 714e9a9 commit 08d3704

1 file changed

Lines changed: 121 additions & 27 deletions

File tree

.github/workflows/Code-Quality-check.yml

Lines changed: 121 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,21 @@ permissions:
1111
checks: write
1212
statuses: write
1313

14+
env:
15+
CLOUD_STORE_GROUP_ID: ${{ vars.CLOUD_STORE_GROUP_ID }}
16+
CLOUD_STORE_ARTIFACT_ID: ${{ vars.CLOUD_STORE_ARTIFACT_ID }}
17+
CLOUD_STORE_VERSION: ${{ vars.CLOUD_STORE_VERSION }}
18+
1419
jobs:
15-
test-and-quality:
20+
build:
1621
runs-on: ubuntu-latest
22+
outputs:
23+
maven_cache_key: ${{ runner.os }}-maven-${{ steps.cache.outputs.cache-hit }}
1724
steps:
1825
- uses: actions/checkout@v3
1926
with:
20-
fetch-depth: 0 # Important for SonarQube to get full history
21-
27+
fetch-depth: 0
28+
2229
- name: Set up JDK 11
2330
uses: actions/setup-java@v3
2431
with:
@@ -34,67 +41,154 @@ jobs:
3441
restore-keys: |
3542
${{ runner.os }}-maven-
3643
37-
- name: Build and Run Tests
44+
- name: Build Knowledge Platform
3845
run: |
3946
mvn clean install -DskipTests=true \
40-
-DCLOUD_STORE_GROUP_ID=${{ vars.CLOUD_STORE_GROUP_ID }} \
41-
-DCLOUD_STORE_ARTIFACT_ID=${{ vars.CLOUD_STORE_ARTIFACT_ID }} \
42-
-DCLOUD_STORE_VERSION=${{ vars.CLOUD_STORE_VERSION }}
43-
echo "Running the test cases"
44-
cd content-api/content-service/
47+
-DCLOUD_STORE_GROUP_ID=${CLOUD_STORE_GROUP_ID} \
48+
-DCLOUD_STORE_ARTIFACT_ID=${CLOUD_STORE_ARTIFACT_ID} \
49+
-DCLOUD_STORE_VERSION=${CLOUD_STORE_VERSION}
50+
51+
test-content:
52+
needs: build
53+
runs-on: ubuntu-latest
54+
steps:
55+
- uses: actions/checkout@v3
56+
- name: Set up JDK 11
57+
uses: actions/setup-java@v3
58+
with:
59+
java-version: '11'
60+
distribution: 'temurin'
61+
cache: 'maven'
62+
63+
- name: Run Content Service Tests
64+
working-directory: content-api/content-service/
65+
run: |
4566
mvn clean test org.jacoco:jacoco-maven-plugin:0.8.8:prepare-agent test org.jacoco:jacoco-maven-plugin:0.8.8:report \
46-
-DCLOUD_STORE_GROUP_ID=${{ vars.CLOUD_STORE_GROUP_ID }} \
47-
-DCLOUD_STORE_ARTIFACT_ID=${{ vars.CLOUD_STORE_ARTIFACT_ID }} \
48-
-DCLOUD_STORE_VERSION=${{ vars.CLOUD_STORE_VERSION }}
67+
-DCLOUD_STORE_GROUP_ID=${CLOUD_STORE_GROUP_ID} \
68+
-DCLOUD_STORE_ARTIFACT_ID=${CLOUD_STORE_ARTIFACT_ID} \
69+
-DCLOUD_STORE_VERSION=${CLOUD_STORE_VERSION}
4970
50-
- name: Upload Test Results
71+
- name: Upload Content Test Results
5172
if: always()
5273
uses: actions/upload-artifact@v4
5374
with:
54-
name: test-results
75+
name: content-test-results
5576
path: 'content-api/content-service/target/surefire-reports/*.xml'
5677

57-
- name: Publish Test Results
78+
- name: Publish Content Test Results
5879
if: always()
5980
uses: dorny/test-reporter@v1
6081
with:
61-
name: Test Results
82+
name: Content Test Results
6283
path: content-api/content-service/target/surefire-reports/*.xml
6384
reporter: java-junit
6485
fail-on-error: true
6586

87+
test-taxonomy:
88+
needs: build
89+
runs-on: ubuntu-latest
90+
steps:
91+
- uses: actions/checkout@v3
92+
- name: Set up JDK 11
93+
uses: actions/setup-java@v3
94+
with:
95+
java-version: '11'
96+
distribution: 'temurin'
97+
cache: 'maven'
98+
99+
- name: Run Taxonomy Tests
100+
working-directory: taxonomy-api/taxonomy-service/
101+
run: |
102+
mvn clean test org.jacoco:jacoco-maven-plugin:0.8.8:prepare-agent test org.jacoco:jacoco-maven-plugin:0.8.8:report \
103+
-DCLOUD_STORE_GROUP_ID=${CLOUD_STORE_GROUP_ID} \
104+
-DCLOUD_STORE_ARTIFACT_ID=${CLOUD_STORE_ARTIFACT_ID} \
105+
-DCLOUD_STORE_VERSION=${CLOUD_STORE_VERSION}
106+
107+
- name: Upload Taxonomy Test Results
108+
if: always()
109+
uses: actions/upload-artifact@v4
110+
with:
111+
name: taxonomy-test-results
112+
path: 'taxonomy-api/taxonomy-service/target/surefire-reports/*.xml'
113+
114+
- name: Publish Taxonomy Test Results
115+
if: always()
116+
uses: dorny/test-reporter@v1
117+
with:
118+
name: Taxonomy Test Results
119+
path: taxonomy-api/taxonomy-service/target/surefire-reports/*.xml
120+
reporter: java-junit
121+
fail-on-error: true
122+
123+
sonar-analysis-content:
124+
needs: test-content
125+
runs-on: ubuntu-latest
126+
steps:
127+
- uses: actions/checkout@v3
66128
- name: Set up JDK 17
67-
uses: actions/setup-java@v2
129+
uses: actions/setup-java@v3
68130
with:
69131
java-version: '17'
70132
distribution: 'temurin'
71-
72-
- name: SonarCloud Analysis
133+
cache: 'maven'
134+
- name: Run SonarCloud Analysis for Content
73135
env:
74136
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
75137
working-directory: content-api/content-service
76138
run: |
77139
mvn sonar:sonar \
78-
-DCLOUD_STORE_GROUP_ID=${{ vars.CLOUD_STORE_GROUP_ID }} \
79-
-DCLOUD_STORE_ARTIFACT_ID=${{ vars.CLOUD_STORE_ARTIFACT_ID }} \
80-
-DCLOUD_STORE_VERSION=${{ vars.CLOUD_STORE_VERSION }} \
140+
-DCLOUD_STORE_GROUP_ID=${CLOUD_STORE_GROUP_ID} \
141+
-DCLOUD_STORE_ARTIFACT_ID=${CLOUD_STORE_ARTIFACT_ID} \
142+
-DCLOUD_STORE_VERSION=${CLOUD_STORE_VERSION} \
81143
-Dsonar.projectKey=Sunbird-Knowlg_knowledge-platform \
82144
-Dsonar.organization=sunbird-knowlg-1 \
83145
-Dsonar.host.url=https://sonarcloud.io \
84146
-Dsonar.coverage.jacoco.xmlReportPaths=content-api/content-service/target/site/jacoco/jacoco.xml
85147
148+
sonar-analysis-taxonomy:
149+
needs: test-taxonomy
150+
runs-on: ubuntu-latest
151+
steps:
152+
- uses: actions/checkout@v3
153+
- name: Set up JDK 17
154+
uses: actions/setup-java@v3
155+
with:
156+
java-version: '17'
157+
distribution: 'temurin'
158+
cache: 'maven'
159+
- name: Run SonarCloud Analysis for Taxonomy
160+
env:
161+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
162+
working-directory: taxonomy-api/taxonomy-service
163+
run: |
164+
mvn sonar:sonar \
165+
-DCLOUD_STORE_GROUP_ID=${CLOUD_STORE_GROUP_ID} \
166+
-DCLOUD_STORE_ARTIFACT_ID=${CLOUD_STORE_ARTIFACT_ID} \
167+
-DCLOUD_STORE_VERSION=${CLOUD_STORE_VERSION} \
168+
-Dsonar.projectKey=Sunbird-Knowlg_knowledge-platform \
169+
-Dsonar.organization=sunbird-knowlg-1 \
170+
-Dsonar.host.url=https://sonarcloud.io \
171+
-Dsonar.coverage.jacoco.xmlReportPaths=taxonomy-api/taxonomy-service/target/site/jacoco/jacoco.xml
86172
173+
comment-pr:
174+
needs: [sonar-analysis-content, sonar-analysis-taxonomy]
175+
if: github.event_name == 'pull_request'
176+
runs-on: ubuntu-latest
177+
steps:
87178
- name: Comment PR with SonarQube Results
88179
uses: actions/github-script@v6
89-
if: github.event_name == 'pull_request' && always()
90180
with:
91181
script: |
92-
const sonarUrl = `https://sonarcloud.io/dashboard?id=Sunbird-Knowlg_knowledge-platform`;
93-
const message = `### Quality Gate Results
94-
Check the detailed SonarQube analysis at: ${sonarUrl}`;
182+
const message = `### SonarCloud Analysis Results 🔍
183+
184+
#### Quality Gate Results for Services:
185+
- [Service Analysis](https://sonarcloud.io/dashboard?id=Sunbird-Knowlg_knowledge-platform)
186+
187+
Please review the analysis results for each service. Ensure all quality gates are passing before merging.`;
188+
95189
github.rest.issues.createComment({
96190
owner: context.repo.owner,
97191
repo: context.repo.repo,
98192
issue_number: context.issue.number,
99193
body: message
100-
});
194+
});

0 commit comments

Comments
 (0)