-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
124 lines (106 loc) · 2.95 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
image: maven:3-eclipse-temurin-17
stages:
- build
- test
- lint
- deploy
.my-rules: &my-rules
rules:
- if: $CI_COMMIT_TAG
- if: $CI_MERGE_REQUEST_ID # Execute jobs in merge request context
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
- if: $CI_PIPELINE_SOURCE == "web" # manual run via GitLab UI
workflow:
<<: *my-rules
variables:
GIT_SUBMODULE_STRATEGY: recursive
MAVEN_ARGS: "--no-transfer-progress -Dmaven.repo.local=$CI_PROJECT_DIR/.m2/repository"
cache:
paths:
- .m2/repository/
- target/
################################################################################
# build
build:
stage: build
script:
- mvn compile
################################################################################
# test
test:
stage: test
coverage: '/Instruction Coverage: \d+.\d+ %/'
script:
- mvn clean test
- mvn jacoco:report
- sh ./scripts/coverage.sh $JACOCO_CSV_LOCATION
- sh ./scripts/coverage_metrics.sh $JACOCO_CSV_LOCATION >> metrics.txt
variables:
JACOCO_CSV_LOCATION: "$CI_PROJECT_DIR/target/site/jacoco/jacoco.csv"
artifacts:
paths:
- target/site/jacoco/
reports:
metrics: metrics.txt
junit:
- target/surefire-reports/TEST-*.xml
show-coverage:
stage: test
needs:
- test
image: registry.gitlab.com/haynes/jacoco2cobertura:1.0.9
script:
- python /opt/cover2cover.py target/site/jacoco/jacoco.xml $CI_PROJECT_DIR/src/main/java/ > coverage.xml
artifacts:
reports:
coverage_report:
coverage_format: cobertura
path: coverage.xml
################################################################################
# lint
.lint: &lint-template
stage: lint
needs:
- build
rules:
- if: '$CI_MERGE_REQUEST_TITLE =~ /^Draft:/'
allow_failure: true
- when: on_success
allow_failure: false
check-licence-headers:
<<: *lint-template
script:
- mvn license:check
check-formatting:
<<: *lint-template
script:
- mvn spotless:check
checkstyle:
<<: *lint-template
script:
- mvn checkstyle:checkstyle
- cat target/checkstyle-result.xml | ./scripts/checkstyle_report.sh > checkstyle-report.json
artifacts:
when: always
reports:
codequality:
- checkstyle-report.json
################################################################################
# deploy
deploy-gitlab:
stage: deploy
script:
- 'mvn deploy -s ci_settings.xml'
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
nix-build:
stage: deploy
image: docker.io/nixos/nix
script:
- nix --experimental-features 'nix-command flakes' build --print-build-logs
rules:
- changes:
- default.nix
- flake.lock
- flake.nix
- pom.xml