-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy path.travis.yml
125 lines (119 loc) · 4.87 KB
/
.travis.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
language: python
dist: jammy
python: 3.10.13
if: branch = master AND type = push OR type = pull_request
stages:
- name: linting
- name: unitttest
- name: deploy
# - name: test
before_script:
- sudo apt-get update
- sudo apt-get install -y ssh sshpass curl
jobs:
include:
- stage: linting
name: Python linting
script:
- export PIPENV_VERBOSITY=-1
- cd bot
- pip install pipenv
- pipenv install --dev --skip-lock
- pipenv graph
- echo "Running Python linting"
- pipenv run mypy --version
- pipenv run black --version
- pipenv run isort --version
- pylint --disable=C0116 --disable=C0114 --disable=R0401 --disable=W0613 --disable=C0415 --disable=W0718 --disable=C0115 support_bot
- flake8 --show-source --statistics --max-complexity 6 support_bot tests
- echo "Running autoflake on support_bot and tests files"
- pipenv run autoflake --recursive --check --ignore-init-module-imports --remove-unused-variables --remove-all-unused-imports support_bot tests
- echo "Running mypy, black, and isort checks"
- pipenv run mypy support_bot
- pipenv run black --check support_bot tests
- pipenv run isort --check-only support_bot tests
- echo "Python linting completed successfully"
- stage: linting
name: TypeScript linting
script:
- echo "Running TypeScript linting"
- cd typescript-app
- npm install
- npx prettier --check --config .prettierrc --ignore-path .prettierignore frontend app.ts
- echo "TypeScript linting completed successfully"
- stage: unitttest
script:
- echo "Installing dependencies"
- cd bot
- pip install pipenv
- pipenv install --dev --skip-lock
- echo "Running unit tests"
- pipenv run pytest tests -v
- stage: deploy
script:
- |
echo "Deploying service on test server"
sshpass -p $PIPELINE_SERVER_PASSWORD ssh -o StrictHostKeyChecking=no root@$PIPELINE_SERVER_IP_ADDRESS << ENDSSH
cd /home
git clone https://github.com/Grommash9/tg_chat_mate
cd tg_chat_mate
if [[ "$TRAVIS_PULL_REQUEST" != "false" ]]; then
git fetch origin +refs/pull/$TRAVIS_PULL_REQUEST/merge: --depth=50
git checkout -qf FETCH_HEAD
else
git checkout -qf "$TRAVIS_BRANCH"
fi
export DOMAIN=$PIPELINE_SERVER_IP_ADDRESS
echo "DOMAIN=$PIPELINE_SERVER_IP_ADDRESS" >> .env
echo "ISSUE_SSL=true" >> .env
echo "MONGO_USERNAME=root" >> .env
echo "MONGO_DATABASE=bot_support_db" >> .env
echo "MONGO_PORT=27017" >> .env
echo "MONGO_HOST=192.168.1.50" >> .env
echo "BOT_TOKEN=$BOT_TOKEN" >> .env
echo "MONGO_PASSWORD=$MONGO_PASSWORD" >> .env
echo "LONG_GOOD_SECRET_KEY=$LONG_GOOD_SECRET_KEY" >> .env
echo "ROOT_PASSWORD=$ROOT_PASSWORD" >> .env
chmod +x install.sh
./install.sh
docker cp ./dump.gz tg_chat_mate-mongo-db-1:/data/dump.gz
docker-compose exec mongo-db mongorestore --archive=/data/dump.gz --gzip --db bot_support_db --username root --password $MONGO_PASSWORD --authenticationDatabase admin
ENDSSH
after_failure:
- |
sshpass -p $PIPELINE_SERVER_PASSWORD ssh -o StrictHostKeyChecking=no root@$PIPELINE_SERVER_IP_ADDRESS << 'ENDSSH'
echo "Removing from test server"
cd /home/tg_chat_mate
docker compose down
docker rm -f $(docker ps -a -q)
docker volume rm $(docker volume ls -q)
rm -r /home/tg_chat_mate
ENDSSH
# - stage: test
# script:
# - echo "Running tests"
# - |
# sshpass -p $PIPELINE_SERVER_PASSWORD ssh -o StrictHostKeyChecking=no root@$PIPELINE_SERVER_IP_ADDRESS << 'ENDSSH'
# docker exec tg_chat_mate-bot-1 pipenv install —dev
# docker exec tg_chat_mate-bot-1 pipenv run pytest tests/post_deploy_tests.py -v
# ENDSSH
# after_failure:
# - |
# echo "Removing from test server"
# sshpass -p $PIPELINE_SERVER_PASSWORD ssh -o StrictHostKeyChecking=no root@$PIPELINE_SERVER_IP_ADDRESS << 'ENDSSH'
# cd /home/tg_chat_mate
# docker compose down
# docker rm -f $(docker ps -a -q)
# docker volume rm $(docker volume ls -q)
# rm -r /home/tg_chat_mate
# ENDSSH
# after_success:
# - |
# echo "Removing from test server"
# sshpass -p $PIPELINE_SERVER_PASSWORD ssh -o StrictHostKeyChecking=no root@$PIPELINE_SERVER_IP_ADDRESS << 'ENDSSH'
# cd /home/tg_chat_mate
# docker compose down
# docker rm -f $(docker ps -a -q)
# docker volume rm $(docker volume ls -q)
# rm -r /home/tg_chat_mate
# ENDSSH