-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy path.gitlab-ci.yml
201 lines (187 loc) · 7.2 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
variables:
COMMON_BIND_HOST: "0.0.0.0"
DEPLOY_DOCKER_HELM: "true"
DEPLOY_TIMESTAMP: "$DEPLOY_TIMESTAMP"
DOCKER_DRIVER: "$DIND_DRIVER"
DOCKER_HOST: "$DIND_HOST"
DOCKER_TLS_CERTDIR: "$DIND_TLS_CERTDIR"
MAVEN_CLI: "-Ddocker.registry=$DOCKER_REGISTRY -Dhelm.deploy.url=$HELM_REGISTRY -Dhelm.deploy.type=$HELM_TYPE -Dmaven.deploy.releases=$MAVEN_DEPLOY_RELEASES -Dmaven.deploy.snapshots=$MAVEN_DEPLOY_SNAPSHOTS --batch-mode --errors --fail-fast --show-version"
MAVEN_OPTS: "-Dmaven.repo.local=.m2/repository"
GIT_SUBMODULE_STRATEGY: recursive
default:
#image: maven:3.8.4-eclipse-temurin-17
image: maven:3.9.2-amazoncorretto-17-debian-bullseye
services:
- name: "$DIND_IMAGE"
alias: docker
entrypoint: [ "env", "-u", "DOCKER_HOST" ]
command: [ "dockerd-entrypoint.sh" ]
stages:
- test
- deploy
deploy:
stage: deploy
cache:
- key: $CI_BUILD_REF_NAME
paths:
- .m2/repository
- key:
files:
- Frontend/package-lock.json
prefix: node-modules-$NODE_VERSION
paths:
- Frontend/node_modules
rules:
- if: $CI_COMMIT_BRANCH =~ /^maven\/release\/.*/ && $CI_PIPELINE_SOURCE == "pipeline"
- if: $CI_COMMIT_TAG && $CI_PIPELINE_SOURCE == "pipeline"
- if: $CI_COMMIT_BRANCH =~ /^maven\// && $CI_COMMIT_BRANCH !~ /^maven\/release\/.*/ && $CI_COMMIT_TAG == null
before_script:
- apt-get update -y
- apt-get install -y git
script:
- mvn $MAVEN_CLI -s .mvn/settings.xml deploy
.frontend_job: &frontend_job
variables:
NODE_VERSION: 16
stage: test
image: node:$NODE_VERSION-alpine3.16
rules:
- if: $CI_COMMIT_BRANCH =~ /^maven\/release\/.*/ && $CI_PIPELINE_SOURCE == "pipeline"
- if: $CI_COMMIT_TAG && $CI_PIPELINE_SOURCE == "pipeline"
- if: $CI_COMMIT_BRANCH !~ /^maven\/release\/.*/ && $CI_COMMIT_TAG == null
cache:
key:
files:
- Frontend/package-lock.json
prefix: node-modules-$NODE_VERSION
paths:
- Frontend/node_modules
before_script:
- cd Frontend
- node -v
- npm -v
# Install dependencies on cache miss, e.g., when first running on a ci runner.
- ([[ -d node_modules ]] || npm ci)
check formatting:
<<: *frontend_job
allow_failure: true
script:
- npm run check:format
check linting:
<<: *frontend_job
allow_failure: true
script:
- npm run check:lint
unittest frontend:
<<: *frontend_job
variables:
NODE_VERSION: 16
CHROME_BIN: /usr/bin/chromium-browser
before_script:
- apk add chromium
- mkdir -p Frontend/projects/edu-sharing-api/build/
- cp Backend/services/rest/api/src/main/resources/openapi.json Frontend/projects/edu-sharing-api/build/openapi.json
- cd Frontend/projects/edu-sharing-api
- node -v
- npm -v
- npm ci
- npm run generate-api
- cd ../..
# Install dependencies on cache miss, e.g., when first running on a ci runner.
- ([[ -d node_modules ]] || npm ci)
script:
- npm run prebuild
- npm run test-ci
test docker:
stage: test
cache:
- key: $CI_BUILD_REF_NAME
paths:
- .m2/repository
- key:
files:
- Frontend/package-lock.json
prefix: node-modules-$NODE_VERSION
paths:
- Frontend/node_modules
artifacts:
paths:
- deploy/docker/compose/target/compose/openapi.json
- deploy/docker/build/service/target/build/rest-api/openapi.json
when: always
expire_in: 3 day
before_script:
- apt-get update -y
- apt-get install -y ca-certificates curl gnupg jq lsb-release wait-for-it
- mkdir -p /etc/apt/keyrings
- curl -fsSL https://download.docker.com/linux/debian/gpg | gpg --dearmor -o /etc/apt/keyrings/docker.gpg
- echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/debian $(lsb_release -cs) stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null
- apt-get update -y
- apt-get install -y docker-ce docker-ce-cli containerd.io docker-compose-plugin docker-compose
- apt-get install -y php php-curl php-dom php-gd php-mbstring php-xml php-zip
- docker info
- docker version
- docker login $DOCKER_REGISTRY -u $DOCKER_USERNAME -p $DOCKER_PASSWORD
script:
- mkdir -p "$MAVEN_HOME"
- mvn $MAVEN_CLI -s .mvn/settings.xml install
- pushd deploy/docker/compose/target/compose
- docker compose -f 1_repository-common.yml up -d
- "until wait-for-it docker:8100 -t 3; do sleep 1; done"
- "until [[ $(curl -sSf -w '%{http_code}\n' -o /dev/null -H 'Accept: application/json' http://docker:8100/edu-sharing/rest/_about/status/SERVICE?timeoutSeconds=3) -eq 200 ]]; do sleep 1; done"
- "curl -m 300 -H 'Accept: application/json' --user 'admin:admin' http://docker:8100/edu-sharing/rest/openapi.json | jq -S . > openapi.json"
- docker compose -f 1_repository-common.yml down -v
- cmp -s openapi.json ../../../build/service/target/build/rest-api/openapi.json || exit 1
- popd
rules:
- if: $CI_COMMIT_BRANCH =~ /^maven\/release\/.*/ && $CI_PIPELINE_SOURCE == "pipeline"
- if: $CI_COMMIT_TAG && $CI_PIPELINE_SOURCE == "pipeline"
- if: $CI_COMMIT_BRANCH !~ /^maven\/release\/.*/ && $CI_COMMIT_TAG == null && $CI_PIPELINE_SOURCE == "pipeline"
e2e:
stage: test
cache:
- key: $CI_BUILD_REF_NAME
paths:
- .m2/repository
- key:
files:
- Frontend/package-lock.json
prefix: node-modules-$NODE_VERSION
paths:
- Frontend/node_modules
artifacts:
paths:
- repository/Frontend/src/generated/ng/playwright-report/
when: always
before_script:
- apt-get update -y
- apt-get install -y ca-certificates curl gnupg jq lsb-release wait-for-it
- mkdir -p /etc/apt/keyrings
- curl -fsSL https://download.docker.com/linux/debian/gpg | gpg --dearmor -o /etc/apt/keyrings/docker.gpg
- echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/debian $(lsb_release -cs) stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null
- apt-get update -y
- apt-get install -y docker-ce docker-ce-cli containerd.io docker-compose-plugin docker-compose
- apt-get install -y php php-curl php-dom php-gd php-mbstring php-xml php-zip
- curl -fsSL https://deb.nodesource.com/setup_16.x | bash - && apt-get install -y nodejs
- docker login $DOCKER_REGISTRY -u $DOCKER_USERNAME -p $DOCKER_PASSWORD
variables:
E2E_TEST_BASE_URL: http://docker:8100/edu-sharing/
REPOSITORY_SERVICE_HOST: docker
REPOSITORY_SERVICE_PORT: 8100
script:
- mkdir -p "$MAVEN_HOME"
- mvn $MAVEN_CLI -s .mvn/settings.xml install
- pushd deploy/docker/compose/target/compose
- docker compose -f 1_repository-common.yml up -d
- pushd ../../../../../repository/Frontend
- npx playwright install --with-deps
- "until wait-for-it docker:8100 -t 3; do sleep 1; done"
- "until [[ $(curl -sSf -w '%{http_code}\n' -o /dev/null -H 'Accept: application/json' http://docker:8100/edu-sharing/rest/_about/status/SERVICE?timeoutSeconds=3) -eq 200 ]]; do sleep 1; done"
- npm run e2e-prepare-edu-sharing
- npm run e2e
- popd
- docker compose -f 1_repository-common.yml down -v
- popd
only:
variables:
- $E2E_TEST == "true"