-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy path.gitlab-ci.yml
125 lines (121 loc) · 4.94 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
include:
- project: "waldur/waldur-pipelines"
file: "/templates/stages.yml"
- project: "waldur/waldur-pipelines"
file: "/templates/test/check-merge-compatibility.yml"
- project: "waldur/waldur-pipelines"
file: "/templates/test/lint-md-files.yml"
- project: "waldur/waldur-pipelines"
file: "/templates/deploy/dev-env-update.yml"
variables:
DOCKER_REGISTRY_PREFIX: "registry.hpc.ut.ee/mirror/"
Test compose configuration:
services:
- name: "docker:20.10.16-dind"
command: ["--mtu=1400"]
interruptible: true
rules:
# If triggered from another pipeline
- if: $TRIGGER_PROJECT_NAME
# If changes are pushed to `develop` or `master` branch
- if: '$CI_COMMIT_BRANCH == "develop"'
- if: '$CI_COMMIT_BRANCH == "master"'
# If associated merge request exists
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
# If triggered by a schedule
- if: '$CI_PIPELINE_SOURCE == "schedule"'
variables:
DOCKER_DRIVER: overlay2
COMPOSE_INTERACTIVE_NO_CLI: 1
WALDUR_DOMAIN: docker
TLS: internal
DOCKER_REGISTRY_PREFIX: "registry.hpc.ut.ee/mirror/"
script:
- cp -vf .env.example .env
- echo "DOCKER_REGISTRY_PREFIX=registry.hpc.ut.ee/mirror/" >> .env
- |
if [ "$CI_PIPELINE_SOURCE" == "merge_request_event" ]; then
echo "Testing using latest images"
sed -i 's/WALDUR_MASTERMIND_IMAGE_TAG=.*/WALDUR_MASTERMIND_IMAGE_TAG=latest/' .env
sed -i 's/WALDUR_HOMEPORT_IMAGE_TAG=.*/WALDUR_HOMEPORT_IMAGE_TAG=latest/' .env
fi
- docker compose version
- docker context list
- docker info
- docker compose config
- echo "Pulling images:"
- docker compose pull
- echo "Images pulled:"
- docker images
- docker compose up waldur-mastermind-db-migration
- docker compose logs --tail=100 waldur-mastermind-db-migration
- docker compose up -d
- docker compose ps
- docker compose exec waldur-mastermind-worker status
- docker compose exec waldur-mastermind-worker waldur createstaffuser -u admin -p password -e [email protected]
# Using `docker` host due to docker networking model:
# Accessing directly to the `dind` service
- curl -k -i https://docker | grep 200
- curl -k -i https://docker/api/ | grep 401
- curl -X POST -d '{"username":"admin","password":"password" }' -H "Content-type:application/json" -k -i https://docker/api-auth/password/ | grep 200
- mkdir docs/
- API_GROUPS_STRING=$(docker exec waldur-mastermind-api waldur shell -c "from waldur_core.core.api_groups_mapping import API_GROUPS; print(' '.join(API_GROUPS.keys()))")
- echo $API_GROUPS_STRING
- echo -e "# API index\n" > docs/index.md
- echo -e "Summary:\n" >> docs/index.md
- |
for item in $API_GROUPS_STRING
do
echo "$item"
curl -sLk "http://docker/docs/$item/?format=openapi" -o docs/$item-docs.json
item_cap=`echo ${item:0:1} | tr '[a-z]' '[A-Z]'`${item:1}
echo -e "# $item_cap\n\n"'!!'"swagger $item-docs.json"'!!' > docs/$item-api.md
echo "- [$item_cap]($item-api.md)" >> docs/index.md
done
before_script:
- apk add curl
- |
if [ "$TRIGGER_PROJECT_NAME" == "waldur-mastermind" ]; then
export WALDUR_MASTERMIND_IMAGE_TAG=${TRIGGER_IMAGE_TAG}
elif [ "$TRIGGER_PROJECT_NAME" == "waldur-homeport" ]; then
export WALDUR_HOMEPORT_IMAGE_TAG=${TRIGGER_IMAGE_TAG}
fi
artifacts:
# Saving generated doc files for further configuration uploading
paths:
- docs/
expire_in: 1 day
Upload configuration guide:
image: "registry.hpc.ut.ee/mirror/library/python:3.8-buster"
stage: deploy
interruptible: true
rules:
# If changes are pushed to `develop` branch
- if: '$CI_COMMIT_BRANCH == "develop"'
variables:
GUIDE_PATH: docs/admin-guide/deployment/docker-compose.md
API_DOCS_PATH: docs/API/
IMG_TARGET_PATH: docs/admin-guide/deployment/img
script:
- cd /tmp/
- git clone "https://gitlab-ci-token:$GITLAB_TOKEN@$CI_SERVER_HOST/waldur/waldur-docs.git"
- cd waldur-docs
- git config --global user.name "$GITLAB_USER_NAME"
- git config --global user.email "$GITLAB_USER_EMAIL"
- cp -vf ${CI_BUILDS_DIR}/${CI_PROJECT_PATH}/README.md $GUIDE_PATH
- mkdir -p $API_DOCS_PATH
- cp -vf ${CI_BUILDS_DIR}/${CI_PROJECT_PATH}/docs/* $API_DOCS_PATH
- git add $API_DOCS_PATH
- mkdir -p docs/admin-guide/deployment/img
- cp -vf ${CI_BUILDS_DIR}/${CI_PROJECT_PATH}/img/* $IMG_TARGET_PATH
- git add $IMG_TARGET_PATH
- git commit $GUIDE_PATH $API_DOCS_PATH $IMG_TARGET_PATH -m "Update configuration guide and API docs" || exit 0
- git branch new-configuration-guide
- git push --set-upstream origin new-configuration-guide:master
# Override default rules so the job runs for tags automatically
Trigger dev env update:
rules:
- if: '$SKIP_DEV_UPDATE == "true" || $SKIP_DEV_UPDATE == "yes"'
when: never
- if: $CI_COMMIT_TAG
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'