Skip to content

Commit cd24cf2

Browse files
authored
.github: improve coverage run (#6238)
Add support to detect and kick UI builds and run quality build and report coverage for the PR. Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
1 parent 05c907b commit cd24cf2

2 files changed

Lines changed: 42 additions & 14 deletions

File tree

.github/workflows/coverage-check.yml

Lines changed: 41 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
name: PR Quality Check
1919

20-
on: [pull_request]
20+
on: [pull_request_target]
2121

2222
jobs:
2323
build:
@@ -26,27 +26,55 @@ jobs:
2626
steps:
2727
- uses: actions/checkout@v3
2828

29+
- name: Changed Java Files
30+
id: java-changes
31+
uses: tj-actions/changed-files@a59f800cbb60ed483623848e31be67659a2940f8
32+
with:
33+
files: |
34+
**/*.java
35+
36+
- name: Changed UI Files
37+
id: ui-changes
38+
uses: tj-actions/changed-files@a59f800cbb60ed483623848e31be67659a2940f8
39+
with:
40+
files: |
41+
ui/*
42+
43+
- name: Kick UI Build
44+
if: steps.ui-changes.outputs.any_changed == 'true'
45+
run: |
46+
curl -s -H "Authorization: token ${{ secrets.ACS_ROBOT_TOKEN }}" \
47+
-X POST -d '{"body": "UI changes found, kicking a new QA UI build\n@blueorangutan ui"}' \
48+
"https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments"
49+
2950
- name: Set up JDK11
3051
uses: actions/setup-java@v3
52+
if: steps.java-changes.outputs.any_changed == 'true'
3153
with:
3254
distribution: 'temurin'
3355
java-version: '11'
3456
cache: 'maven'
3557

36-
- name: Install nonoss jar dependencies
58+
- name: Run Build and Tests with Coverage
59+
id: coverage
60+
if: steps.java-changes.outputs.any_changed == 'true'
3761
run: |
3862
git clone https://github.com/shapeblue/cloudstack-nonoss.git nonoss
3963
cd nonoss && bash -x install-non-oss.sh && cd ..
64+
mvn -P quality -Dsimulator -Dnoredist clean install
4065
41-
- name: Run Build and Tests with Coverage
42-
run: mvn -P quality -Dsimulator -Dnoredist clean install
66+
echo "COVERAGE<<EOF" >> $GITHUB_ENV
67+
for file in ${{ steps.java-changes.outputs.all_changed_files }}; do
68+
name=$(basename $file | sed 's/.java//g')
69+
coverage=$(grep ,$name, client/target/site/jacoco-aggregate/jacoco.csv | cut -f3-9 -d"," | sed 's/,/|/g')
70+
echo $coverage
71+
echo "|$coverage|" >> $GITHUB_ENV
72+
done
73+
echo "EOF" >> $GITHUB_ENV
4374
44-
- name: Generate JaCoCo Report
45-
uses: Madrapps/jacoco-report@fd4800e8a81e21bdf373438e5918b975df041d15
46-
with:
47-
paths: ${{ github.workspace }}/client/target/site/jacoco-aggregate/jacoco.xml
48-
token: ${{ secrets.GITHUB_TOKEN }}
49-
min-coverage-overall: 10
50-
min-coverage-changed-files: 80
51-
title: PR Code Coverage
52-
debug-mode: false
75+
- name: Comment PR Coverage Report
76+
if: steps.java-changes.outputs.any_changed == 'true'
77+
run: |
78+
curl -s -H "Authorization: token ${{ secrets.ACS_ROBOT_TOKEN }}" \
79+
-X POST -d '{"body": "PR Coverage Report\n|**CLASS**|**INSTRUCTION MISSED**|**INSTRUCTION COVERED**|**BRANCH MISSED**|**BRANCH COVERED**|**LINE MISSED**|**LINE COVERED**|\n|-----|-----|-----|-----|-----|-----|-----|\n${{ env.COVERAGE }}"}' \
80+
"https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments"

.github/workflows/merge-conflict-checker.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
- name: Conflict Check
2929
uses: eps1lon/actions-label-merge-conflict@v2.0.0
3030
with:
31-
repoToken: "${{ secrets.GITHUB_TOKEN }}"
31+
repoToken: "${{ secrets.GITHUB_TOKEN }}"
3232
dirtyLabel: "status:has-conflicts"
3333
removeOnDirtyLabel: "status:ready-for-review"
3434
continueOnMissingPermissions: true

0 commit comments

Comments
 (0)