forked from falkr/reflect-2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
176 lines (165 loc) · 3.69 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
stages:
- lint
- build
- duplicate-check
- test
- deploy
variables:
PUBLIC_API_URL: "http://127.0.0.1:8000"
cache:
key: ${CI_COMMIT_REF_SLUG}-node-modules
paths:
- node_modules/
lint backend:
stage: lint
image: python:3.11
script:
- echo "Linting the backend"
- python --version
- pip install --upgrade pip
- pip install black
- cd backend
- black --check .
only:
- merge_requests
lint frontend:
stage: lint
image: node:20
script:
- echo "Linting the frontend"
- cd frontend
- npm ci
- npm run lint
- npm run check
only:
- merge_requests
build frontend:
stage: build
image: node:20
script:
- echo "Building the project"
- cd frontend
- npm i --cache .npm --prefer-offline
- npm run build
only:
- merge_requests
dependencies:
- lint frontend
frontend check:
stage: duplicate-check
image: node:20
script:
- echo "Checking for duplicate files in the frontend"
- cd frontend
- npm i --cache .npm --prefer-offline
- npm run duplication-check
only:
- merge_requests
dependencies:
- lint frontend
test backend:
stage: test
image: python:3.9
script:
- echo "Testing the backend"
- pip install --upgrade pip
- pip install pytest httpx pytest-asyncio
- cd backend
- pip install -r requirements.txt
- |
cat <<EOF > .env
TEST=true
SECRET_KEY=test
isAdmin=false
production=false
client_id = ""
client_secret = ""
REDIRECT_URI = ""
BASE_URL = ""
MAIL_USERNAME = $MAIL_USERNAME
MAIL_PASSWORD = $MAIL_PASSWORD
MAIL_FROM = $MAIL_FROM
MAIL_PORT = $MAIL_PORT
MAIL_SERVER = $MAIL_SERVER
EOF
- pytest -p no:warnings
only:
- merge_requests
test frontend:
stage: test
image: node:20
script:
- echo "Testing the frontend"
- cd frontend
- npm i --cache .npm --prefer-offline
- npm run test
only:
- merge_requests
deploy-frontend:
stage: deploy
image: node:19
script:
- echo "Deploying to Vercel for the frontend"
- cd frontend
- |
cat <<EOF > .env
PUBLIC_API_URL = $PUBLIC_API_URL
EOF
- npx vercel --token $VERCEL_TOKEN --confirm=n --prod --name frontend
only:
- dev
environment:
name: production
variables:
VERCEL_TOKEN: $VERCEL_TOKEN
PUBLIC_API_URL: $PUBLIC_API_URL
deploy-backend:
stage: deploy
image: node:19
script:
- echo "Deploying to Heroku for the backend"
- cd backend
- |
cat <<EOF > .env
SECRET_KEY = $SECRET_KEY
isAdmin=false
production = true
client_id = $CLIENT_ID
client_secret = $CLIENT_SECRET
DATABASE_URI = $DATABASE_URI
REDIRECT_URI = $REDIRECT_URI
BASE_URL = $BASE_URL
PRODUCTION_ORIGIN = $PRODUCTION_ORIGIN
MAIL_USERNAME = $MAIL_USERNAME
MAIL_PASSWORD = $MAIL_PASSWORD
MAIL_FROM = $MAIL_FROM
MAIL_PORT = $MAIL_PORT
MAIL_SERVER = $MAIL_SERVER
UID = ""
EMAIL_USER = ""
USER_EMAIL = ""
TEST_ACCOUNT = false
OPENAI_KEY = $OPENAI_KEY
SERVERLESS = true
EOF
- echo "Waiting for 3 seconds before deploying"
- sleep 3
- npx vercel --token $VERCEL_TOKEN --confirm=n --prod --name backend
variables:
VERCEL_TOKEN: $VERCEL_TOKEN
SECRET_KEY: $SECRET_KEY
CLIENT_ID: $CLIENT_ID
CLIENT_SECRET: $CLIENT_SECRET
REDIRECT_URI: $REDIRECT_URI
BASE_URL: $BASE_URL
MAIL_USERNAME: $MAIL_USERNAME
MAIL_PASSWORD: $MAIL_PASSWORD
MAIL_FROM: $MAIL_FROM
MAIL_PORT: $MAIL_PORT
MAIL_SERVER: $MAIL_SERVER
DATABASE_URI: $DATABASE_URI
OPENAI_KEY: $OPENAI_KEY
only:
- dev
environment:
name: production