forked from Sunbird-Knowlg/knowledge-platform
-
Notifications
You must be signed in to change notification settings - Fork 0
105 lines (89 loc) · 3.88 KB
/
content-service-pr-check.yml
File metadata and controls
105 lines (89 loc) · 3.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
name: Content Service PR Checks
on:
push:
paths:
- 'content-api/**'
jobs:
test-and-analyze:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0 # Required for SonarCloud analysis
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '11'
cache: 'maven'
- name: Build Content Service
working-directory: content-api/content-service
run: |
mvn clean install -DskipTests=true \
-DCLOUD_STORE_GROUP_ID=${{ vars.CLOUD_STORE_GROUP_ID }} \
-DCLOUD_STORE_ARTIFACT_ID=${{ vars.CLOUD_STORE_ARTIFACT_ID }} \
-DCLOUD_STORE_VERSION=${{ vars.CLOUD_STORE_VERSION }}
- name: Run Tests
working-directory: content-api/content-service
run: |
mvn test -pl content-service -am \
-DCLOUD_STORE_GROUP_ID=${{ vars.CLOUD_STORE_GROUP_ID }} \
-DCLOUD_STORE_ARTIFACT_ID=${{ vars.CLOUD_STORE_ARTIFACT_ID }} \
-DCLOUD_STORE_VERSION=${{ vars.CLOUD_STORE_VERSION }}
- name: Generate Test Coverage Report
working-directory: content-api/content-service
run: |
mvn scoverage:report
- name: SonarCloud Scan
uses: SonarSource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
with:
projectBaseDir: content-api/content-service
args: >
-Dsonar.organization=${{ vars.SONAR_ORGANIZATION }}
-Dsonar.projectKey=knowledge-platform-content-service
-Dsonar.java.binaries=target/scala-2.12/classes
-Dsonar.scala.coverage.reportPaths=target/scala-2.12/scoverage-report/scoverage.xml
-Dsonar.sources=app
-Dsonar.tests=test
-Dsonar.test.inclusions=test/**/*.*
- name: Check Quality Gate
id: sonarqube-quality-gate-check
uses: sonarsource/sonarqube-quality-gate-action@master
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
timeout-minutes: 5
# - name: Add PR Comment
# uses: actions/github-script@v6
# if: always()
# with:
# script: |
# const testResult = '${{ job.status }}';
# const sonarStatus = '${{ steps.sonarqube-quality-gate-check.outcome }}';
# let comment = '## Content Service PR Check Results\n\n';
# // Test Results Section
# comment += '### Test Results\n';
# comment += `**Status**: ${testResult === 'success' ? '✅ Passed' : '❌ Failed'}\n\n`;
# // Code Quality Section
# comment += '### Code Quality Check\n';
# comment += `**Status**: ${sonarStatus === 'success' ? '✅ Passed' : '❌ Failed'}\n\n`;
# if (testResult !== 'success' || sonarStatus !== 'success') {
# comment += '### ⚠️ Action Required\n';
# comment += '- Please check the test failures and code quality issues\n';
# comment += '- Fix the identified issues and update the PR\n';
# comment += '- Detailed reports are available in the Actions tab\n';
# } else {
# comment += '### ✅ All Checks Passed!\n';
# comment += 'This PR meets all quality standards.\n';
# }
# github.rest.issues.createComment({
# issue_number: context.issue.number,
# owner: context.repo.owner,
# repo: context.repo.repo,
# body: comment
# });
- name: Check Test Results
if: steps.sonarqube-quality-gate-check.outcome != 'success' || job.status != 'success'
run: exit 1