-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy path.gitlab-ci.yml
126 lines (116 loc) · 3.33 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
image: node:16
variables:
CHROME_BIN: chromium-browser
CONTAINER_IMAGE: ${CI_REGISTRY_IMAGE}:${CI_COMMIT_SHORT_SHA}
POSTGRES_HOST_AUTH_METHOD: "trust"
EMAIL_BACKEND: "django.core.mail.backends.console.EmailBackend"
SECRET_KEY: "testing"
ENABLE_TEST_API: "true"
FF_NETWORK_PER_BUILD: 1
DEBUG: "true"
GIT_SUBMODULE_STRATEGY: normal
SAST_EXCLUDED_PATHS: "*.stories.ts, *.spec.ts, cypress"
include:
- template: SAST.gitlab-ci.yml
- template: Dependency-Scanning.gitlab-ci.yml
- template: Secret-Detection.gitlab-ci.yml
stages:
- test
- build
- deploy
test:
stage: test
image: node:16-alpine
script:
- apk add --update --no-cache chromium-chromedriver chromium git
- npm ci --force
- npm run lint
- npm run test -- --progress false --watch=false --browsers=Chromium_CI
test-e2e:
stage: test
variables:
ENABLE_ORGANIZATION_CREATION: "true"
CELERY_TASK_ALWAYS_EAGER: "true"
services:
- postgres
- name: registry.gitlab.com/glitchtip/glitchtip-backend:master
alias: backend
command: ["./bin/run-migrate-and-runserver.sh"]
image:
name: cypress/included:10.1.0
entrypoint: [""]
script:
- npm ci --force
- cp src/proxy.conf.ci.json src/proxy.conf.json
- npm run e2e
except:
- tags
artifacts:
when: always
paths:
- cypress/videos/**/*.mp4
- cypress/screenshots/**/*.png
expire_in: 1 day
build-assets:
stage: test
script:
- npm ci --force
- npm run build-prod
artifacts:
paths:
- dist/
build-docker:
stage: build
image: docker:stable
services:
- docker:dind
dependencies:
- build-assets
# needs: ["build-assets"]
only:
refs:
- master
- tags
variables:
- $CI_COMMIT_REF_PROTECTED
script:
- echo "Start build docker step $CI_REGISTRY_IMAGE commit ref $CI_COMMIT_REF_NAME"
- trap '' PIPE
- VERSION=${CI_COMMIT_REF_NAME#*v}
- echo "Build version $VERSION ci registry image $CI_REGISTRY_IMAGE commit ref $CI_COMMIT_REF_NAME"
- docker build -f Dockerfile.prod -t ${CI_REGISTRY_IMAGE}:${CI_COMMIT_REF_NAME} -t ${CONTAINER_IMAGE} --build-arg FRONTEND_GLITCHTIP_VERSION=$VERSION .
- if [ $CI_COMMIT_REF_NAME = "master" ]; then docker tag ${CONTAINER_IMAGE} ${CI_REGISTRY_IMAGE}:latest; fi
- docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN registry.gitlab.com
- docker push ${CI_REGISTRY_IMAGE}:${CI_COMMIT_REF_NAME}
- docker push ${CONTAINER_IMAGE}
- if [ $CI_COMMIT_REF_NAME = "master" ]; then docker push ${CI_REGISTRY_IMAGE}:latest; fi
upload-sourcemaps:
stage: deploy
image: getsentry/sentry-cli
dependencies:
- build-assets
script:
- VERSION=glitchtip@${CI_COMMIT_REF_NAME#*v}
- sentry-cli releases files ${VERSION} upload-sourcemaps dist/glitchtip-frontend
only:
refs:
- tags
variables:
- $CI_COMMIT_REF_PROTECTED
deploy-staging:
stage: deploy
image:
name: alpine/helm:3.6.3
entrypoint: [""]
# needs: ["build-docker", "test-e2e"]
script:
- helm repo add glitchtip https://gitlab.com/api/v4/projects/16325141/packages/helm/stable
- helm upgrade glitchtip-staging glitchtip/glitchtip --set-string image.tag=${CI_COMMIT_SHORT_SHA} --reuse-values
environment:
name: staging
url: https://staging.glitchtip.com
only:
refs:
- master
variables:
- $CI_COMMIT_REF_PROTECTED