-
Notifications
You must be signed in to change notification settings - Fork 12
132 lines (123 loc) · 4.76 KB
/
Copy pathci.yml
File metadata and controls
132 lines (123 loc) · 4.76 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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
name: Integration Tests
on:
pull_request:
branches:
- main
push:
branches:
- other/smallImprovements-AST-128958
jobs:
ui-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3.5.2
with:
lfs: true
- name: Checkout LFS objects
run: git lfs checkout
- uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 17
- uses: actions/cache@v3
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-maven-
- name: Run UI Tests
env:
CX_BASE_URI: ${{ secrets.CX_BASE_URI }}
CX_TENANT: ${{ secrets.CX_TENANT }}
CX_APIKEY: ${{ secrets.CX_APIKEY }}
CX_TEST_SCAN: ${{ secrets.CX_TEST_SCAN }}
DISPLAY: :99.0
run: |
Xvfb -ac :99 -screen 0 1920x1080x16 &
mvn verify -Dtest.includes="**/ui/*.java"
- name: Upload Coverage Report
uses: actions/upload-artifact@v4
with:
name: jacoco-coverage-report-ui
path: checkmarx-ast-eclipse-plugin-tests/target/site/jacoco-aggregate
integration-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3.5.2
with:
lfs: true
- name: Checkout LFS objects
run: git lfs checkout
- uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 17
- uses: actions/cache@v3
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-maven-
- name: Run Integration Tests
env:
CX_BASE_URI: ${{ secrets.CX_BASE_URI }}
CX_TENANT: ${{ secrets.CX_TENANT }}
CX_APIKEY: ${{ secrets.CX_APIKEY }}
CX_TEST_SCAN: ${{ secrets.CX_TEST_SCAN }}
DISPLAY: :99.0
run: |
Xvfb -ac :99 -screen 0 1920x1080x16 &
mvn verify -Dtest.includes="**/integration/*Test.java"
- name: Upload Coverage Report
uses: actions/upload-artifact@v4
with:
name: jacoco-coverage-report-integration
path: checkmarx-ast-eclipse-plugin-tests/target/site/jacoco-aggregate
unit-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3.5.2
with:
lfs: true
- name: Checkout LFS objects
run: git lfs checkout
- uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 17
- uses: actions/cache@v3
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-maven-
- name: Run Unit Tests with Coverage
env:
CX_BASE_URI: ${{ secrets.CX_BASE_URI }}
CX_TENANT: ${{ secrets.CX_TENANT }}
CX_APIKEY: ${{ secrets.CX_APIKEY }}
CX_TEST_SCAN: ${{ secrets.CX_TEST_SCAN }}
DISPLAY: :99.0
run: |
Xvfb -ac :99 -screen 0 1920x1080x16 &
mvn clean verify -Dtest.includes="**/unit/**/*Test.java"
- name: Upload Coverage Report
uses: actions/upload-artifact@v4
with:
name: jacoco-coverage-report-unit
path: checkmarx-ast-eclipse-plugin-tests/target/site/jacoco-aggregate
- name: Generate JaCoCo Coverage Summary
run: |
REPORT="checkmarx-ast-eclipse-plugin-tests/target/site/jacoco-aggregate/jacoco.xml"
LINE_COVERED=$(grep 'type="LINE"' $REPORT | sed -E 's/.*covered="([0-9]+)".*/\1/')
LINE_MISSED=$(grep 'type="LINE"' $REPORT | sed -E 's/.*missed="([0-9]+)".*/\1/')
BRANCH_COVERED=$(grep 'type="BRANCH"' $REPORT | sed -E 's/.*covered="([0-9]+)".*/\1/')
BRANCH_MISSED=$(grep 'type="BRANCH"' $REPORT | sed -E 's/.*missed="([0-9]+)".*/\1/')
LINE_TOTAL=$((LINE_COVERED + LINE_MISSED))
BRANCH_TOTAL=$((BRANCH_COVERED + BRANCH_MISSED))
LINE_PERCENT=$(awk "BEGIN {printf \"%.2f\", ($LINE_COVERED/$LINE_TOTAL)*100}")
BRANCH_PERCENT=$(awk "BEGIN {printf \"%.2f\", ($BRANCH_COVERED/$BRANCH_TOTAL)*100}")
echo "## 🧪 Test Coverage Summary" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "| Metric | Coverage |" >> $GITHUB_STEP_SUMMARY
echo "|------|------|" >> $GITHUB_STEP_SUMMARY
echo "| **Line Coverage** | ${LINE_PERCENT}% |" >> $GITHUB_STEP_SUMMARY
echo "| **Branch Coverage** | ${BRANCH_PERCENT}% |" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY