/
.gitlab-ci.yml
154 lines (137 loc) · 4.06 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
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
# You can override the included template(s) by including variable overrides
# SAST customization: https://docs.gitlab.com/ee/user/application_security/sast/#customizing-the-sast-settings
# Secret Detection customization: https://docs.gitlab.com/ee/user/application_security/secret_detection/#customizing-settings
# Dependency Scanning customization: https://docs.gitlab.com/ee/user/application_security/dependency_scanning/#customizing-the-dependency-scanning-settings
# Container Scanning customization: https://docs.gitlab.com/ee/user/application_security/container_scanning/#customizing-the-container-scanning-settings
# Note that environment variables can be set in several places
# See https://docs.gitlab.com/ee/ci/variables/#cicd-variable-precedence
stages:
- test
- publish
sast:
stage: test
include:
- template: Security/SAST.gitlab-ci.yml
.publish:
image: archlinux:base
script:
- pacman -Syu --noconfirm git jre-openjdk-headless
- export JAVA_HOME=$(dirname $(dirname $(readlink -f $(command -v java))))
- ./gradlew $module:publishKotlinMultiplatformPublicationToGitLabRepository $module:publishJvmPublicationToGitLabRepository $module:publishJsPublicationToGitLabRepository
only:
- tags
logger:publish:
extends: [ .publish ]
variables:
module: logger
backbone:publish:
extends: [ .publish ]
variables:
module: backbone
.test-jvm:
image: openjdk:latest
script:
- ./gradlew $module:koverReport $module:koverVerify # implies running the JVM tests
after_script:
- mkdir -p test-report-$module
- mv $module/build/reports/tests/jvmTest test-report-$module/test
- mv $module/build/reports/kover/html test-report-$module/coverage
- mv $module/build/reports/kover/xml/report.xml test-report-$module/coverage.xml
- values=$(cat test-report-$module/coverage.xml | tail -7 | head -5 | grep 'INSTRUCTION' | cut -d ' ' -f 3,4 | sed 's/missed="//;s/" covered="/ /;s/"\/>//')
- missed=$(<<<$values cut -d ' ' -f 1)
- covered=$(<<<$values cut -d ' ' -f 2)
- echo "Coverage $(($covered * 100 / ($covered + $missed)))%"
coverage: '/Coverage \d+%/'
artifacts:
paths:
- test-report-$module
expose_as: 'Test and coverage report'
reports:
junit: $module/build/test-results/jvmTest/**.xml
when: always
only:
- merge_requests
- main
- tags
.test-jvm-convert-coverage:
image: registry.gitlab.com/haynes/jacoco2cobertura:1.0.8
script:
- python /opt/cover2cover.py test-report-$module/coverage.xml $CI_PROJECT_DIR/$module/src/main/kotlin/ > cobertura.xml
artifacts:
reports:
coverage_report:
coverage_format: cobertura
path: cobertura.xml
only:
- merge_requests
- main
- tags
logger:test:jvm:
extends: [ .test-jvm ]
variables:
module: logger
logger:convert-coverage:
extends: [ .test-jvm-convert-coverage ]
needs:
- job: logger:test:jvm
artifacts: true
variables:
module: logger
backbone:test:jvm:
extends: [ .test-jvm ]
variables:
module: backbone
backbone:convert-coverage:
extends: [ .test-jvm-convert-coverage ]
needs:
- job: backbone:test:jvm
artifacts: true
variables:
module: backbone
spine:test:jvm:
extends: [ .test-jvm ]
variables:
module: spine
spine:convert-coverage:
extends: [ .test-jvm-convert-coverage ]
needs:
- job: spine:test:jvm
artifacts: true
variables:
module: spine
auth:test:jvm:
extends: [ .test-jvm ]
variables:
module: auth
auth:convert-coverage:
extends: [ .test-jvm-convert-coverage ]
needs:
- job: auth:test:jvm
artifacts: true
variables:
module: auth
dokka:
image: openjdk:latest
needs: [ ]
script:
- ./gradlew dokkaHtmlMultiModule
- mv build/dokka/htmlMultiModule documentation
artifacts:
paths:
- documentation
expose_as: "Documentation"
pages:
image: alpine:latest
stage: publish
needs:
- job: dokka
artifacts: true
script:
- mkdir -p public
- mv documentation public
artifacts:
paths:
- public
rules:
- if: '$CI_COMMIT_BRANCH == "main"'
- when: never