-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
executable file
·142 lines (134 loc) · 3.22 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
stages:
- build
- test
- format
- deploy
variables:
DEPLOYMENT_BRANCH: "/master|staging|production/"
frontend build:
stage: build
image: node:10
tags:
- docker
rules:
- if: '$CI_MERGE_REQUEST_ID != null || $CI_COMMIT_BRANCH =~ $DEPLOYMENT_BRANCH'
- changes:
- client/**/*
before_script:
- cd client
- npm install
script:
- CI=false yarn build
backend unit tests:
stage: test
image: python:3.7.6-buster
tags:
- docker
rules:
- if: '$CI_MERGE_REQUEST_ID != null || $CI_COMMIT_BRANCH =~ $DEPLOYMENT_BRANCH'
- changes:
- server/**/*
before_script:
- cd server
- pip install --upgrade pip
- pip install -r requirements.txt
script:
- python -m pytest Tests
backend system tests:
stage: test
image: python:3.7.6-buster
tags:
- docker
rules:
- if: '$CI_MERGE_REQUEST_ID != null || $CI_COMMIT_BRANCH =~ $DEPLOYMENT_BRANCH'
- changes:
- server/**/*
variables:
# Cradle Server Variables
DB_USERNAME: "root"
DB_PASSWORD: "ci-password"
EMAIL_USER: "[email protected]"
EMAIL_PASSWORD: "ci-password"
DB_HOSTNAME: "mysql"
DB_PORT: "3306"
DB_NAME: "cradle"
PORT: "5000"
# MySQL Variables
MYSQL_DATABASE: "cradle"
MYSQL_ROOT_PASSWORD: "ci-password"
services:
- mysql:5.7
before_script:
# Add mysql client so we can execute queries on the database
- apt-get update -y
- apt-get install default-mysql-client -y
- cd server
- pip install --upgrade pip
- pip install -r requirements.txt
# Spin up a server instance in the background
# Run this first so that the server can warm up whilst we seed the db
- python3 app.py &
# Build and seed database
- python3 db.py rebuild --no-docker
- python3 manage.py seed_test_data
script:
- python -m pytest SystemTests
frontend lint:
stage: format
image: node:10
tags:
- docker
rules:
- if: '$CI_MERGE_REQUEST_ID != null || $CI_COMMIT_BRANCH =~ $DEPLOYMENT_BRANCH'
when: always
- changes:
- client/**/*
when: always
before_script:
- cd client
- npm install
script:
- ./node_modules/.bin/eslint "src/**/*.{ts,tsx}"
frontend format:
stage: format
image: node:10
tags:
- docker
rules:
- if: '$CI_MERGE_REQUEST_ID != null || $CI_COMMIT_BRANCH =~ $DEPLOYMENT_BRANCH'
when: always
- changes:
- client/**/*
when: always
before_script:
- npm install prettier --global
script:
- prettier --check "client/src/**/*.{ts,tsx}"
backend format:
stage: format
image: python:3.7.6-buster
tags:
- docker
rules:
- if: '$CI_MERGE_REQUEST_ID != null || $CI_COMMIT_BRANCH =~ $DEPLOYMENT_BRANCH'
when: always
- changes:
- server/**/*
when: always
before_script:
- pip install --upgrade pip
- pip install black
script:
- black --check --exclude 'server/migrations/.*' server
deploy staging:
stage: deploy
tags:
- shell
rules:
# Only deploy to staging if we are on the master or stating branch.
- if: '$CI_MERGE_REQUEST_ID == null && $CI_COMMIT_BRANCH =~ "/master|staging/"'
when: on_success
- when: never
script:
- source /var/cradle/staging.env
- ./scripts/deploy.sh