Skip to content

Commit 3ec3007

Browse files
authored
Generate coverage for Simulator based integration tests & ui tests in github actions (#7784)
* Generate coverage for Simulator based integration tests * Add flag for unit tests * Add coverage for uitests
1 parent c4e53c0 commit 3ec3007

4 files changed

Lines changed: 36 additions & 2 deletions

File tree

.github/workflows/ci.yml

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,8 @@ jobs:
193193

194194
steps:
195195
- uses: actions/checkout@v3
196+
with:
197+
fetch-depth: 0
196198

197199
- name: Set up JDK
198200
uses: actions/setup-java@v3
@@ -217,6 +219,11 @@ jobs:
217219
run: |
218220
python3 -m pip install --user --upgrade urllib3 lxml paramiko nose texttable ipmisim pyopenssl pycrypto mock flask netaddr pylint pycodestyle six astroid
219221
222+
- name: Install jacoco dependencies
223+
run: |
224+
wget https://github.com/jacoco/jacoco/releases/download/v0.8.10/jacoco-0.8.10.zip
225+
unzip jacoco-0.8.10.zip -d jacoco
226+
220227
- name: Env details
221228
run: |
222229
uname -a
@@ -249,9 +256,16 @@ jobs:
249256
mvn -q -Pdeveloper -pl developer -Ddeploydb
250257
mvn -q -Pdeveloper -pl developer -Ddeploydb-simulator
251258
259+
- name: Generate jacoco-coverage.sh
260+
run: |
261+
echo "java -jar jacoco/lib/jacococli.jar report jacoco-it.exec \\" > jacoco-report.sh
262+
find . | grep "target/classes" | sed 's/\/classes\//\/classes /g' | awk '{print "--classfiles", $1, "\\"}' | sort |uniq >> jacoco-report.sh
263+
find . | grep "src/main/java" | sed 's/\/java\//\/java /g' | awk '{print "--sourcefiles", $1, "\\"}' | sort | uniq >> jacoco-report.sh
264+
echo "--xml jacoco-coverage.xml" >> jacoco-report.sh
265+
252266
- name: Start CloudStack Management Server with Simulator
253267
run: |
254-
export MAVEN_OPTS="-Xmx4096m -XX:MaxPermSize=800m -Djava.security.egd=file:/dev/urandom"
268+
export MAVEN_OPTS="-Xmx4096m -XX:MaxPermSize=800m -Djava.security.egd=file:/dev/urandom -javaagent:jacoco/lib/jacocoagent.jar=address=*,port=36320,output=tcpserver"
255269
echo -e "\nStarting simulator"
256270
set +e
257271
mvn -Dsimulator -Dorg.eclipse.jetty.annotations.maxWait=120 -pl :cloud-client-ui jetty:run 2>&1 > /tmp/jetty-log || true &
@@ -275,10 +289,20 @@ jobs:
275289
done
276290
277291
echo -e "Stopping Simulator, integration tests run completed\n"
292+
java -jar jacoco/lib/jacococli.jar dump --address localhost --port 36320 --destfile jacoco-it.exec
293+
bash jacoco-report.sh
278294
mvn -Dsimulator -pl client jetty:stop 2>&1
279295
find /tmp//MarvinLogs -type f -exec echo -e "Printing marvin logs {} :\n" \; -exec cat {} \;
280296
281297
- name: Integration Tests Result
282298
run: |
283299
echo -e "Simulator CI Test Results: (only failures listed)\n"
284300
python3 ./tools/marvin/xunit-reader.py integration-test-results/
301+
302+
- uses: codecov/codecov-action@v3
303+
with:
304+
files: jacoco-coverage.xml
305+
fail_ci_if_error: true
306+
flags: simulator-marvin-tests
307+
verbose: true
308+
name: codecov

.github/workflows/codecov.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,5 +53,6 @@ jobs:
5353
with:
5454
files: ./client/target/site/jacoco-aggregate/jacoco.xml
5555
fail_ci_if_error: true
56+
flags: unit-tests
5657
verbose: true
5758
name: codecov

.github/workflows/ui.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,12 @@ jobs:
5151
npm run build
5252
npm run lint
5353
npm run test:unit
54+
55+
- uses: codecov/codecov-action@v3
56+
with:
57+
working-directory: ui
58+
files: ./coverage/lcov.info
59+
fail_ci_if_error: true
60+
flags: uitests
61+
verbose: true
62+
name: codecov

ui/jest.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,5 +50,5 @@ module.exports = {
5050
'!**/node_modules/**',
5151
'!<rootDir>/src/locales/*.{js, json}'
5252
],
53-
coverageReporters: ['html', 'text-summary']
53+
coverageReporters: ['html', 'text-summary', 'lcov']
5454
}

0 commit comments

Comments
 (0)