-
-
Notifications
You must be signed in to change notification settings - Fork 18
/
.gitlab-ci.yml
106 lines (101 loc) · 3.22 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
variables:
BOT_VERSION: 2.15.1
MAVEN_OPTS: -Dmaven.repo.local=.m2/repository
dependencies:
image: maven:3.8.6-eclipse-temurin-17-alpine
only:
changes: &code-changes
- Dockerfile
- pom.xml
- src/main/**/*
- src/test/**/*
- sql/**/*
script:
- mvn --batch-mode de.qaware.maven:go-offline-maven-plugin:resolve-dependencies
stage: .pre
test:
image: maven:3.9.7-eclipse-temurin-21-alpine
only:
changes: *code-changes
services:
- name: docker:20.10.17-dind
command: [ "--tls=false" ]
script:
- mvn -Pcoverage --batch-mode org.jacoco:jacoco-maven-plugin:prepare-agent test org.jacoco:jacoco-maven-plugin:report
- awk -F"," '{ instructions += $4 + $5; covered += $5 } END { print "Total", 100*covered/instructions, "%" }' target/site/jacoco/jacoco.csv
coverage: '/Total (\d+.\d+) %/'
variables:
TESTCONTAINERS_HOST_OVERRIDE: "host.docker.internal"
# 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
artifacts:
paths:
- target/site/jacoco/jacoco.xml
stage: test
container:
image: docker:20.10.17
cache: {}
rules:
- if: $CI_COMMIT_REF_NAME == 'master'
changes: *code-changes
- if: $CI_COMMIT_TAG
changes: *code-changes
services:
- docker:20.10.17-dind
script:
- '[ -n "$CI_COMMIT_TAG" ] && VERSION=${CI_COMMIT_TAG#"v"} || VERSION=${BOT_VERSION}-${CI_COMMIT_SHORT_SHA}'
- BUILD_DATE=$(date -u +%FT%TZ)
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- |
docker build --quiet \
--cache-from $CI_REGISTRY/pawabot/pawa:latest \
-t $CI_REGISTRY/pawabot/pawa:${VERSION} \
--build-arg VCS_REF=${CI_COMMIT_SHORT_SHA} \
--build-arg BUILD_DATE=${BUILD_DATE} \
--build-arg VERSION=${VERSION} \
.
- '[ -n "$CI_COMMIT_TAG" ] && docker push $CI_REGISTRY/pawabot/pawa:latest || docker push $CI_REGISTRY/pawabot/pawa:${VERSION}'
- docker tag $CI_REGISTRY/pawabot/pawa:${VERSION} gdragon/throw-voice:${VERSION}
- docker login -u $DOCKER_LOGIN -p $DOCKER_PASSWORD
- docker push gdragon/throw-voice:${VERSION}
stage: deploy
variables:
DOCKER_DRIVER: overlay2
DOCKER_TLS_CERTDIR: /certs
coverage:
image: registry.gitlab.com/haynes/jacoco2cobertura:1.0.9
cache: {}
only:
changes: *code-changes
script:
# convert report from jacoco to cobertura, using relative project path
- python /opt/cover2cover.py target/site/jacoco/jacoco.xml $CI_PROJECT_DIR/src/main/kotlin/ > target/site/cobertura.xml
artifacts:
reports:
coverage_report:
coverage_format: cobertura
path: target/site/cobertura.xml
stage: deploy
pages:
artifacts:
expire_in: 30 days
paths:
- public
cache: {}
script:
- cp -r src/site/ public
stage: deploy
rules:
- if: $DEPLOY_SITE
- if: $CI_COMMIT_REF_NAME == 'master'
changes:
- CHANGELOG.md
- src/site/**/*
- if: $CI_COMMIT_TAG
changes:
- CHANGELOG.md
- src/site/**/*