-
Notifications
You must be signed in to change notification settings - Fork 4
/
.gitlab-ci.yml
86 lines (83 loc) · 2.74 KB
/
.gitlab-ci.yml
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
stages:
- test
- coverage
- publish
test:
stage: test
image: maven:3.8.8-eclipse-temurin-17
script:
- mvn clean verify -s $MAVEN_SETTINGS -Dmaven.repo.local=$CI_PROJECT_DIR/.m2/repository
- shopt -s globstar
- awk -F"," '{ instructions += $4 + $5; covered += $5 } END { print covered, "/", instructions, " instructions covered"; print "Total", 100*covered/instructions, "% covered" }' /builds/**/target/site/jacoco/jacoco.csv
- cd test/bats
- source install_bats.sh
- source variables.sh
- $BATS_HOME/bats-core/bin/bats --gather-test-outputs-in target/reports -x --report-formatter junit --output target/ cdoc2_tests.bats
- 'for file in target/reports/*; do echo "## $file ##" >> target/bats-test.log; cat "$file" >> target/bats-test.log; done'
coverage: /Total \d+\.\d+ %/
artifacts:
when: always
reports:
junit:
- "**/target/surefire-reports/*.xml"
- "**/target/report.xml"
paths:
- "**/target/site/jacoco"
- "**/target/bats-test.log"
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
when: on_success
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
when: on_success
- when: never
cache:
key: "$CI_COMMIT_REF_NAME"
paths:
- .m2/repository
coverage:
stage: coverage
image: mcr.microsoft.com/dotnet/sdk:8.0
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
when: on_success
- when: never
script:
- export PATH="$PATH:/root/.dotnet/tools"
- dotnet tool restore
- dotnet tool install dotnet-reportgenerator-globaltool --global
- |
for src in $(find /builds -type f -name 'jacoco.xml' | sed -r 's|/target/site/jacoco/[^/]+$||' | sort -u )
do
sourcedirs="$src/src/main/"
for i in $(find $src -type f -name '*.java' | sed -r 's|/[^/]+$||' |sort -u)
do
sourcedirs="${sourcedirs};${i}"
done
reportgenerator \
-reports:$src/**/jacoco.xml \
-targetdir:$src/target/reports \
-reporttypes:Cobertura \
-sourcedirs:$sourcedirs
sed -i 's|filename=\"'"$src"'/src/main/java/|filename=\"|g' $src/target/reports/Cobertura.xml
done
artifacts:
paths:
- "$CI_PROJECT_DIR/**/Cobertura.xml"
reports:
coverage_report:
coverage_format: cobertura
path: "$CI_PROJECT_DIR/**/Cobertura.xml"
publish:
stage: publish
image: maven:3.8.8-eclipse-temurin-17
script: mvn deploy -s $MAVEN_SETTINGS
cache:
key: "$CI_COMMIT_REF_NAME"
paths:
- .m2/repository
rules:
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
when: on_success
- if: '$CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH && $CI_PIPELINE_SOURCE != "merge_request_event"'
when: manual
- when: never