forked from Sunbird-Knowlg/knowledge-platform
-
Notifications
You must be signed in to change notification settings - Fork 0
87 lines (77 loc) · 2.93 KB
/
content-service-pr-check.yml
File metadata and controls
87 lines (77 loc) · 2.93 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
name: Pull Request Checks
on:
push:
branches:
- '*'
jobs:
test-and-quality:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0 # Important for SonarQube to get full history
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'temurin'
cache: 'maven'
- name: Cache Maven packages
uses: actions/cache@v3
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Build and Run Tests
run: |
mvn clean install -DskipTests -DCLOUD_STORE_GROUP_ID=org.sunbird -DCLOUD_STORE_ARTIFACT_ID=cloud-store-sdk_2.12 -DCLOUD_STORE_VERSION=1.4.7.2
cd content-api/content-service/
mvn clean test org.jacoco:jacoco-maven-plugin:0.8.8:prepare-agent test org.jacoco:jacoco-maven-plugin:0.8.8:report -DCLOUD_STORE_GROUP_ID=org.sunbird -DCLOUD_STORE_ARTIFACT_ID=cloud-store-sdk_2.12 -DCLOUD_STORE_VERSION=1.4.7.2
- name: Upload Test Results
if: always()
uses: actions/upload-artifact@v4
with:
name: test-results
path: 'content-api/content-service/target/surefire-reports/*.xml'
- name: Publish Test Results
if: always()
uses: dorny/test-reporter@v1
with:
name: Test Results
path: content-api/content-service/target/surefire-reports/*.xml
reporter: java-junit
fail-on-error: true
- name: Set up JDK 17
uses: actions/setup-java@v2
with:
java-version: '17'
distribution: 'temurin'
- name: SonarCloud Analysis
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: |
mvn sonar:sonar \
-DCLOUD_STORE_GROUP_ID=org.sunbird \
-DCLOUD_STORE_ARTIFACT_ID=cloud-store-sdk_2.12 \
-DCLOUD_STORE_VERSION=1.4.7.2 \
-Dsonar.projectKey=vinodbhorge \
-Dsonar.organization=vinodbhorge \
-Dsonar.host.url=https://sonarcloud.io \
-Dsonar.coverage.jacoco.xmlReportPaths=content-api/content-service/target/site/jacoco/jacoco.xml \
-Dsonar.token=$SONAR_TOKEN
- name: Comment PR with SonarQube Results
uses: actions/github-script@v6
if: always()
with:
script: |
const sonarUrl = `https://sonarcloud.io/dashboard?id=${process.env.GITHUB_REPOSITORY.replace('/', '_')}`;
const message = `### Quality Gate Results
Check the detailed SonarQube analysis at: ${sonarUrl}`;
github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: message
});