-
Notifications
You must be signed in to change notification settings - Fork 5
/
.gitlab-ci.yml
189 lines (170 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
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
image: alpine:3.12
stages:
- build
- test
- artefacts
- release
variables:
DOCKER_BUILD: docker image build --pull
DOCKER_BUILDKIT: "1"
DOCKER_CLI_EXPERIMENTAL: enabled
DOCKER_HOST: "tcp://dind:2375/"
GIT_FETCH_EXTRA_FLAGS: --tags
GIT_STRATEGY: fetch
GIT_SUBMODULE_STRATEGY: recursive
DOCKER_TAGS: ${CI_COMMIT_SHORT_SHA}-${CI_PIPELINE_IID}
DOCKER_IMAGE: registry.gitlab.com/makersquad/oss/harp
DOCKER_IMAGE_DEV: registry.gitlab.com/makersquad/oss/harp
CI_REGISTRY_PASSWORD: ${CI_JOB_TOKEN}
KUBERNETES_CPU_REQUEST: "0.5"
KUBERNETES_CPU_LIMIT: "1"
.DockerBuild: &DockerBuild
image: docker:24.0.6
stage: build
before_script:
- apk add git make py3-pip py3-jinja2 bash
- pip install 'poetry==1.7.1'
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
retry:
max: 2
when: runner_system_failure
build:runtime:
<<: *DockerBuild
script:
- bash bin/sandbox make buildc pushc
build:dev:
<<: *DockerBuild
variables:
DOCKER_TAGS_SUFFIX: -dev
script:
- bash bin/sandbox make buildc-dev pushc-dev
.TestBase: &TestBase
needs: ["build:dev"]
image: ${DOCKER_IMAGE}:${DOCKER_TAGS}-dev
stage: test
variables: &TestBaseVariables
GIT_STRATEGY: none
before_script:
- 'export DOCKER_HOST=tcp://$(curl -sSk -H "Authorization: Bearer $(cat /var/run/secrets/kubernetes.io/serviceaccount/token)" "https://kubernetes.default.svc/api/v1/namespaces/cicd/pods" | jq -r ''.items[] | select(.metadata.labels.app=="dind") | .status.podIP''):2375/'
- 'echo DOCKER_HOST=$DOCKER_HOST'
.TestBackend: &TestBackend
<<: *TestBase
variables: &TestBackendVariables
<<: *TestBaseVariables
PYTEST: /opt/venv/bin/pytest
PYTEST_OPTIONS: "-m 'not subprocess'"
script:
- (cd /opt/harp/src; poetry run make test-backend)
.TestFrontend: &TestFrontend
<<: *TestBase
variables: &TestFrontendVariables
<<: *TestBaseVariables
test:backend:core:
<<: *TestBackend
variables:
<<: *TestBackendVariables
PYTEST_TARGETS: "harp"
test:backend:apps:
<<: *TestBackend
variables:
<<: *TestBackendVariables
PYTEST_TARGETS: "harp_apps"
KUBERNETES_CPU_REQUEST: "1"
KUBERNETES_CPU_LIMIT: "2"
test:backend:e2e:
<<: *TestBackend
variables:
<<: *TestBackendVariables
PYTEST_TARGETS: "tests"
PYTEST_CPUS: "1"
test:frontend:unit:
<<: *TestFrontend
variables:
<<: *TestFrontendVariables
KUBERNETES_CPU_REQUEST: "2"
KUBERNETES_CPU_LIMIT: "3"
script:
- (cd /opt/harp/src/harp_apps/dashboard/frontend; pnpm test:unit)
#test:frontend:browser:
# <<: *TestFrontend
# variables:
# <<: *TestFrontendVariables
# script:
# - (cd /opt/harp/src/harp_apps/dashboard/frontend; pnpm test:browser)
#
#test:frontend:visual:
# <<: *TestFrontend
# variables:
# <<: *TestFrontendVariables
# script:
# - (cd /opt/harp/src; bin/runc_visualtests pnpm test:ui:dev)
doc:html:
needs: ["build:dev"]
image: ${DOCKER_IMAGE}:${DOCKER_TAGS}-dev
stage: artefacts
variables:
GIT_STRATEGY: none
SPHINXBUILD: /opt/venv/bin/sphinx-build
script:
- (cd /opt/harp/src/docs; make html)
- mv /opt/harp/src/docs/_build/html harp-doc
artifacts:
name: harp-doc
expire_in: 1 month
paths:
- "harp-doc/*"
storybook:
needs: ["build:dev"]
image: ${DOCKER_IMAGE}:${DOCKER_TAGS}-dev
stage: artefacts
variables:
GIT_STRATEGY: none
script:
- (cd /opt/harp/src/harp_apps/dashboard/frontend; pnpm ui:build)
- mv /opt/harp/src//harp_apps/dashboard/frontend/build harp-ui
artifacts:
name: harp-ui
expire_in: 1 month
paths:
- "harp-ui/*"
release:
image: docker:24.0.6
needs:
- "build:runtime"
- "test:backend:core"
- "test:backend:apps"
- "test:backend:e2e"
- "test:frontend:unit"
# - "test:frontend:browser"
# - "test:frontend:visual"
stage: release
only:
- /^[0-9]+\.[0-9]+$/
- tags
variables:
GIT_STRATEGY: none
SOURCE_IMAGE: registry.gitlab.com/makersquad/oss/harp:${DOCKER_TAGS}
before_script:
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- docker pull ${SOURCE_IMAGE}
- docker login -u $DOCKERHUB_USERNAME -p $DOCKERHUB_PASSWORD docker.io
script:
- echo "CI_COMMIT_BRANCH = ${CI_COMMIT_BRANCH}"
- echo "CI_COMMIT_TAG = ${CI_COMMIT_TAG}"
- if [ -n "$CI_COMMIT_BRANCH" ]; then
docker tag ${SOURCE_IMAGE} makersquad/harp-proxy:${CI_COMMIT_BRANCH}-git;
docker push makersquad/harp-proxy:${CI_COMMIT_BRANCH}-git;
fi
- if [ -n "$CI_COMMIT_TAG" ]; then
docker tag ${SOURCE_IMAGE} makersquad/harp-proxy:${CI_COMMIT_TAG};
docker push makersquad/harp-proxy:${CI_COMMIT_TAG};
fi
- if [ -n "$CI_COMMIT_TAG" ]; then
if echo "$CI_COMMIT_TAG" | grep -qE '^[0-9]+\.[0-9]+\.[0-9]+$'; then
docker tag ${SOURCE_IMAGE} makersquad/harp-proxy:latest;
docker push makersquad/harp-proxy:latest;
fi;
fi
retry:
max: 2
when: runner_system_failure