-
Notifications
You must be signed in to change notification settings - Fork 9
/
.gitlab-ci.yml
150 lines (139 loc) · 3.81 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
stages:
- test
- build
- acceptance_tests
- publish
- sync
include:
- project: 'Northern.tech/Mender/mendertesting'
file: '.gitlab-ci-check-commits-signoffs.yml'
- project: 'Northern.tech/Mender/mendertesting'
file: '.gitlab-ci-check-docker-build.yml'
- project: 'Northern.tech/Mender/mendertesting'
file: '.gitlab-ci-check-docker-deploy.yml'
- project: 'Northern.tech/Mender/mendertesting'
file: '.gitlab-ci-github-status-updates.yml'
# Disable Mender specific job
publish:image:mender:
rules:
- when: never
test:check-python3-formatting:
tags:
- mender-qa-worker-generic-light
stage: test
needs: []
image: python:3
before_script:
- pip install tox
- cd backend
script:
- TOXENV=black tox
test:backend-unit:
tags:
- mender-qa-worker-generic-light
stage: test
needs: []
services:
- name: bitnami/postgresql:12.2.0
alias: db
variables:
POSTGRES_PASSWORD: password
POSTGRES_DB: mantra-db
image: python:3.12
before_script:
- cd backend
- pip install -r requirements.txt
- pip install tox
script:
- gunicorn -t 120 --daemon --bind 127.0.0.1:7374 --access-logfile - tetra.app:application
- TOXENV=functional tox
build:docker:
variables:
DOCKER_REPOSITORY: mendersoftware/mantra-api
DOCKER_DIR: backend
after_script:
- cp image.tar image-api.tar
artifacts:
expire_in: 2w
paths:
- image.tar
- image-api.tar
rules:
- if: $CI_COMMIT_REF_NAME == "master"
- changes:
- backend/**/*
publish:image:
variables:
DOCKER_REPOSITORY: mendersoftware/mantra-api
DOCKER_DIR: backend
sync:image:
variables:
DOCKER_REPOSITORY: mendersoftware/mantra-api
TARGET_MANIFEST_FILE: kubernetes/mender-qastatus/api-deployment.yaml
build:docker:ui:
extends: build:docker
variables:
DOCKER_REPOSITORY: mendersoftware/mantra-ui
DOCKER_DIR: ui
script:
- echo "building ${CI_PROJECT_NAME} for ${DOCKER_BUILD_SERVICE_IMAGE}"
- docker build
--build-arg AWS_ACCESS_KEY_ID
--build-arg AWS_SECRET_ACCESS_KEY
--build-arg GITLAB_TOKEN
--build-arg GITHUB_TOKEN=$GITHUB_BOT_TOKEN_REPO_FULL
--tag $DOCKER_BUILD_SERVICE_IMAGE
--file ${DOCKER_DIR:-.}/${DOCKERFILE:-Dockerfile}
${DOCKER_DIR:-.}
- docker save $DOCKER_BUILD_SERVICE_IMAGE > image.tar
after_script:
- cp image.tar image-ui.tar
artifacts:
expire_in: 2w
paths:
- image.tar
- image-ui.tar
rules:
- if: $CI_COMMIT_REF_NAME == "master"
- changes:
- ui/**/*
test:composition:
tags:
- mender-qa-worker-generic-light
stage: acceptance_tests
image: tiangolo/docker-with-compose
needs:
- job: build:docker
artifacts: true
- job: build:docker:ui
artifacts: true
services:
- docker:20.10.8-dind
before_script:
- docker load -i image-api.tar
- docker tag mendersoftware/mantra-api:${CI_COMMIT_REF_SLUG} mendersoftware/mantra-api:pr
- docker load -i image-ui.tar
- docker tag mendersoftware/mantra-ui:${CI_COMMIT_REF_SLUG} mendersoftware/mantra-ui:pr
- apk add --no-cache python3
- pip3 install --ignore-installed tox
- echo $'[api]\nbase_url = http://test:test@docker/api' > backend/tetra-test.conf
script:
- docker-compose -f docker-compose.yml -f docker-compose.test.yml up -d db
- sleep 10
- docker-compose -f docker-compose.yml -f docker-compose.test.yml up --no-recreate -d
- cd backend
- TOXENV=functional tox
publish:image:ui:
extends: publish:image
dependencies:
- build:docker:ui
variables:
DOCKER_REPOSITORY: mendersoftware/mantra-ui
DOCKER_DIR: ui
sync:image:ui:
extends: sync:image
dependencies:
- publish:image:ui
variables:
DOCKER_REPOSITORY: mendersoftware/mantra-ui
TARGET_MANIFEST_FILE: kubernetes/mender-qastatus/ui-deployment.yaml