-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
110 lines (103 loc) · 2.97 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
stages:
- lint
- test
- deploy
- sanity-test
lint-flask:
stage: lint
image: python:3.10
allow_failure: true
before_script:
- cd server/
- python --version
- pip install -r requirements.txt
script:
- flake8
lint-react:
stage: lint
image: node:18
allow_failure: true
before_script:
- cd web/
- yarn install
script:
- yarn lint
test-flask:
stage: test
image: python:3.10
before_script:
- cd server/
- python --version
- pip install -r requirements.txt
script:
- python3 -m unittest tests/test_endpoints.py -v
test-react:
stage: test
image: node:18
before_script:
- cd web/
- yarn install
script:
- yarn test
deploy-server:
stage: deploy
image: alpine:latest
before_script:
- 'command -v ssh-agent >/dev/null || ( apk add --update openssh )'
- eval $(ssh-agent -s)
- echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add -
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
- ssh-keyscan advisorlink.ml >> ~/.ssh/known_hosts
- chmod 644 ~/.ssh/known_hosts
script:
- ssh [email protected] "cd git/f22_cis3760_team106online && git fetch && git checkout $CI_COMMIT_BRANCH && git reset --hard origin/$CI_COMMIT_BRANCH && sudo make production"
rules:
- if: $CI_COMMIT_REF_NAME == $CI_DEFAULT_BRANCH
restart-database:
stage: deploy
image: alpine:latest
when: manual
before_script:
- 'command -v ssh-agent >/dev/null || ( apk add --update openssh )'
- eval $(ssh-agent -s)
- echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add -
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
- ssh-keyscan advisorlink.ml >> ~/.ssh/known_hosts
- chmod 644 ~/.ssh/known_hosts
script:
- ssh [email protected] "cd git/f22_cis3760_team106online && sudo make db"
rules:
- if: $CI_COMMIT_REF_NAME == $CI_DEFAULT_BRANCH
test-frontend:
stage: sanity-test
image: ubuntu:latest
services:
- selenium/standalone-chrome
dependencies:
- deploy-server
before_script:
- cd server/
# Update apt-get and install pip
- apt-get update
- apt-get install -y python3-pip libpq-dev python3-dev
- pip3 install -r requirements.txt
# Install chrome
- cd tests/selenium
- apt-get install -y xvfb zip wget ca-certificates
- apt-get install -y libnss3-dev libasound2 libxss1 libappindicator3-1 libindicator7 gconf-service libgconf-2-4 libpango1.0-0 xdg-utils fonts-liberation libgbm1 libcurl4
- wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
- apt install -y ./google-chrome-stable_current_amd64.deb
- rm google-chrome*.deb
# Install chromedriver
- wget -N http://chromedriver.storage.googleapis.com/89.0.4389.23/chromedriver_linux64.zip
- unzip -o chromedriver_linux64.zip
- chmod +x chromedriver
- cp chromedriver /usr/local/bin
- rm chromedriver_linux64.zip
- rm chromedriver
script:
- python3 test_frontend.py -headless
rules:
- if: $CI_COMMIT_REF_NAME == $CI_DEFAULT_BRANCH