Skip to content

Commit 48c0c76

Browse files
authored
Restyle Included config files and made few changes in config,yml (#33)
Restyle Included config files and made few changes in config,yml
2 parents fe59f4a + 123c39d commit 48c0c76

File tree

3 files changed

+132
-47
lines changed

3 files changed

+132
-47
lines changed

.circleci/config.yml

Lines changed: 50 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,54 @@
11
---
2-
# Python CircleCI 2.0 configuration file
3-
#
4-
# Check https://circleci.com/docs/2.0/language-python/ for more details
5-
#
62
version: 2
73
jobs:
84
build:
9-
docker:
10-
- image: circleci/mysql:5.7
11-
working_directory: /root/singnet
12-
environment:
13-
PYTHONPATH: /root/singnet/snet-platform-usage
14-
steps:
15-
- checkout
16-
- restore_cache:
17-
keys:
18-
- v1-dependencies-{{ checksum "metering/requirements.txt" }}
19-
# fallback to using the latest cache if no exact match is found
20-
- v1-dependencies-
21-
- run:
22-
name: Install Python and Git
23-
command: |
24-
mysql --version
25-
service mysql start
26-
apt-get update
27-
apt-get -y install sudo wget git
28-
apt-get -y install python3 python3-pip
29-
- run:
30-
name: install dependencies
31-
command: |
32-
python3 -m venv venv
33-
. venv/bin/activate
34-
pip install -r metering/requirements.txt
35-
- save_cache:
36-
paths:
37-
- ./venv
38-
key: v1-dependencies-{{ checksum "requirements.txt" }}
39-
# run tests!
40-
# this example uses Django's built-in test-runner
41-
# other common Python testing frameworks include pytest and nose
42-
# https://pytest.org
43-
# https://nose.readthedocs.io
44-
- run:
45-
name: run tests
46-
command: |
47-
. venv/bin/activate
48-
python metering/tests/test_total_calls.py test
49-
- store_artifacts:
50-
path: test-reports
51-
destination: test-reports
5+
docker:
6+
- image: circleci/python:3.6.6-node
7+
- image: circleci/mysql:8.0.16
8+
environment:
9+
MYSQL_ROOT_PASSWORD: rootpw
10+
MYSQL_DATABASE: test_db
11+
MYSQL_USER: user
12+
MYSQL_PASSWORD: passw0rd
13+
working_directory: ~/singnet
14+
environment:
15+
PYTHONPATH: ~/singnet/snet-platform-usage/metering
16+
steps:
17+
- checkout
18+
- run:
19+
# Our primary container isn't MYSQL so run a sleep command until it's ready.
20+
name: Waiting for MySQL to be ready
21+
command: |
22+
for i in `seq 1 30`;
23+
do
24+
nc -z 127.0.0.1 3306 && echo Success && exit 0
25+
echo -n .
26+
sleep 1
27+
done
28+
echo Failed waiting for MySQL && exit 1
29+
- run:
30+
name: Initialise tables.
31+
command: |
32+
cd metering
33+
cp tests/alembic.ini .
34+
cp tests/test-settings.py settings.py
35+
sudo pip install alembic
36+
sudo pip install pymysql
37+
sudo pip install cryptography
38+
PYTHONPATH=$PWD
39+
alembic upgrade head
40+
- run:
41+
name: Install dependencies & compile
42+
command: |
43+
cd metering
44+
python -m compileall *.py
45+
python -m compileall */*.py
46+
sudo pip install -r requirements.txt
47+
- run:
48+
name: run tests for metering
49+
command: |
50+
cd metering
51+
PYTHONPATH=$PWD python tests/test_total_calls.py
52+
- store_artifacts:
53+
path: test-reports
54+
destination: test-reports

metering/tests/alembic.ini

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
# A generic, single database configuration.
2+
3+
[alembic]
4+
# path to migration scripts
5+
script_location = alembic
6+
7+
# template used to generate migration files
8+
# file_template = %%(rev)s_%%(slug)s
9+
10+
# timezone to use when rendering the date
11+
# within the migration file as well as the filename.
12+
# string value is passed to dateutil.tz.gettz()
13+
# leave blank for localtime
14+
# timezone =
15+
16+
# max length of characters to apply to the
17+
# "slug" field
18+
# truncate_slug_length = 40
19+
20+
# set to 'true' to run the environment during
21+
# the 'revision' command, regardless of autogenerate
22+
# revision_environment = false
23+
24+
# set to 'true' to allow .pyc and .pyo files without
25+
# a source .py file to be detected as revisions in the
26+
# versions/ directory
27+
# sourceless = false
28+
29+
# version location specification; this defaults
30+
# to alembic/versions. When using multiple version
31+
# directories, initial revisions must be specified with --version-path
32+
# version_locations = %(here)s/bar %(here)s/bat alembic/versions
33+
34+
# the output encoding used when revision files
35+
# are written from script.py.mako
36+
# output_encoding = utf-8
37+
38+
sqlalchemy.url = mysql+pymysql://user:passw0rd@localhost/test_db
39+
40+
41+
# Logging configuration
42+
[loggers]
43+
keys = root,sqlalchemy,alembic
44+
45+
[handlers]
46+
keys = console
47+
48+
[formatters]
49+
keys = generic
50+
51+
[logger_root]
52+
level = WARN
53+
handlers = console
54+
qualname =
55+
56+
[logger_sqlalchemy]
57+
level = WARN
58+
handlers =
59+
qualname = sqlalchemy.engine
60+
61+
[logger_alembic]
62+
level = INFO
63+
handlers =
64+
qualname = alembic
65+
66+
[handler_console]
67+
class = StreamHandler
68+
args = (sys.stderr,)
69+
level = NOTSET
70+
formatter = generic
71+
72+
[formatter_generic]
73+
format = %(levelname)-5.5s [%(name)s] %(message)s
74+
datefmt = %H:%M:%S
75+

metering/tests/test-settings.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
DB_HOST = 'localhost'
2+
DB_NAME = 'test_db'
3+
DB_USER = 'user'
4+
DB_PWD = 'passw0rd'
5+
DB_DRIVER = 'mysql+pymysql'
6+
7+
DB_URL = f"mysql+pymysql://{DB_USER}:{DB_PWD}@{DB_HOST}/{DB_NAME}"

0 commit comments

Comments
 (0)