-
Notifications
You must be signed in to change notification settings - Fork 1
/
.gitlab-ci.yml
210 lines (194 loc) · 7.31 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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
# (c) https://github.com/MontiCore/monticore
# Build JAVA applications using Apache Maven (http://maven.apache.org)
# Cache downloaded dependencies and plugins between builds.
# To keep cache across branches add 'key: "$CI_JOB_NAME"'
cache:
paths:
- .m2/repository/
key: "$CI_COMMIT_SHA" # Cache across branch and stage
image: registry.git.rwth-aachen.de/monticore/container-registry/gradle:7.6.4-jdk11
stages:
- build
- test
- post-test
- trigger_languages
- mirror
Validate Gradle:
stage: build
script:
- gradle assemble --refresh-dependencies --warning-mode all
artifacts:
paths:
- ./target/
expire_in: 1 week
# Checks if the links in this repository's Markdown files are valid.
#
# For more information, visit: https://git.rwth-aachen.de/se/infrastructure/mdlinkchecker (Available internally only)
check-links:
# We need a JDK 17+ image for this job since the link checker requires Java 17.
image: eclipse-temurin:17-jdk-alpine
# The check runs parallel to the build since project documentation is not generated.
stage: build
# Allow failure regardless of whether the tool exists with a non-zero error code. We don't currently want to fail the
# pipeline if a link is invalid.
allow_failure: true
before_script:
- 'apk --no-cache add curl'
script:
- 'curl --location --header "PRIVATE-TOKEN: $secibuildinfstrtoken" "https://git.rwth-aachen.de/api/v4/projects/se%2Finfrastructure%2Fmdlinkchecker/jobs/artifacts/master/raw/target/libs/MDLinkCheckerCLI.jar?job=build" --output MDLinkChecker.jar'
- 'java -jar MDLinkChecker.jar -t "$secibuildtoken" -r . -p'
Unit Test Gradle:
stage: test
needs: ["Validate Gradle"]
dependencies:
- Validate Gradle #download artifacts from build
script:
- gradle build test --refresh-dependencies
check_format:
stage: test
allow_failure: true
script:
- echo "You can format the java files using <gradle fmt>"
- gradle checkfmt $GRADLE_OPT $ARGS2
## Run Unit Tests after build
#.unit_test_template: &unit_test_definition
# stage: test
# coverage: '/\d+.\d+ \% covered/'
# script:
# - mvn $MAVEN_CLI_OPTS test
# - awk -F"," '{ instructions += $4 + $5; covered += $5 } END { print covered, "/", instructions, "instructions covered"; print 100*covered/instructions, "% covered" }' ./target/site/jacoco/jacoco.csv
# dependencies:
# - Validate Maven #download artifacts from build
# needs: ["Validate Maven"]
# artifacts:
# reports:
# junit:
# - ./target/surefire-reports/TEST-*.xml
#
#Unit Test JDK 8:
# image: registry.git.rwth-aachen.de/monticore/container-registry/maven:3-jdk-8
# <<: *unit_test_definition
#
#Unit Test JDK 11:
# image: registry.git.rwth-aachen.de/monticore/container-registry/maven:3-jdk-11
# # We do not require JDK 11 support yet. We appreciate it though.
# allow_failure: true
# <<: *unit_test_definition
#
#Unit Test JDK 14:
# image: registry.git.rwth-aachen.de/monticore/container-registry/maven:3-jdk-14
# # We do not require JDK 14 support yet. We appreciate it though.
# allow_failure: true
# <<: *unit_test_definition
#
#Unit Test Amazon Corretto JDK 8:
# image: registry.git.rwth-aachen.de/monticore/container-registry/maven:3-amazoncorretto-8
# # We do not require Amazon Corretto JDK support. We appreciate it though.
# allow_failure: true
# <<: *unit_test_definition
Code Quality:
stage: post-test
variables:
DOCKER_DRIVER: overlay2
allow_failure: true
cache: {}
needs: [] # can run immediately
retry: 2
tags:
- shell
- docker
script:
- export SP_VERSION=$(echo "$CI_SERVER_VERSION" | sed 's/^\([0-9]*\)\.\([0-9]*\).*/\1-\2-stable/')
# Update Codeclimate and SonarJava Plugin
- docker run --rm
--env CODECLIMATE_CODE="$PWD"
--env CONTAINER_TIMEOUT_SECONDS=150000
--volume "$PWD":/code
--volume /var/run/docker.sock:/var/run/docker.sock
--volume /tmp/cc:/tmp/cc
codeclimate/codeclimate engines:install
# Check Code Quality
- docker run --rm
--env CODECLIMATE_CODE="$PWD"
--env CONTAINER_TIMEOUT_SECONDS=150000
--volume "$PWD":/code
--volume /var/run/docker.sock:/var/run/docker.sock
--volume /tmp/cc:/tmp/cc
codeclimate/codeclimate analyze -f json > codeclimate.json
#"registry.gitlab.com/gitlab-org/security-products/codequality:$SP_VERSION" /code
artifacts:
reports:
codequality: codeclimate.json
Deploy Nexus:
image: registry.git.rwth-aachen.de/monticore/container-registry/gradle:7.6.3-jdk11
stage: post-test
only:
- develop
script:
- gradle publish -PmavenPassword=$pass -PmavenUser=$user
Deploy Docker:
stage: post-test
variables:
DOCKER_DRIVER: overlay2
cache: {}
only:
- master
- develop
tags:
- shell
- docker
- node2
script:
- docker login -u sebot -p $sebot $CI_REGISTRY
- docker build -t $CI_REGISTRY_IMAGE/ocl:latest .
- docker image push $CI_REGISTRY_IMAGE/ocl:latest
trigger-montifun-main:
rules:
- if: '$CI_COMMIT_REF_NAME == "master" && $CI_PIPELINE_SOURCE != "pipeline"'
stage: trigger_languages
trigger:
project: monticore/languages/montifun
branch: main
trigger-montifun-dev:
rules:
- if: '$CI_COMMIT_REF_NAME == "develop" && $CI_PIPELINE_SOURCE != "pipeline"'
stage: trigger_languages
trigger:
project: monticore/languages/montifun
branch: dev
# Mirrors this repository's `develop` and `master` branch to GitHub.
#
# The mirror will always be at either HEAD or HEAD+1 (depending on whether cleanup is necessary).
# For more information, visit: https://git.rwth-aachen.de/se/infrastructure/github-mirror-tools (Available internally only)
githubmirror:
# We need a JDK 17+ image for this job since the link checker requires Java 17.
image: eclipse-temurin:17-jdk-alpine
stage: mirror
variables:
# The repository is edited during this job. To make sure that no changes persist, we instruct GitLab to always
# create a fresh clone of the repository instead of caching it and attempting to remove any changes.
#
# See https://docs.gitlab.com/ee/ci/runners/configure_runners.html#git-strategy
GIT_STRATEGY: clone
before_script:
- 'apk --no-cache add curl git openssh-client'
- eval $(ssh-agent -s)
- ssh-add <(echo "$SE_CIBUILD_SSH_PRIV_KEY")
- echo "$SE_CIBUILD_SSH_PRIV_KEY" | tr -d '\r' | ssh-add -
- git config --global user.email "[email protected]"
- git config --global user.name "MontiCore Mirroring Bot"
- git checkout "$CI_COMMIT_REF_NAME" # GitLab checks out a commit in detached HEAD mode by default, but we want to commit to the branch and push.
- mkdir -p ~/.ssh
- echo -e "Host github.com\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config
script:
- "curl --location --header \"PRIVATE-TOKEN: $secibuildinfstrtoken\" \"https://git.rwth-aachen.de/api/v4/projects/se%2Finfrastructure%2Fgithub-mirror-tools/repository/files/mirror.sh/raw\" --output mirror.sh"
- sh mirror.sh
- rm mirror.sh
- git add --all
# We'll simply ignore failures during commit because there is a chance that no files were changed. In this case the
# remote will be on the same commit as the upstream repository.
- (git commit -m "[Mirror] Replace all internal links and references") || true
- git remote add github [email protected]:MontiCore/ocl.git
- git push github $CI_COMMIT_BRANCH --force
rules:
- when: never