-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
85 lines (76 loc) · 3.39 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
include:
- template: Security/SAST.gitlab-ci.yml
image: rcktsci/java-tooling:11-code-coverage
stages:
- build
- test
- deploy
# Cache downloaded dependencies and plugins between builds.
cache:
paths:
- .m2/repository
variables:
# This will suppress any download for dependencies and plugins or upload messages which would clutter the console log.
# `showDateTime` will show the passed time in milliseconds. You need to specify `--batch-mode` to make this work.
MAVEN_OPTS: "-Dhttps.protocols=TLSv1.2 -Dmaven.repo.local=$CI_PROJECT_DIR/.m2/repository -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=WARN -Dorg.slf4j.simpleLogger.showDateTime=true -Djava.awt.headless=true"
# As of Maven 3.3.0 instead of this you may define these options in `.mvn/maven.config` so the same config is used
# when running from the command line.
# `installAtEnd` and `deployAtEnd` are only effective with recent version of the corresponding plugins.
MAVEN_CLI_OPTS: "--batch-mode --errors --fail-at-end --show-version -DinstallAtEnd=true -DdeployAtEnd=true -s ci_settings.xml"
# Instruct Testcontainers to use the daemon of DinD, use port 2735 for non-tls connections.
DOCKER_HOST: "tcp://docker:2375"
# Instruct Docker not to start over TLS.
DOCKER_TLS_CERTDIR: ""
# Improve performance with overlayfs.
DOCKER_DRIVER: overlay2
sast:
stage: test
.docker:
services:
- name: docker:23.0-dind
# explicitly disable tls to avoid docker startup interruption
command: [ "--tls=false" ]
before_script:
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
build:
stage: build
script:
- mvn $MAVEN_CLI_OPTS compile
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH || $CI_PIPELINE_SOURCE == 'merge_request_event'
test:
extends: .docker
stage: test
variables:
JACOCO_REPORT: $CI_PROJECT_DIR/coverage/target/site/jacoco-aggregate/jacoco.xml
COBERTURA_XML: $CI_PROJECT_DIR/coverage/target/site/jacoco-aggregate/cobertura.xml
script:
# Компиляция проекта, прогон тестов.
- mvn $MAVEN_CLI_OPTS verify sonar:sonar -Dsonar.qualitygate.wait=true
after_script:
# convert a report from jacoco to cobertura, using a relative project path
- 'python3 /opt/cover2cover.py ${JACOCO_REPORT}
$CI_PROJECT_DIR/r2dbc-scheduler/src/main/java/
$CI_PROJECT_DIR/r2dbc-scheduler-spring-boot-starter/src/main/java/
> ${COBERTURA_XML}'
- |
echo "Total coverage: " "$(grep -o 'Total[^%]*%' r2dbc-scheduler/target/site/jacoco/index.html | grep -o '[1-9]\{1,3\}.%')"
artifacts:
reports:
# Сохраняем отчёт JUnit по пройденным юнит-тестам.
junit:
- '**/target/surefire-reports/TEST-*.xml'
- '**/target/failsafe-reports/TEST-*.xml'
# Сохраняем отчёт JaCoCo о покрытии кода.
coverage_report:
coverage_format: cobertura
path: ${COBERTURA_XML}
coverage: '/Total coverage:\s+?(\d{1,3})/'
rules:
- if: $CI_PIPELINE_SOURCE == 'merge_request_event' || $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
deploy:
stage: deploy
script:
- 'mvn $MAVEN_CLI_OPTS deploy -pl r2dbc-scheduler,r2dbc-scheduler-spring-boot-starter -Dmaven.test.skip -P GitlabCI'
rules:
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH || $CI_COMMIT_TAG'