-
Notifications
You must be signed in to change notification settings - Fork 1
/
.gitlab-ci.yml
117 lines (112 loc) · 5.16 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
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_HOME: "/builds/$CI_PROJECT_PATH/mnt/.m2"
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=/builds/$CI_PROJECT_PATH/mnt/.m2/repository"
REPOSITORY_ANTIVIRUS_ENABLED: "false"
REPOSITORY_CLUSTER_ENABLED: "false"
REPOSITORY_ELASTIC_ENABLED: "true"
REPOSITORY_MONGO_ENABLED: "true"
REPOSITORY_REMOTE_ENABLED: "false"
REPOSITORY_TRANSFORM_ENABLED: "false"
SERVICE_CONNECTOR_ENABLED: "false"
default:
image: maven:3.8.4-jdk-8
services:
- name: "$DIND_IMAGE"
alias: docker
entrypoint: [ "env", "-u", "DOCKER_HOST" ]
command: [ "dockerd-entrypoint.sh" ]
stages:
- test
- deploy
test docker:
stage: test
artifacts:
paths:
- deploy/docker/openapi.json
- deploy/docker/repository/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
- . deploy.sh ci
- "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"
- . deploy.sh stop
- cmp -s openapi.json repository/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_BRANCH !~ /^maven\/release\/.*/ && $CI_COMMIT_TAG == null && ($CI_PIPELINE_SOURCE == "pipeline" || $CI_PIPELINE_SOURCE == "trigger" || $CI_PIPELINE_SOURCE == "schedule")
- if: $CI_COMMIT_TAG
when: never
e2e:
stage: test
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
- . deploy.sh ci
- pushd ../../repository/Frontend/src/generated/ng
- 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
- . deploy.sh stop
- popd
only:
variables:
- $E2E_TEST == "true"
deploy:
stage: deploy
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
before_script:
- apt-get update -y
- apt-get install -y php php-curl php-dom php-gd php-mbstring php-xml php-zip
script:
- mvn $MAVEN_CLI -s .mvn/settings.xml deploy